forked from TrueCloudLab/frostfs-testcases
Compare commits
1 commit
930176f544
...
52eafc3d70
Author | SHA1 | Date | |
---|---|---|---|
52eafc3d70 |
1 changed files with 65 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import string
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import allure
|
import allure
|
||||||
|
@ -6,8 +7,15 @@ from frostfs_testlib import reporter
|
||||||
from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus
|
from frostfs_testlib.s3 import S3ClientWrapper, VersioningStatus
|
||||||
from frostfs_testlib.steps.s3 import s3_helper
|
from frostfs_testlib.steps.s3 import s3_helper
|
||||||
from frostfs_testlib.storage.dataclasses.object_size import ObjectSize
|
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
|
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.nightly
|
||||||
@pytest.mark.s3_gate
|
@pytest.mark.s3_gate
|
||||||
|
@ -140,3 +148,60 @@ class TestS3GateBucket:
|
||||||
s3_client.delete_bucket(bucket)
|
s3_client.delete_bucket(bucket)
|
||||||
with pytest.raises(Exception, match=r".*Not Found.*"):
|
with pytest.raises(Exception, match=r".*Not Found.*"):
|
||||||
s3_client.head_bucket(bucket)
|
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, 62, 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] Bucket with invalid name length should not be created (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] Bucket with invalid name should not be created (s3_client={s3_client}, bucket_name={bucket_name})")
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"bucket_name",
|
||||||
|
[
|
||||||
|
"BUCKET-1",
|
||||||
|
"buckeT-2",
|
||||||
|
# The following case for AWS CLI is not handled correctly
|
||||||
|
# "-bucket",
|
||||||
|
"bucket-3-",
|
||||||
|
".bucket-4",
|
||||||
|
"bucket-5.",
|
||||||
|
"bucket..6",
|
||||||
|
"bucket+7",
|
||||||
|
"bucket_8",
|
||||||
|
"bucket 9",
|
||||||
|
"127.10.5.10",
|
||||||
|
"xn--bucket-11",
|
||||||
|
"bucket-12-s3alias",
|
||||||
|
# The following names can be used in FrostFS but are prohibited by the AWS specification.
|
||||||
|
# "sthree-bucket-14"
|
||||||
|
# "sthree-configurator-bucket-15"
|
||||||
|
# "amzn-s3-demo-bucket-16"
|
||||||
|
# "sthree-bucket-17"
|
||||||
|
# "bucket-18--ol-s3"
|
||||||
|
# "bucket-19--x-s3"
|
||||||
|
# "bucket-20.mrap"
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_create_bucket_with_invalid_name(self, s3_client: S3ClientWrapper, bucket_name: str):
|
||||||
|
with reporter.step("Create bucket with invalid name and catch exception"):
|
||||||
|
with pytest.raises(Exception, match=".*(?:InvalidBucketName|Invalid bucket name).*"):
|
||||||
|
s3_client.create_bucket(bucket_name)
|
||||||
|
|
Loading…
Reference in a new issue