diff --git a/s3tests_boto3/functional/__init__.py b/s3tests_boto3/functional/__init__.py index 9b5abf9..019f407 100644 --- a/s3tests_boto3/functional/__init__.py +++ b/s3tests_boto3/functional/__init__.py @@ -156,6 +156,10 @@ def setup(): config.default_host = defaults.get("host") config.default_port = int(defaults.get("port")) config.default_is_secure = defaults.get("is_secure") + if(config.default_is_secure == True): + config.proto = "https" + else: + config.proto = "http" # vars from the main section config.main_access_key = cfg.get('s3 main',"access_key") @@ -211,7 +215,7 @@ def get_client(client_config=None): if client_config == None: client_config = Config(signature_version='s3v4') - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) client = boto3.client(service_name='s3', aws_access_key_id=config.main_access_key, @@ -224,7 +228,7 @@ def get_client(client_config=None): def get_v2_client(): - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) client = boto3.client(service_name='s3', aws_access_key_id=config.main_access_key, @@ -239,7 +243,7 @@ def get_alt_client(client_config=None): if client_config == None: client_config = Config(signature_version='s3v4') - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) client = boto3.client(service_name='s3', aws_access_key_id=config.alt_access_key, @@ -254,7 +258,7 @@ def get_tenant_client(client_config=None): if client_config == None: client_config = Config(signature_version='s3v4') - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) client = boto3.client(service_name='s3', aws_access_key_id=config.tenant_access_key, @@ -267,7 +271,7 @@ def get_tenant_client(client_config=None): def get_unauthenticated_client(): - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) client = boto3.client(service_name='s3', aws_access_key_id='', @@ -280,7 +284,7 @@ def get_unauthenticated_client(): def get_bad_auth_client(aws_access_key_id='badauth'): - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) client = boto3.client(service_name='s3', aws_access_key_id=aws_access_key_id, @@ -314,7 +318,7 @@ def get_new_bucket_resource(name=None): Always recreates a bucket from scratch. This is useful to also reset ACLs and such. """ - endpoint_url = "http://%s:%d" % (config.default_host, config.default_port) + endpoint_url = "%s://%s:%d" % (config.proto, config.default_host, config.default_port) s3 = boto3.resource('s3', use_ssl=False, @@ -347,6 +351,9 @@ def get_new_bucket(client=None, name=None): def get_config_is_secure(): return config.default_is_secure +def get_config_proto(): + return config.proto + def get_config_host(): return config.default_host