def testGetViaHttpsKeyCert(self):
# At this point I can only test
# that the key and cert files are passed in
# correctly to httplib. It would be nice to have
# a real https endpoint to test against.
# bitworking.org presents an certificate for a non-matching host
# (*.webfaction.com), so we need to disable cert checking for this test.
http = httplib2.Http(timeout=2, disable_ssl_certificate_validation=True)
http.add_certificate("akeyfile", "acertfile", "bitworking.org")
try:
(response, content) = http.request("https://bitworking.org", "GET")
except:
pass
self.assertEqual(http.connections["https:bitworking.org"].key_file, "akeyfile")
self.assertEqual(http.connections["https:bitworking.org"].cert_file, "acertfile")
try:
(response, content) = http.request("https://notthere.bitworking.org", "GET")
except:
pass
self.assertEqual(http.connections["https:notthere.bitworking.org"].key_file, None)
self.assertEqual(http.connections["https:notthere.bitworking.org"].cert_file, None)
评论列表
文章目录