[#310] Extend bucket testsuite
Some checks failed
DCO check / Commits Check (pull_request) Has been cancelled
Some checks failed
DCO check / Commits Check (pull_request) Has been cancelled
- Added tests to check the correctness of bucket names according to the AWS specification Signed-off-by: Kirill Sosnovskikh <k.sosnovskikh@yadro.com>
This commit is contained in:
parent
64bc778116
commit
66d59d8e3e
1 changed files with 56 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import string
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import allure
|
||||
|
@ -6,8 +7,15 @@ from frostfs_testlib import reporter
|
|||
from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus
|
||||
from frostfs_testlib.steps.s3 import s3_helper
|
||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
||||
from frostfs_testlib.utils import string_utils
|
||||
from frostfs_testlib.utils.file_utils import generate_file
|
||||
|
||||
VALID_SYMBOLS_WITHOUT_DOT = string.ascii_lowercase + string.digits + "-"
|
||||
VALID_AND_INVALID_SYMBOLS = string.ascii_letters + string.punctuation
|
||||
|
||||
# TODO: The dot symbol is temporarily not supported.
|
||||
VALID_SYMBOLS_WITH_DOT = VALID_SYMBOLS_WITHOUT_DOT + "."
|
||||
|
||||
|
||||
@pytest.mark.nightly
|
||||
@pytest.mark.s3_gate
|
||||
|
@ -140,3 +148,51 @@ class TestS3GateBucket:
|
|||
s3_client.delete_bucket(bucket)
|
||||
with pytest.raises(Exception, match=r".*Not Found.*"):
|
||||
s3_client.head_bucket(bucket)
|
||||
|
||||
@allure.title("Create bucket with valid name length (s3_client={s3_client} length={length})")
|
||||
@pytest.mark.parametrize("length", [3, 4, 32, 63])
|
||||
def test_create_bucket_with_valid_length(self, s3_client: S3ClientWrapper, length: int):
|
||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||
while not (bucket_name[0].isalnum() and bucket_name[-1].isalnum()):
|
||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||
|
||||
with reporter.step("Create bucket with valid name length"):
|
||||
s3_client.create_bucket(bucket_name)
|
||||
|
||||
with reporter.step("Check bucket name in buckets"):
|
||||
assert bucket_name in s3_client.list_buckets()
|
||||
|
||||
@allure.title("[NEGATIVE] Create bucket with invalid name length (s3_client={s3_client} length={length})")
|
||||
@pytest.mark.parametrize("length", [2, 64, 254, 255, 256])
|
||||
def test_create_bucket_with_invalid_length(self, s3_client: S3ClientWrapper, length: int):
|
||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||
while not (bucket_name[0].isalnum() and bucket_name[-1].isalnum()):
|
||||
bucket_name = string_utils.random_string(length, VALID_SYMBOLS_WITHOUT_DOT)
|
||||
|
||||
with reporter.step("Create bucket with invalid name length and catch exception"):
|
||||
with pytest.raises(Exception, match=".*(?:InvalidBucketName|Invalid bucket name).*"):
|
||||
s3_client.create_bucket(bucket_name)
|
||||
|
||||
@allure.title("[NEGATIVE] Create bucket with invalid name (s3_client={s3_client}, prefix={prefix}, postfix={postfix})")
|
||||
@pytest.mark.parametrize(
|
||||
"prefix, postfix",
|
||||
[
|
||||
["BUCKET-", "-1"],
|
||||
["buckeT-", "-2"],
|
||||
["-bucket-", "-3"],
|
||||
["-bucket-", "5-"],
|
||||
[".bucket-", "-6"],
|
||||
["bucket-", "-7."],
|
||||
["bucket..", "-8"],
|
||||
["bucket+", "-9"],
|
||||
["bucket_", "-10"],
|
||||
["127.10.5.11", None],
|
||||
["xn--bucket-", "-12"],
|
||||
["bucket-13-", "-s3alias"],
|
||||
],
|
||||
)
|
||||
def test_create_bucket_with_invalid_name(self, s3_client: S3ClientWrapper, prefix: str, postfix: str | None):
|
||||
bucket_name = prefix if postfix is None else string_utils.unique_name(prefix, postfix)
|
||||
with reporter.step("Create bucket with invalid name and catch exception"):
|
||||
with pytest.raises(Exception, match=".*(?:InvalidBucketName|Invalid bucket name|argument --bucket: expected one argument).*"):
|
||||
s3_client.create_bucket(bucket_name)
|
||||
|
|
Loading…
Reference in a new issue