Merge lp:~ivoks/charms/precise/quantum-gateway/cert-decode into lp:~charmers/charms/precise/quantum-gateway/trunk

Proposed by Ante Karamatić
Status: Merged
Merged at revision: 42
Proposed branch: lp:~ivoks/charms/precise/quantum-gateway/cert-decode
Merge into: lp:~charmers/charms/precise/quantum-gateway/trunk
Diff against target: 55 lines (+11/-2)
3 files modified
hooks/quantum_hooks.py (+4/-1)
revision (+1/-1)
unit_tests/test_quantum_hooks.py (+6/-0)
To merge this branch: bzr merge lp:~ivoks/charms/precise/quantum-gateway/cert-decode
Reviewer Review Type Date Requested Status
James Page Approve
Ante Karamatić (community) Needs Resubmitting
Review via email: mp+204605@code.launchpad.net

Description of the change

Quantum gateway doesn't decode certificate from relation. This branch fixes that problem.

To post a comment you must log in.
Revision history for this message
James Page (james-page) wrote :

Change looks OK

Please can you update the units tests as well:

jamespage@armstrong[ubuntu]:~/src/charms/landing/quantum-gateway$ make test
Starting tests...
...................................F...........................
======================================================================
FAIL: test_nm_changed (unit_tests.test_quantum_hooks.TestQuantumHooks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jamespage/src/charms/landing/quantum-gateway/unit_tests/test_quantum_hooks.py", line 143, in test_nm_changed
    self.install_ca_cert.assert_called_with('cert')
  File "/usr/lib/python2.7/dist-packages/mock.py", line 835, in assert_called_with
    raise AssertionError(msg)
AssertionError: Expected call: install_ca_cert('cert')
Actual call: install_ca_cert('q\xea\xed')

Name Stmts Miss Cover Missing
------------------------------------------------------
hooks/quantum_contexts 92 3 97% 168-170
hooks/quantum_hooks 64 0 100%
hooks/quantum_utils 160 0 100%
------------------------------------------------------
TOTAL 316 3 99%
----------------------------------------------------------------------
Ran 63 tests in 0.856s

FAILED (failures=1)
make: *** [test] Error 1

I'd use the passthrough approach used in the dashboard change to cover this.

review: Needs Fixing
43. By Ante Karamatić

Fix tests for cert

44. By Ante Karamatić

Add missing newline

Revision history for this message
Ante Karamatić (ivoks) :
review: Needs Resubmitting
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/quantum_hooks.py'
2--- hooks/quantum_hooks.py 2013-11-28 13:12:39 +0000
3+++ hooks/quantum_hooks.py 2014-02-04 11:54:39 +0000
4@@ -1,5 +1,7 @@
5 #!/usr/bin/python
6
7+from base64 import b64decode
8+
9 from charmhelpers.core.hookenv import (
10 log, ERROR, WARNING,
11 config,
12@@ -125,7 +127,8 @@
13 def nm_changed():
14 CONFIGS.write_all()
15 if relation_get('ca_cert'):
16- install_ca_cert(relation_get('ca_cert'))
17+ ca_crt = b64decode(relation_get('ca_cert'))
18+ install_ca_cert(ca_crt)
19
20
21 @hooks.hook("cluster-relation-departed")
22
23=== modified file 'revision'
24--- revision 2013-11-28 13:12:39 +0000
25+++ revision 2014-02-04 11:54:39 +0000
26@@ -1,1 +1,1 @@
27-59
28+60
29
30=== modified file 'unit_tests/test_quantum_hooks.py'
31--- unit_tests/test_quantum_hooks.py 2013-11-28 13:12:39 +0000
32+++ unit_tests/test_quantum_hooks.py 2014-02-04 11:54:39 +0000
33@@ -36,9 +36,14 @@
34 'execd_preinstall',
35 'lsb_release',
36 'stop_services',
37+ 'b64decode',
38 ]
39
40
41+def passthrough(value):
42+ return value
43+
44+
45 class TestQuantumHooks(CharmTestCase):
46
47 def setUp(self):
48@@ -47,6 +52,7 @@
49 self.test_config.set('openstack-origin', 'cloud:precise-havana')
50 self.test_config.set('plugin', 'ovs')
51 self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'}
52+ self.b64decode.side_effect = passthrough
53
54 def _call_hook(self, hookname):
55 hooks.hooks.execute([

Subscribers

People subscribed via source and target branches