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
=== modified file 'landscape/manager/scriptexecution.py'
--- landscape/manager/scriptexecution.py 2012-03-12 20:23:24 +0000
+++ landscape/manager/scriptexecution.py 2012-03-20 09:34:18 +0000
@@ -217,8 +217,10 @@
217 data = attachment_id217 data = attachment_id
218 yield succeed(None)218 yield succeed(None)
219 else:219 else:
220 data = yield fetch_async("%s%d" % (root_path, attachment_id),220 data = yield fetch_async(
221 headers=headers)221 "%s%d" % (root_path, attachment_id),
222 cainfo=self.registry.config.ssl_public_key,
223 headers=headers)
222 full_filename = os.path.join(attachment_dir, filename)224 full_filename = os.path.join(attachment_dir, filename)
223 attachment = file(full_filename, "wb")225 attachment = file(full_filename, "wb")
224 os.chmod(full_filename, 0600)226 os.chmod(full_filename, 0600)
225227
=== modified file 'landscape/manager/tests/test_scriptexecution.py'
--- landscape/manager/tests/test_scriptexecution.py 2012-03-14 12:48:53 +0000
+++ landscape/manager/tests/test_scriptexecution.py 2012-03-20 09:34:18 +0000
@@ -216,7 +216,41 @@
216 headers = {"User-Agent": "landscape-client/%s" % VERSION,216 headers = {"User-Agent": "landscape-client/%s" % VERSION,
217 "Content-Type": "application/octet-stream",217 "Content-Type": "application/octet-stream",
218 "X-Computer-ID": "secure_id"}218 "X-Computer-ID": "secure_id"}
219 mock_fetch("https://localhost/attachment/14", headers=headers)219 mock_fetch("https://localhost/attachment/14", headers=headers,
220 cainfo=None)
221 self.mocker.result(succeed("some other data"))
222 self.mocker.replay()
223
224 result = self.plugin.run_script(
225 u"/bin/sh",
226 u"ls $LANDSCAPE_ATTACHMENTS && cat $LANDSCAPE_ATTACHMENTS/file1",
227 attachments={u"file1": 14})
228
229 def check(result):
230 self.assertEqual(result, "file1\nsome other data")
231
232 result.addCallback(check)
233 return result
234
235 def test_run_with_attachment_ids_and_ssl(self):
236 """
237 When fetching attachments, L{ScriptExecution} passes the optional ssl
238 certificate file if the configuration specifies it.
239 """
240 self.manager.config.url = "https://localhost/message-system"
241 self.manager.config.ssl_public_key = "/some/key"
242 persist = Persist(
243 filename=os.path.join(self.config.data_path, "broker.bpickle"))
244 registration_persist = persist.root_at("registration")
245 registration_persist.set("secure-id", "secure_id")
246 persist.save()
247 mock_fetch = self.mocker.replace("landscape.lib.fetch.fetch_async",
248 passthrough=False)
249 headers = {"User-Agent": "landscape-client/%s" % VERSION,
250 "Content-Type": "application/octet-stream",
251 "X-Computer-ID": "secure_id"}
252 mock_fetch("https://localhost/attachment/14", headers=headers,
253 cainfo="/some/key")
220 self.mocker.result(succeed("some other data"))254 self.mocker.result(succeed("some other data"))
221 self.mocker.replay()255 self.mocker.replay()
222256
@@ -899,7 +933,8 @@
899 headers = {"User-Agent": "landscape-client/%s" % VERSION,933 headers = {"User-Agent": "landscape-client/%s" % VERSION,
900 "Content-Type": "application/octet-stream",934 "Content-Type": "application/octet-stream",
901 "X-Computer-ID": "secure_id"}935 "X-Computer-ID": "secure_id"}
902 mock_fetch("https://localhost/attachment/14", headers=headers)936 mock_fetch("https://localhost/attachment/14", headers=headers,
937 cainfo=None)
903 self.mocker.result(fail(HTTPCodeError(404, "Not found")))938 self.mocker.result(fail(HTTPCodeError(404, "Not found")))
904 self.mocker.replay()939 self.mocker.replay()
905940

Subscribers

People subscribed via source and target branches

to all changes: