Merge lp:~therve/landscape-client/attachment-ssl-key into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Geoff Teale
Approved revision: 529
Merged at revision: 528
Proposed branch: lp:~therve/landscape-client/attachment-ssl-key
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 72 lines (+41/-4)
2 files modified
landscape/manager/scriptexecution.py (+4/-2)
landscape/manager/tests/test_scriptexecution.py (+37/-2)
To merge this branch: bzr merge lp:~therve/landscape-client/attachment-ssl-key
Reviewer Review Type Date Requested Status
Geoff Teale (community) Approve
Björn Tillenius (community) Approve
Review via email: mp+98352@code.launchpad.net

Description of the change

Fairly straightforward fix, too bad I didn't think about it first.

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Looks good, +1!

review: Approve
529. By Thomas Herve

Fix test failure

Revision history for this message
Geoff Teale (tealeg) wrote :

+1 Great.

Thanks for fixing the tests.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/manager/scriptexecution.py'
2--- landscape/manager/scriptexecution.py 2012-03-12 20:23:24 +0000
3+++ landscape/manager/scriptexecution.py 2012-03-20 09:34:18 +0000
4@@ -217,8 +217,10 @@
5 data = attachment_id
6 yield succeed(None)
7 else:
8- data = yield fetch_async("%s%d" % (root_path, attachment_id),
9- headers=headers)
10+ data = yield fetch_async(
11+ "%s%d" % (root_path, attachment_id),
12+ cainfo=self.registry.config.ssl_public_key,
13+ headers=headers)
14 full_filename = os.path.join(attachment_dir, filename)
15 attachment = file(full_filename, "wb")
16 os.chmod(full_filename, 0600)
17
18=== modified file 'landscape/manager/tests/test_scriptexecution.py'
19--- landscape/manager/tests/test_scriptexecution.py 2012-03-14 12:48:53 +0000
20+++ landscape/manager/tests/test_scriptexecution.py 2012-03-20 09:34:18 +0000
21@@ -216,7 +216,41 @@
22 headers = {"User-Agent": "landscape-client/%s" % VERSION,
23 "Content-Type": "application/octet-stream",
24 "X-Computer-ID": "secure_id"}
25- mock_fetch("https://localhost/attachment/14", headers=headers)
26+ mock_fetch("https://localhost/attachment/14", headers=headers,
27+ cainfo=None)
28+ self.mocker.result(succeed("some other data"))
29+ self.mocker.replay()
30+
31+ result = self.plugin.run_script(
32+ u"/bin/sh",
33+ u"ls $LANDSCAPE_ATTACHMENTS && cat $LANDSCAPE_ATTACHMENTS/file1",
34+ attachments={u"file1": 14})
35+
36+ def check(result):
37+ self.assertEqual(result, "file1\nsome other data")
38+
39+ result.addCallback(check)
40+ return result
41+
42+ def test_run_with_attachment_ids_and_ssl(self):
43+ """
44+ When fetching attachments, L{ScriptExecution} passes the optional ssl
45+ certificate file if the configuration specifies it.
46+ """
47+ self.manager.config.url = "https://localhost/message-system"
48+ self.manager.config.ssl_public_key = "/some/key"
49+ persist = Persist(
50+ filename=os.path.join(self.config.data_path, "broker.bpickle"))
51+ registration_persist = persist.root_at("registration")
52+ registration_persist.set("secure-id", "secure_id")
53+ persist.save()
54+ mock_fetch = self.mocker.replace("landscape.lib.fetch.fetch_async",
55+ passthrough=False)
56+ headers = {"User-Agent": "landscape-client/%s" % VERSION,
57+ "Content-Type": "application/octet-stream",
58+ "X-Computer-ID": "secure_id"}
59+ mock_fetch("https://localhost/attachment/14", headers=headers,
60+ cainfo="/some/key")
61 self.mocker.result(succeed("some other data"))
62 self.mocker.replay()
63
64@@ -899,7 +933,8 @@
65 headers = {"User-Agent": "landscape-client/%s" % VERSION,
66 "Content-Type": "application/octet-stream",
67 "X-Computer-ID": "secure_id"}
68- mock_fetch("https://localhost/attachment/14", headers=headers)
69+ mock_fetch("https://localhost/attachment/14", headers=headers,
70+ cainfo=None)
71 self.mocker.result(fail(HTTPCodeError(404, "Not found")))
72 self.mocker.replay()
73

Subscribers

People subscribed via source and target branches

to all changes: