mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 13:47:27 +00:00
boto3: use https:// for secure endpoints
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit ac18365f75
)
This commit is contained in:
parent
bce59979ca
commit
b1d6dc927c
1 changed files with 10 additions and 24 deletions
|
@ -157,6 +157,9 @@ def setup():
|
|||
config.default_port = int(defaults.get("port"))
|
||||
config.default_is_secure = cfg.getboolean('DEFAULT', "is_secure")
|
||||
|
||||
proto = 'https' if config.default_is_secure else 'http'
|
||||
config.default_endpoint = "%s://%s:%d" % (proto, config.default_host, config.default_port)
|
||||
|
||||
# vars from the main section
|
||||
config.main_access_key = cfg.get('s3 main',"access_key")
|
||||
config.main_secret_key = cfg.get('s3 main',"secret_key")
|
||||
|
@ -211,25 +214,20 @@ 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)
|
||||
|
||||
client = boto3.client(service_name='s3',
|
||||
aws_access_key_id=config.main_access_key,
|
||||
aws_secret_access_key=config.main_secret_key,
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
use_ssl=config.default_is_secure,
|
||||
verify=False,
|
||||
config=client_config)
|
||||
return client
|
||||
|
||||
def get_v2_client():
|
||||
|
||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
||||
|
||||
client = boto3.client(service_name='s3',
|
||||
aws_access_key_id=config.main_access_key,
|
||||
aws_secret_access_key=config.main_secret_key,
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
use_ssl=config.default_is_secure,
|
||||
verify=False,
|
||||
config=Config(signature_version='s3'))
|
||||
|
@ -239,12 +237,10 @@ 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)
|
||||
|
||||
client = boto3.client(service_name='s3',
|
||||
aws_access_key_id=config.alt_access_key,
|
||||
aws_secret_access_key=config.alt_secret_key,
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
use_ssl=config.default_is_secure,
|
||||
verify=False,
|
||||
config=client_config)
|
||||
|
@ -254,38 +250,30 @@ 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)
|
||||
|
||||
client = boto3.client(service_name='s3',
|
||||
aws_access_key_id=config.tenant_access_key,
|
||||
aws_secret_access_key=config.tenant_secret_key,
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
use_ssl=config.default_is_secure,
|
||||
verify=False,
|
||||
config=client_config)
|
||||
return client
|
||||
|
||||
def get_unauthenticated_client():
|
||||
|
||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
||||
|
||||
client = boto3.client(service_name='s3',
|
||||
aws_access_key_id='',
|
||||
aws_secret_access_key='',
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
use_ssl=config.default_is_secure,
|
||||
verify=False,
|
||||
config=Config(signature_version=UNSIGNED))
|
||||
return client
|
||||
|
||||
def get_bad_auth_client(aws_access_key_id='badauth'):
|
||||
|
||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
||||
|
||||
client = boto3.client(service_name='s3',
|
||||
aws_access_key_id=aws_access_key_id,
|
||||
aws_secret_access_key='roflmao',
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
use_ssl=config.default_is_secure,
|
||||
verify=False,
|
||||
config=Config(signature_version='s3v4'))
|
||||
|
@ -314,12 +302,10 @@ 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)
|
||||
|
||||
s3 = boto3.resource('s3',
|
||||
use_ssl=False,
|
||||
verify=False,
|
||||
endpoint_url=endpoint_url,
|
||||
endpoint_url=config.default_endpoint,
|
||||
aws_access_key_id=config.main_access_key,
|
||||
aws_secret_access_key=config.main_secret_key)
|
||||
if name is None:
|
||||
|
|
Loading…
Reference in a new issue