Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix up insecure behavior for functional tests
At some point, we should probably plumb in a ca_cert option or something.

Change-Id: I3b719be3e2ae5620ad84bd275516f6c8843ceaa4
  • Loading branch information
tipabu committed Jun 11, 2018
1 parent c51e1c6 commit fcd7a05
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/functional/swift_test_client.py
Expand Up @@ -17,6 +17,7 @@
import json
import os
import random
import sys
import socket
import time

Expand Down Expand Up @@ -151,6 +152,16 @@ def authenticate(self, clone_conn=None):
auth_netloc = "%s:%d" % (self.auth_host, self.auth_port)
auth_url = auth_scheme + auth_netloc + auth_path

if self.insecure:
try:
import requests
from requests.packages.urllib3.exceptions import \
InsecureRequestWarning
except ImportError:
pass
else:
requests.packages.urllib3.disable_warnings(
InsecureRequestWarning)
authargs = dict(snet=False, tenant_name=self.account,
auth_version=self.auth_version, os_options={},
insecure=self.insecure)
Expand Down Expand Up @@ -201,7 +212,14 @@ def cluster_info(self):
return json.loads(self.response.read())

def http_connect(self):
self.connection = self.conn_class(self.storage_netloc)
if issubclass(self.conn_class, http_client.HTTPSConnection) and \
self.insecure and sys.version_info >= (2, 7, 9):
import ssl
self.connection = self.conn_class(
self.storage_netloc,
context=ssl._create_unverified_context())
else:
self.connection = self.conn_class(self.storage_netloc)

def make_path(self, path=None, cfg=None):
if path is None:
Expand Down Expand Up @@ -328,7 +346,6 @@ def put_start(self, path, hdrs=None, parms=None, cfg=None, chunked=False):
for (x, y) in parms.items()]
path = '%s?%s' % (path, '&'.join(query_args))

self.connection = self.conn_class(self.storage_netloc)
self.connection.putrequest('PUT', path)
for key, value in headers.items():
self.connection.putheader(key, value)
Expand Down

0 comments on commit fcd7a05

Please sign in to comment.