Skip to content

Commit

Permalink
Issue #112
Browse files Browse the repository at this point in the history
  • Loading branch information
Абашев Алексей committed Nov 4, 2023
1 parent 524cd1f commit 77e561f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public FileName parseUri(
if ((bucket != null) && (bucket.trim().length() > 0)) {
// Has bucket inside URL
if ((region != null) && (region.trim().length() > 0)) {
host = "s3-" + region + ".amazonaws.com";
host = "s3." + region + ".amazonaws.com";
} else {
host = "s3.amazonaws.com";
}
Expand Down
38 changes: 19 additions & 19 deletions src/test/java/com/github/vfss3/S3FileNameParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ public void checkHostedStyleUrl() throws FileSystemException {
hasPathPrefix("bucket").
hasType(FOLDER);

assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(FOLDER);

assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com/some_file")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com/some_file")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(IMAGINARY);

assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com/some file")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com/some file")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(IMAGINARY);

Expand Down Expand Up @@ -78,8 +78,8 @@ public void checkPathStyleUrl() throws FileSystemException {
hasEndpoint("s3.amazonaws.com").
hasPathPrefix("bucket");

assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(FOLDER);

Expand All @@ -88,14 +88,14 @@ public void checkPathStyleUrl() throws FileSystemException {
hasPathPrefix("bucket").
hasType(FOLDER);

assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket/gggg")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket/gggg")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(IMAGINARY).
hasPath("/gggg");

assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket/concurrent/")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket/concurrent/")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(IMAGINARY).
hasPath("/concurrent");
Expand Down Expand Up @@ -133,13 +133,13 @@ public void checkLocalStackUrl() throws FileSystemException {

@Test
public void checkRegionParsing() throws FileSystemException {
assertThat(parse("s3://s3-eu-west-1.amazonaws.com/bucket")).
assertThat(parse("s3://s3.eu-west-1.amazonaws.com/bucket")).
hasSigningRegion("eu-west-1");

assertThat(parse("s3://s3.amazonaws.com/bucket")).
hasSigningRegion("us-east-1");

assertThat(parse("s3://bucket.s3-eu-west-1.amazonaws.com")).
assertThat(parse("s3://bucket.s3.eu-west-1.amazonaws.com")).
hasSigningRegion("eu-west-1");

assertThat(parse("s3://s3-tests.storage.yandexcloud.net")).
Expand All @@ -151,13 +151,13 @@ public void checkRegionParsing() throws FileSystemException {

@Test
public void checkBrokenUrls() throws FileSystemException {
assertThat(parse("s3://s3-eu-west-1.amazonaws.com/s3-tests//big_file.iso")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://s3.eu-west-1.amazonaws.com/s3-tests//big_file.iso")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("s3-tests").
hasPath("/big_file.iso");

assertThat(parse("s3://s3-eu-west-1.amazonaws.com///////s3-tests///////big_file.iso")).
hasEndpoint("s3-eu-west-1.amazonaws.com").
assertThat(parse("s3://s3.eu-west-1.amazonaws.com///////s3-tests///////big_file.iso")).
hasEndpoint("s3.eu-west-1.amazonaws.com").
hasPathPrefix("s3-tests").
hasPath("/big_file.iso");

Expand Down Expand Up @@ -202,7 +202,7 @@ public void checkCredentials() throws FileSystemException {
hasType(FOLDER);

assertThat(parse("s3://access:secret:cn-north-1@bucket.s3.amazonaws.com")).
hasEndpoint("s3-cn-north-1.amazonaws.com").
hasEndpoint("s3.cn-north-1.amazonaws.com").
hasPathPrefix("bucket").
hasType(FOLDER).
hasSigningRegion("cn-north-1");
Expand Down

0 comments on commit 77e561f

Please sign in to comment.