You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2011/03/16 19:11:35 UTC

svn commit: r1082241 - /incubator/libcloud/trunk/test/test_httplib_ssl.py

Author: tomaz
Date: Wed Mar 16 18:11:35 2011
New Revision: 1082241

URL: http://svn.apache.org/viewvc?rev=1082241&view=rev
Log:
Add another test for SSL stuff.

Modified:
    incubator/libcloud/trunk/test/test_httplib_ssl.py

Modified: incubator/libcloud/trunk/test/test_httplib_ssl.py
URL: http://svn.apache.org/viewvc/incubator/libcloud/trunk/test/test_httplib_ssl.py?rev=1082241&r1=1082240&r2=1082241&view=diff
==============================================================================
--- incubator/libcloud/trunk/test/test_httplib_ssl.py (original)
+++ incubator/libcloud/trunk/test/test_httplib_ssl.py Wed Mar 16 18:11:35 2011
@@ -17,6 +17,8 @@ import sys
 import unittest
 import os.path
 
+import mock
+
 import libcloud.security
 from libcloud.httplib_ssl import LibcloudHTTPSConnection
 
@@ -25,8 +27,34 @@ class TestHttpLibSSLTests(unittest.TestC
     def setUp(self):
         self.httplib_object = LibcloudHTTPSConnection('foo.bar')
 
-    def test_connect(self):
-        pass
+    def test_verify_hostname(self):
+        cert1 = {'notAfter': 'Feb 16 16:54:50 2013 GMT',
+         'subject': ((('countryName', 'US'),),
+                     (('stateOrProvinceName', 'Delaware'),),
+                     (('localityName', 'Wilmington'),),
+                     (('organizationName', 'Python Software Foundation'),),
+                     (('organizationalUnitName', 'SSL'),),
+                     (('commonName', 'somemachine.python.org'),))}
+
+        cert2 = {'notAfter': 'Feb 16 16:54:50 2013 GMT',
+         'subject': ((('countryName', 'US'),),
+                     (('stateOrProvinceName', 'Delaware'),),
+                     (('localityName', 'Wilmington'),),
+                     (('organizationName', 'Python Software Foundation'),),
+                     (('organizationalUnitName', 'SSL'),),
+                     (('commonName', 'somemachine.python.org'),)),
+         'subjectAltName': ((('DNS', 'foo.alt.name')),
+                           (('DNS', 'foo.alt.name.1')))}
+
+        self.assertFalse(self.httplib_object._verify_hostname(
+                         hostname='invalid', cert=cert1))
+        self.assertTrue(self.httplib_object._verify_hostname(
+                        hostname='somemachine.python.org', cert=cert1))
+
+        self.assertFalse(self.httplib_object._verify_hostname(
+                         hostname='invalid', cert=cert2))
+        self.assertTrue(self.httplib_object._verify_hostname(
+                        hostname='foo.alt.name.1', cert=cert2))
 
     def test_get_subject_alt_names(self):
         cert1 = {'notAfter': 'Feb 16 16:54:50 2013 GMT',