[PATCH] Avoid certificate validation on tests

Python 2.7.9 forces https libraries to check if certicate is valid. If not, it will raise an exception. So, a context that unverify the certificate is necessary to run tests. Issue #637: Tests fail with an SSL error on Ubuntu Vivid / Debian Jessie Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com> --- tests/utils.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index 2a8929f..2ffe776 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -22,9 +22,11 @@ import base64 import cherrypy import grp import httplib +import inspect import json import os import socket +import ssl import sys import time import threading @@ -148,7 +150,13 @@ def _request(conn, path, data, method, headers): def request(host, port, path, data=None, method='GET', headers=None): - conn = httplib.HTTPSConnection(host, port) + # verify if HTTPSConnection has context parameter + if "context" in inspect.getargspec(httplib.HTTPSConnection.__init__).args: + context = ssl._create_unverified_context() + conn = httplib.HTTPSConnection(host, port, context=context) + else: + conn = httplib.HTTPSConnection(host, port) + return _request(conn, path, data, method, headers) -- 2.1.0

Reviewed-by: Crístian Deives <cristiandeives@gmail.com> On 14-05-2015 15:01, Ramon Medeiros wrote:
Python 2.7.9 forces https libraries to check if certicate is valid. If not, it will raise an exception. So, a context that unverify the certificate is necessary to run tests.
Issue #637: Tests fail with an SSL error on Ubuntu Vivid / Debian Jessie
Signed-off-by: Ramon Medeiros <ramonn@linux.vnet.ibm.com>
participants (3)
-
Aline Manera
-
Crístian Deives
-
Ramon Medeiros