Merge lp:~dobey/ubuntuone-storage-protocol/fix-context-test into lp:ubuntuone-storage-protocol

Proposed by dobey
Status: Merged
Approved by: Roberto Alsina
Approved revision: 150
Merged at revision: 149
Proposed branch: lp:~dobey/ubuntuone-storage-protocol/fix-context-test
Merge into: lp:ubuntuone-storage-protocol
Diff against target: 25 lines (+15/-0)
1 file modified
tests/test_context.py (+15/-0)
To merge this branch: bzr merge lp:~dobey/ubuntuone-storage-protocol/fix-context-test
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Review via email: mp+109687@code.launchpad.net

Commit message

Patch get_certificates to use the uninstalled certificates when testing

Description of the change

To test this locally, you'll have to apt-get remove --purge python-ubuntuone-storageprotocol (so that the certs are not installed in the system location). Without this branch, the trunk tests will fail on test_fails_certificate.

To post a comment you must log in.
150. By dobey

Actually, let's just do this for all the tests, and not just one

Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_context.py'
2--- tests/test_context.py 2012-06-08 14:05:42 +0000
3+++ tests/test_context.py 2012-06-11 17:29:17 +0000
4@@ -117,6 +117,21 @@
5 """Tests for the context.get_ssl_context function."""
6
7 @defer.inlineCallbacks
8+ def setUp(self):
9+ yield super(SSLContextTestCase, self).setUp()
10+ self.patch(context, "get_certificates", self.get_certificates)
11+
12+ def get_certificates(self):
13+ """Get the uninstalled certificates, for testing."""
14+ ca_1 = ssl.Certificate.loadPEM(file(os.path.abspath(os.path.join(
15+ os.pardir, os.pardir, 'data',
16+ 'UbuntuOne-Go_Daddy_Class_2_CA.pem')), 'r').read())
17+ ca_2 = ssl.Certificate.loadPEM(file(os.path.abspath(os.path.join(
18+ os.pardir, os.pardir, 'data',
19+ 'UbuntuOne-Go_Daddy_CA.pem')), 'r').read())
20+ return [ca_1.original, ca_2.original]
21+
22+ @defer.inlineCallbacks
23 def verify_context(self, server_context, client_context):
24 """Verify a client context with a given server context."""
25 site = server.Site(FakeResource())

Subscribers

People subscribed via source and target branches