-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: iamAsyncClient without endpointOverride (#492)
- Loading branch information
1 parent
8566aec
commit 0f4cf76
Showing
2 changed files
with
81 additions
and
1 deletion.
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
77 changes: 77 additions & 0 deletions
77
...ommon/aws/aws-s3-core/src/test/java/org/eclipse/edc/aws/s3/AwsClientProviderImplTest.java
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright (c) 2024 Cofinity-X | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Cofinity-X - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.aws.s3; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; | ||
|
||
import java.net.URI; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class AwsClientProviderImplTest { | ||
|
||
private AwsClientProvider clientProvider; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
var config = AwsClientProviderConfiguration.Builder.newInstance() | ||
.credentialsProvider(DefaultCredentialsProvider.create()) | ||
.build(); | ||
clientProvider = new AwsClientProviderImpl(config); | ||
} | ||
|
||
@Test | ||
void iamAsyncClient_noEndpointOverride_shouldReturnClient() { | ||
var clientRequest = S3ClientRequest.from("region", null); | ||
|
||
var client = clientProvider.iamAsyncClient(clientRequest); | ||
|
||
assertThat(client).isNotNull(); | ||
assertThat(client.serviceClientConfiguration().endpointOverride()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void iamAsyncClient_requestMultipleTimesNoEndpointOverride_shouldReturnSameClient() { | ||
var clientRequest = S3ClientRequest.from("region", null); | ||
|
||
var client1 = clientProvider.iamAsyncClient(clientRequest); | ||
var client2 = clientProvider.iamAsyncClient(clientRequest); | ||
|
||
assertThat(client1).isSameAs(client2); | ||
} | ||
|
||
@Test | ||
void iamAsyncClient_withEndpointOverride_shouldReturnClient() { | ||
var endpointOverride = "https://endpointOverride"; | ||
var clientRequest = S3ClientRequest.from("region", endpointOverride); | ||
|
||
var client = clientProvider.iamAsyncClient(clientRequest); | ||
|
||
assertThat(client).isNotNull(); | ||
assertThat(client.serviceClientConfiguration().endpointOverride()).contains(URI.create(endpointOverride)); | ||
} | ||
|
||
@Test | ||
void iamAsyncClient_requestMultipleTimesWithEndpointOverride_shouldReturnSameClient() { | ||
var clientRequest = S3ClientRequest.from("region", "https://endpointOverride"); | ||
|
||
var client1 = clientProvider.iamAsyncClient(clientRequest); | ||
var client2 = clientProvider.iamAsyncClient(clientRequest); | ||
|
||
assertThat(client1).isSameAs(client2); | ||
} | ||
} |