From 5cab1ecf19d82be9e40a1d6a8a9bc1de308a8460 Mon Sep 17 00:00:00 2001 From: Yulia Kovshova Date: Fri, 21 Oct 2022 10:49:25 +0300 Subject: [PATCH] Fix put object with --grant-full-control id=mycanonicaluserid Signed-off-by: Yulia Kovshova --- pytest_tests/steps/aws_cli_client.py | 24 ++++++++++++++++++- .../services/s3_gate/test_s3_bucket.py | 2 +- .../services/s3_gate/test_s3_object.py | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/pytest_tests/steps/aws_cli_client.py b/pytest_tests/steps/aws_cli_client.py index 7c5cc4d..51e77cb 100644 --- a/pytest_tests/steps/aws_cli_client.py +++ b/pytest_tests/steps/aws_cli_client.py @@ -171,7 +171,7 @@ class AwsCliClient: if ObjectLockLegalHoldStatus: cmd += f" --object-lock-legal-hold-status {ObjectLockLegalHoldStatus}" if GrantFullControl: - cmd += f" --grant-full-control {GrantFullControl}" + cmd += f" --grant-full-control '{GrantFullControl}'" if GrantRead: cmd += f" --grant-read {GrantRead}" output = _cmd_run(cmd, LONG_TIMEOUT) @@ -326,6 +326,28 @@ class AwsCliClient: output = _cmd_run(cmd) return self._to_json(output) + def put_object_retention( + self, Bucket: str, Key: str, Retention: dict, VersionId: Optional[str] = None + ) -> dict: + version = f" --version-id {VersionId}" if VersionId else "" + cmd = ( + f"aws {self.common_flags} s3api put-object-retention --bucket {Bucket} --key {Key} " + f"{version} --retention '{json.dumps(Retention, indent=4, sort_keys=True, default=str)}' --endpoint {S3_GATE}" + ) + output = _cmd_run(cmd) + return self._to_json(output) + + def put_object_legal_hold( + self, Bucket: str, Key: str, LegalHold: dict, VersionId: Optional[str] = None + ) -> dict: + version = f" --version-id {VersionId}" if VersionId else "" + cmd = ( + f"aws {self.common_flags} s3api put-object-legal-hold --bucket {Bucket} --key {Key} " + f"{version} --legal-hold '{json.dumps(LegalHold)}' --endpoint {S3_GATE}" + ) + output = _cmd_run(cmd) + return self._to_json(output) + def put_object_tagging(self, Bucket: str, Key: str, Tagging: dict) -> dict: cmd = ( f"aws {self.common_flags} s3api put-object-tagging --bucket {Bucket} --key {Key} " diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py b/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py index 2db9336..fecdd82 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_bucket.py @@ -132,7 +132,7 @@ class TestS3GateBucket(TestS3GateBase): ObjectLockLegalHoldStatus="ON", ) assert_object_lock_mode( - self.s3_client, bucket, file_name, "COMPLIANCE", date_obj_1, "ON" + self.s3_client, bucket_1, file_name, "COMPLIANCE", date_obj_1, "ON" ) @allure.title("Test S3: delete bucket") diff --git a/pytest_tests/testsuites/services/s3_gate/test_s3_object.py b/pytest_tests/testsuites/services/s3_gate/test_s3_object.py index 89402e2..0ae380b 100644 --- a/pytest_tests/testsuites/services/s3_gate/test_s3_object.py +++ b/pytest_tests/testsuites/services/s3_gate/test_s3_object.py @@ -739,7 +739,7 @@ class TestS3GateObject(TestS3GateBase): self.s3_client, bucket, file_path_6, - GrantFullControl=f"'id={self.other_public_key}'", + GrantFullControl=f"id={self.other_public_key}", ) obj_acl = s3_gate_object.get_object_acl_s3(self.s3_client, bucket, file_name_5) obj_permission = [permission.get("Permission") for permission in obj_acl]