|
40 | 40 | ProvideLastModifiedTimeSubscriber, DirectoryCreatorSubscriber, |
41 | 41 | DeleteSourceObjectSubscriber, DeleteSourceFileSubscriber, |
42 | 42 | DeleteCopySourceObjectSubscriber, NonSeekableStream, CreateDirectoryError, |
43 | | - S3PathResolver, CaseConflictCleanupSubscriber) |
| 43 | + S3PathResolver, CaseConflictCleanupSubscriber, |
| 44 | + is_account_regional_namespace_bucket) |
44 | 45 | from awscli.customizations.s3.results import WarningResult |
45 | 46 | from tests.unit.customizations.s3 import FakeTransferFuture |
46 | 47 | from tests.unit.customizations.s3 import FakeTransferFutureMeta |
@@ -360,6 +361,46 @@ def test_outpost_bucket_arn_with_slash_raises_exception(self): |
360 | 361 | ) |
361 | 362 |
|
362 | 363 |
|
| 364 | +class TestIsAccountRegionalNamespaceBucket(unittest.TestCase): |
| 365 | + def test_matches_standard_pattern(self): |
| 366 | + self.assertTrue( |
| 367 | + is_account_regional_namespace_bucket( |
| 368 | + 'amzn-s3-demo-bucket-111122223333-us-west-2-an' |
| 369 | + ) |
| 370 | + ) |
| 371 | + |
| 372 | + def test_matches_different_region(self): |
| 373 | + self.assertTrue( |
| 374 | + is_account_regional_namespace_bucket( |
| 375 | + 'my-bucket-123456789012-eu-central-1-an' |
| 376 | + ) |
| 377 | + ) |
| 378 | + |
| 379 | + def test_no_match_regular_bucket(self): |
| 380 | + self.assertFalse( |
| 381 | + is_account_regional_namespace_bucket('my-regular-bucket') |
| 382 | + ) |
| 383 | + |
| 384 | + def test_no_match_missing_an_suffix(self): |
| 385 | + self.assertFalse( |
| 386 | + is_account_regional_namespace_bucket( |
| 387 | + 'bucket-111122223333-us-west-2' |
| 388 | + ) |
| 389 | + ) |
| 390 | + |
| 391 | + def test_no_match_wrong_account_id_length(self): |
| 392 | + self.assertFalse( |
| 393 | + is_account_regional_namespace_bucket( |
| 394 | + 'bucket-12345-us-west-2-an' |
| 395 | + ) |
| 396 | + ) |
| 397 | + |
| 398 | + def test_no_match_express_directory_bucket(self): |
| 399 | + self.assertFalse( |
| 400 | + is_account_regional_namespace_bucket('bucket--usw2-az1--x-s3') |
| 401 | + ) |
| 402 | + |
| 403 | + |
363 | 404 | class TestCreateWarning(unittest.TestCase): |
364 | 405 | def test_create_warning(self): |
365 | 406 | path = '/foo/' |
|
0 commit comments