mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 13:47:27 +00:00
commit
5be61bc30a
2 changed files with 20 additions and 47 deletions
|
@ -155,7 +155,10 @@ def setup():
|
||||||
# vars from the DEFAULT section
|
# vars from the DEFAULT section
|
||||||
config.default_host = defaults.get("host")
|
config.default_host = defaults.get("host")
|
||||||
config.default_port = int(defaults.get("port"))
|
config.default_port = int(defaults.get("port"))
|
||||||
config.default_is_secure = defaults.get("is_secure")
|
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
|
# vars from the main section
|
||||||
config.main_access_key = cfg.get('s3 main',"access_key")
|
config.main_access_key = cfg.get('s3 main',"access_key")
|
||||||
|
@ -211,27 +214,20 @@ def get_client(client_config=None):
|
||||||
if client_config == None:
|
if client_config == None:
|
||||||
client_config = Config(signature_version='s3v4')
|
client_config = Config(signature_version='s3v4')
|
||||||
|
|
||||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
|
||||||
|
|
||||||
client = boto3.client(service_name='s3',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id=config.main_access_key,
|
aws_access_key_id=config.main_access_key,
|
||||||
aws_secret_access_key=config.main_secret_key,
|
aws_secret_access_key=config.main_secret_key,
|
||||||
endpoint_url=endpoint_url,
|
endpoint_url=config.default_endpoint,
|
||||||
use_ssl=config.default_is_secure,
|
use_ssl=config.default_is_secure,
|
||||||
verify=False,
|
|
||||||
config=client_config)
|
config=client_config)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
def get_v2_client():
|
def get_v2_client():
|
||||||
|
|
||||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
|
||||||
|
|
||||||
client = boto3.client(service_name='s3',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id=config.main_access_key,
|
aws_access_key_id=config.main_access_key,
|
||||||
aws_secret_access_key=config.main_secret_key,
|
aws_secret_access_key=config.main_secret_key,
|
||||||
endpoint_url=endpoint_url,
|
endpoint_url=config.default_endpoint,
|
||||||
use_ssl=config.default_is_secure,
|
use_ssl=config.default_is_secure,
|
||||||
verify=False,
|
|
||||||
config=Config(signature_version='s3'))
|
config=Config(signature_version='s3'))
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
@ -239,14 +235,11 @@ def get_alt_client(client_config=None):
|
||||||
if client_config == None:
|
if client_config == None:
|
||||||
client_config = Config(signature_version='s3v4')
|
client_config = Config(signature_version='s3v4')
|
||||||
|
|
||||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
|
||||||
|
|
||||||
client = boto3.client(service_name='s3',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id=config.alt_access_key,
|
aws_access_key_id=config.alt_access_key,
|
||||||
aws_secret_access_key=config.alt_secret_key,
|
aws_secret_access_key=config.alt_secret_key,
|
||||||
endpoint_url=endpoint_url,
|
endpoint_url=config.default_endpoint,
|
||||||
use_ssl=config.default_is_secure,
|
use_ssl=config.default_is_secure,
|
||||||
verify=False,
|
|
||||||
config=client_config)
|
config=client_config)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
@ -254,40 +247,29 @@ def get_tenant_client(client_config=None):
|
||||||
if client_config == None:
|
if client_config == None:
|
||||||
client_config = Config(signature_version='s3v4')
|
client_config = Config(signature_version='s3v4')
|
||||||
|
|
||||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
|
||||||
|
|
||||||
client = boto3.client(service_name='s3',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id=config.tenant_access_key,
|
aws_access_key_id=config.tenant_access_key,
|
||||||
aws_secret_access_key=config.tenant_secret_key,
|
aws_secret_access_key=config.tenant_secret_key,
|
||||||
endpoint_url=endpoint_url,
|
endpoint_url=config.default_endpoint,
|
||||||
use_ssl=config.default_is_secure,
|
use_ssl=config.default_is_secure,
|
||||||
verify=False,
|
|
||||||
config=client_config)
|
config=client_config)
|
||||||
return client
|
return client
|
||||||
|
|
||||||
def get_unauthenticated_client():
|
def get_unauthenticated_client():
|
||||||
|
|
||||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
|
||||||
|
|
||||||
client = boto3.client(service_name='s3',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id='',
|
aws_access_key_id='',
|
||||||
aws_secret_access_key='',
|
aws_secret_access_key='',
|
||||||
endpoint_url=endpoint_url,
|
endpoint_url=config.default_endpoint,
|
||||||
use_ssl=config.default_is_secure,
|
use_ssl=config.default_is_secure,
|
||||||
verify=False,
|
|
||||||
config=Config(signature_version=UNSIGNED))
|
config=Config(signature_version=UNSIGNED))
|
||||||
return client
|
return client
|
||||||
|
|
||||||
def get_bad_auth_client(aws_access_key_id='badauth'):
|
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',
|
client = boto3.client(service_name='s3',
|
||||||
aws_access_key_id=aws_access_key_id,
|
aws_access_key_id=aws_access_key_id,
|
||||||
aws_secret_access_key='roflmao',
|
aws_secret_access_key='roflmao',
|
||||||
endpoint_url=endpoint_url,
|
endpoint_url=config.default_endpoint,
|
||||||
use_ssl=config.default_is_secure,
|
use_ssl=config.default_is_secure,
|
||||||
verify=False,
|
|
||||||
config=Config(signature_version='s3v4'))
|
config=Config(signature_version='s3v4'))
|
||||||
return client
|
return client
|
||||||
|
|
||||||
|
@ -314,14 +296,11 @@ def get_new_bucket_resource(name=None):
|
||||||
Always recreates a bucket from scratch. This is useful to also
|
Always recreates a bucket from scratch. This is useful to also
|
||||||
reset ACLs and such.
|
reset ACLs and such.
|
||||||
"""
|
"""
|
||||||
endpoint_url = "http://%s:%d" % (config.default_host, config.default_port)
|
|
||||||
|
|
||||||
s3 = boto3.resource('s3',
|
s3 = boto3.resource('s3',
|
||||||
use_ssl=False,
|
|
||||||
verify=False,
|
|
||||||
endpoint_url=endpoint_url,
|
|
||||||
aws_access_key_id=config.main_access_key,
|
aws_access_key_id=config.main_access_key,
|
||||||
aws_secret_access_key=config.main_secret_key)
|
aws_secret_access_key=config.main_secret_key,
|
||||||
|
endpoint_url=config.default_endpoint,
|
||||||
|
use_ssl=config.default_is_secure)
|
||||||
if name is None:
|
if name is None:
|
||||||
name = get_new_bucket_name()
|
name = get_new_bucket_name()
|
||||||
bucket = s3.Bucket(name)
|
bucket = s3.Bucket(name)
|
||||||
|
@ -353,6 +332,9 @@ def get_config_host():
|
||||||
def get_config_port():
|
def get_config_port():
|
||||||
return config.default_port
|
return config.default_port
|
||||||
|
|
||||||
|
def get_config_endpoint():
|
||||||
|
return config.default_endpoint
|
||||||
|
|
||||||
def get_main_aws_access_key():
|
def get_main_aws_access_key():
|
||||||
return config.main_access_key
|
return config.main_access_key
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ from . import (
|
||||||
get_config_is_secure,
|
get_config_is_secure,
|
||||||
get_config_host,
|
get_config_host,
|
||||||
get_config_port,
|
get_config_port,
|
||||||
|
get_config_endpoint,
|
||||||
get_main_aws_access_key,
|
get_main_aws_access_key,
|
||||||
get_main_aws_secret_key,
|
get_main_aws_secret_key,
|
||||||
get_main_display_name,
|
get_main_display_name,
|
||||||
|
@ -1360,18 +1361,8 @@ def test_object_write_file():
|
||||||
eq(body, 'bar')
|
eq(body, 'bar')
|
||||||
|
|
||||||
def _get_post_url(bucket_name):
|
def _get_post_url(bucket_name):
|
||||||
protocol='http'
|
endpoint = get_config_endpoint()
|
||||||
is_secure = get_config_is_secure()
|
return '{endpoint}/{bucket_name}'.format(endpoint=endpoint, bucket_name=bucket_name)
|
||||||
|
|
||||||
if is_secure is True:
|
|
||||||
protocol='https'
|
|
||||||
|
|
||||||
host = get_config_host()
|
|
||||||
port = get_config_port()
|
|
||||||
|
|
||||||
url = '{protocol}://{host}:{port}/{bucket_name}'.format(protocol=protocol,\
|
|
||||||
host=host, port=port, bucket_name=bucket_name)
|
|
||||||
return url
|
|
||||||
|
|
||||||
@attr(resource='object')
|
@attr(resource='object')
|
||||||
@attr(method='post')
|
@attr(method='post')
|
||||||
|
@ -6189,7 +6180,7 @@ def _simple_http_req_100_cont(host, port, is_secure, method, resource):
|
||||||
)
|
)
|
||||||
|
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
if(is_secure == True):
|
if is_secure:
|
||||||
s = ssl.wrap_socket(s);
|
s = ssl.wrap_socket(s);
|
||||||
s.settimeout(5)
|
s.settimeout(5)
|
||||||
s.connect((host, port))
|
s.connect((host, port))
|
||||||
|
|
Loading…
Reference in a new issue