Set the b64 encoded cert as a string
Sending a byte string to relation-set can result in the data being sent being prefixed with a "b'". In this case it corrupts the b64encoding and the receiving charm (ceilometer-agent) cannot b64decode the data. Change-Id: I004bff0706362f893f2f69b07568be1034dbf574
This commit is contained in:
parent
157efee911
commit
7ad2d31417
|
@ -440,7 +440,7 @@ def ceilometer_joined():
|
|||
# pass the data to agents.
|
||||
if 'rabbit_ssl_ca' in context:
|
||||
with open(context['rabbit_ssl_ca'], 'rb') as fh:
|
||||
context['rabbit_ssl_ca'] = base64.b64encode(fh.read())
|
||||
context['rabbit_ssl_ca'] = base64.b64encode(fh.read()).decode()
|
||||
for relid in relation_ids('ceilometer-service'):
|
||||
relation_set(relid, context)
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import copy
|
|||
import os
|
||||
import sys
|
||||
|
||||
from mock import patch, MagicMock, call
|
||||
from mock import patch, MagicMock, call, mock_open
|
||||
|
||||
# python-apt is not installed as part of test-requirements but is imported by
|
||||
# some charmhelpers modules so create a fake import.
|
||||
|
@ -317,10 +317,17 @@ class CeilometerHooksTest(CharmTestCase):
|
|||
@patch('charmhelpers.core.hookenv.config')
|
||||
def test_ceilometer_joined(self, mock_config):
|
||||
self.relation_ids.return_value = ['ceilometer:0']
|
||||
self.get_ceilometer_context.return_value = {'test': 'data'}
|
||||
hooks.hooks.execute(['hooks/ceilometer-service-relation-joined'])
|
||||
self.relation_set.assert_called_with('ceilometer:0',
|
||||
{'test': 'data'})
|
||||
self.get_ceilometer_context.return_value = {
|
||||
'test': 'data',
|
||||
'rabbit_ssl_ca': '/etc/certs/rabbit.pem'}
|
||||
with patch.object(
|
||||
hooks,
|
||||
'open',
|
||||
mock_open(read_data=b'dGVzdCBjZXJ0Cg==')):
|
||||
hooks.hooks.execute(['hooks/ceilometer-service-relation-joined'])
|
||||
self.relation_set.assert_called_with(
|
||||
'ceilometer:0',
|
||||
{'test': 'data', 'rabbit_ssl_ca': 'ZEdWemRDQmpaWEowQ2c9PQ=='})
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
def test_identity_notifications_changed(self, mock_config):
|
||||
|
|
Loading…
Reference in New Issue