From baf36793750efb672cf6b48f60e3e9257404279a Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Mon, 19 Aug 2024 19:40:42 -0400 Subject: [PATCH 1/3] tests: additional fixes due to neofs-s3-gw#976 Signed-off-by: Evgeniy Zayats --- conftest.py | 3 ++- s3tests.conf.SAMPLE | 2 +- s3tests_boto3/functional/test_s3.py | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conftest.py b/conftest.py index cf580f9c8..87b897f67 100644 --- a/conftest.py +++ b/conftest.py @@ -150,7 +150,7 @@ def neofs_setup(request, temp_directory): alt_wallet = create_wallet() - (alt_access_key_id, alt_secret_access_key, alt_wallet_public_key, _) = ( + (alt_access_key_id, alt_secret_access_key, alt_wallet_public_key, alt_wallet_address) = ( init_s3_credentials(alt_wallet, neofs_env) ) @@ -165,6 +165,7 @@ def neofs_setup(request, temp_directory): S3_MAIN_USER_ID=main_wallet_public_key, S3_MAIN_ACCESS_KEY=main_access_key_id, S3_MAIN_SECRET_KEY=main_secret_access_key, + S3_ALT_DISPLAY_NAME=alt_wallet_address, S3_ALT_USER_ID=alt_wallet_public_key, S3_ALT_ACCESS_KEY=alt_access_key_id, S3_ALT_SECRET_KEY=alt_secret_access_key, diff --git a/s3tests.conf.SAMPLE b/s3tests.conf.SAMPLE index 62491480a..b5d38deca 100644 --- a/s3tests.conf.SAMPLE +++ b/s3tests.conf.SAMPLE @@ -43,7 +43,7 @@ secret_key = {{ S3_MAIN_SECRET_KEY }} [s3 alt] # alt display_name set in vstart.sh -display_name = john.doe +display_name = {{ S3_ALT_DISPLAY_NAME }} ## alt email set in vstart.sh email = john.doe@example.com diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 916e79549..08c0839a3 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -5199,7 +5199,7 @@ def add_obj_user_grant(bucket_name, key, grant): grant = { "Grants": grants, - "Owner": {"DisplayName": main_display_name, "ID": main_user_id}, + "Owner": {"DisplayName": main_display_name, "ID": main_display_name}, } return grant @@ -5223,7 +5223,7 @@ def test_object_acl_full_control_verify_attributes(): content_type = response["ContentType"] etag = response["ETag"] - alt_user_id = get_alt_user_id() + alt_user_id = get_alt_display_name() grant = { "Grantee": {"ID": alt_user_id, "Type": "CanonicalUser"}, @@ -5269,7 +5269,7 @@ def add_bucket_user_grant(bucket_name, grant): grant = { "Grants": grants, - "Owner": {"DisplayName": main_display_name, "ID": main_user_id}, + "Owner": {"DisplayName": main_display_name, "ID": main_display_name}, } return grant From 9a49be7e1797da4cd6aef08ce2c0897b514fafba Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Mon, 19 Aug 2024 19:42:05 -0400 Subject: [PATCH 2/3] tests: update status codes validations for negative tests details - https://github.com/nspcc-dev/neofs-s3-gw/issues/899#issuecomment-2173000130 Signed-off-by: Evgeniy Zayats --- s3tests_boto3/functional/test_s3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 08c0839a3..af9e60bb2 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -4289,7 +4289,7 @@ def _test_object_raw_get_x_amz_expires_not_expired(client): ) res = requests.options(url, verify=get_config_ssl_verify()).__dict__ - assert res["status_code"] == 403 + assert res["status_code"] == 400 res = requests.get(url, verify=get_config_ssl_verify()).__dict__ assert res["status_code"] == 200 From 09904a2ca7fcdbaa7e3421331e4d0adab9344bab Mon Sep 17 00:00:00 2001 From: Evgeniy Zayats Date: Mon, 19 Aug 2024 14:48:06 -0400 Subject: [PATCH 3/3] tests: add attachment type to allure attachments It is needed for allure to properly store saved data. Signed-off-by: Evgeniy Zayats --- s3tests_boto3/functional/__init__.py | 46 ++++++++++------------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/s3tests_boto3/functional/__init__.py b/s3tests_boto3/functional/__init__.py index f3503f730..545034e91 100644 --- a/s3tests_boto3/functional/__init__.py +++ b/s3tests_boto3/functional/__init__.py @@ -420,8 +420,7 @@ def get_client(client_config=None): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -436,8 +435,7 @@ def get_v2_client(): verify=config.default_ssl_verify, config=Config(signature_version="s3"), ) - allure.attach("Client V2 created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client V2 Options", allure.attachment_type.TEXT) return client @@ -456,8 +454,7 @@ def get_sts_client(client_config=None): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -494,8 +491,7 @@ def get_iam_client(client_config=None): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -512,8 +508,7 @@ def get_iam_s3client(client_config=None): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -531,8 +526,7 @@ def get_alt_client(client_config=None): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -549,8 +543,7 @@ def get_cloud_client(client_config=None): use_ssl=config.cloud_is_secure, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -568,8 +561,7 @@ def get_tenant_client(client_config=None): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -584,8 +576,7 @@ def get_tenant_iam_client(): verify=config.default_ssl_verify, use_ssl=config.default_is_secure, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -600,8 +591,7 @@ def get_alt_iam_client(): verify=config.default_ssl_verify, use_ssl=config.default_is_secure, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -616,8 +606,7 @@ def get_unauthenticated_client(): verify=config.default_ssl_verify, config=Config(signature_version=UNSIGNED), ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -632,8 +621,7 @@ def get_bad_auth_client(aws_access_key_id="badauth"): verify=config.default_ssl_verify, config=Config(signature_version="s3v4"), ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -651,8 +639,7 @@ def get_svc_client(client_config=None, svc="s3"): verify=config.default_ssl_verify, config=client_config, ) - allure.attach("Client created with the following options:\n"+ - f"{client._client_config._user_provided_options}") + allure.attach(str(client._client_config._user_provided_options), "Client Options", allure.attachment_type.TEXT) return client @@ -672,7 +659,7 @@ def get_new_bucket_name(): prefix=prefix, num=next(bucket_counter), ) - allure.attach(f"Buket name: {name}") + allure.attach(name, "Bucket name", allure.attachment_type.TEXT) return name @@ -941,8 +928,9 @@ def wrapper(*args, **kwargs): with allure.step(f"Request {original_method.__name__}"): response = original_method(*args, **kwargs) allure.attach(str({'args': args, 'kwargs': kwargs}), - name=f'{original_method.__name__} executed with parameters') - allure.attach(str(response)) + f'{original_method.__name__} executed with parameters', + allure.attachment_type.TEXT) + allure.attach(str(response), "Response", allure.attachment_type.TEXT) return response return wrapper