forked from awslabs/aws-java-nio-spi-for-s3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
53 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,59 +40,36 @@ public void init() { | |
|
||
@Test | ||
public void clientWithProvidedEndpoint() throws Exception { | ||
final String URI1 = "s3://endpoint1.io/bucket/resource"; | ||
final String URI2 = "s3://endpoint2.io:8080/bucket/resource"; | ||
final String URI1 = "s3://endpoint2.io:8080/bucket/resource"; | ||
|
||
// | ||
// For non AWS S3 buckets, backet's region is not discovered runtime and it | ||
// must be provided in the AWS profile | ||
// For non AWS S3 buckets, backet's region is not discovered runtime and | ||
// it must be provided in the AWS profile | ||
// | ||
S3FileSystem fs = new S3FileSystem(URI.create(URI1), provider, new S3NioSpiConfiguration(CONFIG)); | ||
fs.clientProvider.asyncClientBuilder = BUILDER; | ||
|
||
S3AsyncClient client = fs.client(); | ||
assertEquals(URI.create("https://endpoint1.io"), BUILDER.endpointOverride); | ||
assertNull(BUILDER.credentialsProvider); | ||
|
||
fs = new S3FileSystem(URI.create(URI2), provider); | ||
fs.clientProvider.asyncClientBuilder = BUILDER; | ||
|
||
fs.client(); | ||
assertEquals(URI.create("https://endpoint2.io:8080"), BUILDER.endpointOverride); | ||
assertNull(BUILDER.credentialsProvider); | ||
} | ||
|
||
@Test | ||
public void clientWithProvidedEndpointAndCredentials() throws Exception { | ||
final String URI1 = "s3://key1:[email protected]/bucket/resource"; | ||
final String URI2 = "s3://key2:[email protected]:8080/bucket/resource"; | ||
|
||
restoreSystemProperties(() -> { | ||
System.setProperty("aws.region", "aws-east-1"); | ||
|
||
S3FileSystem fs = new S3FileSystem(URI.create(URI1), provider); | ||
fs.clientProvider.asyncClientBuilder = BUILDER; | ||
|
||
// | ||
// For non AWS S3 buckets, backet's region is not discovered runtime and it | ||
// must be provided in the AWS profile | ||
// | ||
S3AsyncClient client = fs.client(); | ||
final String URI1 = "s3://key2:[email protected]:8080/bucket/resource"; | ||
|
||
assertEquals(URI.create("https://endpoint1.io"), BUILDER.endpointOverride); | ||
assertNotNull(BUILDER.credentialsProvider); | ||
assertEquals("key1", BUILDER.credentialsProvider.resolveCredentials().accessKeyId()); | ||
assertEquals("secret1", BUILDER.credentialsProvider.resolveCredentials().secretAccessKey()); | ||
|
||
fs = new S3FileSystem(URI.create(URI2), provider); | ||
fs.clientProvider.asyncClientBuilder = BUILDER; | ||
// | ||
// For non AWS S3 buckets, backet's region is not discovered runtime | ||
// and it must be provided in the AWS profile | ||
// | ||
S3FileSystem fs = new S3FileSystem(URI.create(URI1), provider, new S3NioSpiConfiguration(CONFIG)); | ||
fs.clientProvider.asyncClientBuilder = BUILDER; | ||
|
||
fs.client(); | ||
assertEquals(URI.create("https://endpoint2.io:8080"), BUILDER.endpointOverride); | ||
assertNotNull(BUILDER.credentialsProvider); | ||
assertEquals("key2", BUILDER.credentialsProvider.resolveCredentials().accessKeyId()); | ||
assertEquals("secret2", BUILDER.credentialsProvider.resolveCredentials().secretAccessKey()); | ||
}); | ||
fs.client(); | ||
assertEquals(URI.create("https://endpoint2.io:8080"), BUILDER.endpointOverride); | ||
assertNotNull(BUILDER.credentialsProvider); | ||
assertEquals("key2", BUILDER.credentialsProvider.resolveCredentials().accessKeyId()); | ||
assertEquals("secret2", BUILDER.credentialsProvider.resolveCredentials().secretAccessKey()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,10 +238,11 @@ public void getFileSystem() { | |
URI.create("s3://key:[email protected]:2000/foo2/baa2") | ||
}; | ||
|
||
assertThrows(FileSystemNotFoundException.class, () -> { | ||
provider.getFileSystem(URI.create("s3://nowhere.com:2000/foo2/baa2")); | ||
fail("wrong file system!"); | ||
}); | ||
assertThrows( | ||
FileSystemNotFoundException.class, () -> { | ||
provider.getFileSystem(URI.create("s3://nowhere.com:2000/foo2/baa2")); | ||
} | ||
); | ||
} | ||
|
||
@Test | ||
|