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

Proposed by dobey on 2012-06-11
Status: Merged
Approved by: Roberto Alsina on 2012-06-11
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) 2012-06-11 Approve on 2012-06-11
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 on 2012-06-11

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

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