[Kimchi-devel] [PATCH] Avoid certificate validation on tests

Ramon Medeiros ramonn at linux.vnet.ibm.com
Thu May 14 18:01:11 UTC 2015


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 at 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




More information about the Kimchi-devel mailing list