Skip to content

Commit

Permalink
Experiment: Allow bucket names ending with -s3alias / starting with…
Browse files Browse the repository at this point in the history
… `xn--` (#51)
  • Loading branch information
Drvi authored Jul 16, 2024
1 parent 8671f8a commit 9ffe097
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CloudStore"
uuid = "3365d9ee-d53b-4a56-812d-5344d5b716d7"
authors = ["quinnj <quinn.jacobd@gmail.com>"]
version = "1.6.3"
version = "1.6.4"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
2 changes: 0 additions & 2 deletions src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const AWS_REGIONS = Set{String}([
function validate_bucket_name(bucket_name, accelerate)
!(3 <= ncodeunits(bucket_name) <= 63) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must be between 3 (min) and 63 (max) characters long."))
occursin("..", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not contain two adjacent periods."))
startswith(bucket_name, "xn--") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not start with the prefix `xn--`."))
endswith(bucket_name, "-s3alias") && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names must not end with the suffix `-s3alias`."))
accelerate && occursin(".", bucket_name) && throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Buckets used with Amazon S3 Transfer Acceleration can't have dots (.) in their names."))
!contains(bucket_name, r"^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$") &&
throw(ArgumentError("Validation failed for `bucket` name $(repr(bucket_name)): Bucket names can consist only of lowercase letters, numbers, dots (.), and hyphens (-). Bucket names must begin and end with a letter or number."))
Expand Down
13 changes: 5 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,6 @@ end
@test_throws ArgumentError parse_s3_url(bucket="a"^64, accelerate=false)
@test_throws ArgumentError CloudStore.validate_bucket_name("a..b", false)
@test !parse_s3_url(bucket="a..b", accelerate=false)[1]
@test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", false)
@test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=false)
@test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", false)
@test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=false)
@test_throws ArgumentError CloudStore.validate_bucket_name("abcA", false)
@test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=false)
@test_throws ArgumentError CloudStore.validate_bucket_name("abc-", false)
Expand All @@ -909,10 +905,6 @@ end
@test_throws ArgumentError parse_s3_url(bucket="a"^64, accelerate=true)
@test_throws ArgumentError CloudStore.validate_bucket_name("a..b", true)
@test !parse_s3_url(bucket="a..b", accelerate=true)[1]
@test_throws ArgumentError CloudStore.validate_bucket_name("xn--abc", true)
@test_throws ArgumentError parse_s3_url(bucket="xn--abc", accelerate=true)
@test_throws ArgumentError CloudStore.validate_bucket_name("abcs-s3alias", true)
@test_throws ArgumentError parse_s3_url(bucket="abcs-s3alias", accelerate=true)
@test_throws ArgumentError CloudStore.validate_bucket_name("abcA", true)
@test_throws ArgumentError parse_s3_url(bucket="abcA", accelerate=true)
@test_throws ArgumentError CloudStore.validate_bucket_name("abc-", true)
Expand All @@ -927,6 +919,11 @@ end
@test CloudStore.validate_bucket_name("a.b-c1", false) == "a.b-c1"
@test CloudStore.validate_bucket_name("a"^63, false) == "a"^63
@test CloudStore.validate_bucket_name("a"^3, false) == "a"^3
# xn-- prefix and -s3alias suffix are apparently illegal in bucket names create by
# the user but can be received from AWS, see e.g.
# https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-points-alias.html
@test CloudStore.validate_bucket_name("xn--a", false) == "xn--a"
@test CloudStore.validate_bucket_name("a-s3alias", false) == "a-s3alias"

@test_throws ArgumentError("Validation failed for `region` \"xx-xxxx-x\"") CloudStore.parseAWSBucketRegionKey("https://bucket.vpce-1a2b3c4d-5e6f.s3.xx-xxxx-x.vpce.amazonaws.com/bucket-name")
@test_throws ArgumentError("Validation failed for `bucket` name \"bn\": Bucket names must be between 3 (min) and 63 (max) characters long.") CloudStore.parseAWSBucketRegionKey("https://bucket.vpce-1a2b3c4d-5e6f.s3.us-west-2.vpce.amazonaws.com/bn")
Expand Down

2 comments on commit 9ffe097

@Drvi
Copy link
Member Author

@Drvi Drvi commented on 9ffe097 Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/111150

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.4 -m "<description of version>" 9ffe09705c4e67b3e8a6ddd7184ebce4685394c8
git push origin v1.6.4

Please sign in to comment.