Deal with PEP-0476 certificate chaining checking

PEP-0476 introduced more thorough certificate chain verfication
for HTTPS connectivity; this was introduced in Python 2.7.9, and
breaks a number of unit tests in the manila codebase.

Disable certificate chain verification for SSL tests
using the backwards compatible SSLContext provided for this
purpose.

Change-Id: I512e4bd5a10fcfdf6241329dbd1eae6e9350854b
Closes-Bug: #1403068
This commit is contained in:
James Page 2015-03-19 09:54:09 +00:00
parent 20e590e8b3
commit e687499f43
1 changed files with 15 additions and 2 deletions

View File

@ -17,6 +17,7 @@
"""Unit tests for `manila.wsgi`."""
import os.path
import ssl
import tempfile
import urllib2
@ -145,7 +146,13 @@ class TestWSGIServer(test.TestCase):
server = manila.wsgi.Server("test_app", hello_world)
server.start()
response = urllib2.urlopen('https://127.0.0.1:%d/' % server.port)
if hasattr(ssl, '_create_unverified_context'):
response = urllib2.urlopen(
'https://127.0.0.1:%d/' % server.port,
context=ssl._create_unverified_context())
else:
response = urllib2.urlopen('https://127.0.0.1:%d/' % server.port)
self.assertEqual(greetings, response.read())
server.stop()
@ -172,7 +179,13 @@ class TestWSGIServer(test.TestCase):
port=0)
server.start()
response = urllib2.urlopen('https://[::1]:%d/' % server.port)
if hasattr(ssl, '_create_unverified_context'):
response = urllib2.urlopen(
'https://[::1]:%d/' % server.port,
context=ssl._create_unverified_context())
else:
response = urllib2.urlopen('https://[::1]:%d/' % server.port)
self.assertEqual(greetings, response.read())
server.stop()