tests: fix failing HTTPS connection

Recent certificate refactoring probably unclogged some failure
in handling certificates which causes test_changepw to correctly
fail since it is trying to connect using an HTTPS connection
without the CA certificate. This patch adds the CA cert to the
connection.

https://pagure.io/freeipa/issue/4985

Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Stanislav Laznicka
2017-07-03 12:46:51 +02:00
committed by Pavel Vomacka
parent 43c74d3333
commit bf4dae70e0

View File

@@ -22,15 +22,7 @@ Base class for HTTP request tests
from six.moves import urllib
from ipalib import api
# Python 3 rename. The package is available in "six.moves.http_client", but
# pylint cannot handle classes from that alias
try:
import httplib
except ImportError:
# pylint: disable=import-error
import http.client as httplib
from ipalib import api, util
class Unauthorized_HTTP_test(object):
"""
@@ -39,6 +31,7 @@ class Unauthorized_HTTP_test(object):
"""
app_uri = ''
host = api.env.host
cacert = api.env.tls_ca_cert
content_type = 'application/x-www-form-urlencoded'
def send_request(self, method='POST', params=None):
@@ -56,6 +49,7 @@ class Unauthorized_HTTP_test(object):
headers = {'Content-Type' : self.content_type,
'Referer' : url}
conn = httplib.HTTPSConnection(self.host)
conn = util.create_https_connection(
self.host, cafile=self.cacert)
conn.request(method, self.app_uri, params, headers)
return conn.getresponse()