-
Notifications
You must be signed in to change notification settings - Fork 1k
Accept and use the new AWS Credentials interfaces #3829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gosar
merged 13 commits into
feature/master/sra-identity-auth
from
gosar/sra-ia-identity-overload-3
Apr 3, 2023
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8ac22a4
Accept and use the new AWS Credentials interfaces
gosar 6c3095b
Update client codegen for endpoint discovery
gosar 2247529
Address some of Matt's feedback
gosar 30635e2
Switch one usage of overrideConfiguration.credentialsProvider
gosar 093be1f
Update tests to mock new IdentityProvider
gosar 0a6bab3
Handle null for CredentialUtils conversion methods
gosar 96bce3a
Add IdentityProvider overload to S3CrtAsyncClientBuilder
gosar 4d372c9
Add a TODO for removing a join() later
gosar 952a4fc
Add TODO for AwsCredentialsProviderChain
gosar 51834e3
Add unit tests and few other minor changes
gosar b2098a6
Remove unnecessary fallback from AuthorizationStrategyFactory
gosar 22370c2
Fix test in S3
gosar c7fb92f
Address PR feedback
gosar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
115 changes: 115 additions & 0 deletions
115
core/auth/src/test/java/software/amazon/awssdk/auth/credentials/CredentialUtilsTest.java
This file contains hidden or 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,115 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| package software.amazon.awssdk.auth.credentials; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; | ||
| import software.amazon.awssdk.identity.spi.AwsSessionCredentialsIdentity; | ||
|
|
||
| public class CredentialUtilsTest { | ||
|
|
||
| @Test | ||
| public void isAnonymous_AwsCredentials_true() { | ||
| assertThat(CredentialUtils.isAnonymous(AwsBasicCredentials.ANONYMOUS_CREDENTIALS)).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void isAnonymous_AwsCredentials_false() { | ||
| assertThat(CredentialUtils.isAnonymous(AwsBasicCredentials.create("akid", "skid"))).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| public void isAnonymous_AwsCredentialsIdentity_true() { | ||
| assertThat(CredentialUtils.isAnonymous((AwsCredentialsIdentity) AwsBasicCredentials.ANONYMOUS_CREDENTIALS)).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void isAnonymous_AwsCredentialsIdentity_false() { | ||
| assertThat(CredentialUtils.isAnonymous((AwsCredentialsIdentity) AwsBasicCredentials.create("akid", "skid"))).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toCredentials_null_returnsNull() { | ||
| assertThat(CredentialUtils.toCredentials(null)).isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toCredentials_AwsSessionCredentialsIdentity_returnsAwsSessionCredentials() { | ||
| AwsCredentials awsCredentials = CredentialUtils.toCredentials(new AwsSessionCredentialsIdentity() { | ||
| @Override | ||
| public String accessKeyId() { | ||
| return "akid"; | ||
| } | ||
|
|
||
| @Override | ||
| public String secretAccessKey() { | ||
| return "skid"; | ||
| } | ||
|
|
||
| @Override | ||
| public String sessionToken() { | ||
| return "session"; | ||
| } | ||
| }); | ||
|
|
||
| assertThat(awsCredentials).isInstanceOf(AwsSessionCredentials.class); | ||
| AwsSessionCredentials awsSessionCredentials = (AwsSessionCredentials) awsCredentials; | ||
| assertThat(awsSessionCredentials.accessKeyId()).isEqualTo("akid"); | ||
| assertThat(awsSessionCredentials.secretAccessKey()).isEqualTo("skid"); | ||
| assertThat(awsSessionCredentials.sessionToken()).isEqualTo("session"); | ||
| } | ||
|
|
||
| @Test | ||
| public void toCredentials_AwsCredentialsIdentity_returnsAwsCredentials() { | ||
| AwsCredentials awsCredentials = CredentialUtils.toCredentials(new AwsCredentialsIdentity() { | ||
| @Override | ||
| public String accessKeyId() { | ||
| return "akid"; | ||
| } | ||
|
|
||
| @Override | ||
| public String secretAccessKey() { | ||
| return "skid"; | ||
| } | ||
| }); | ||
|
|
||
| assertThat(awsCredentials.accessKeyId()).isEqualTo("akid"); | ||
| assertThat(awsCredentials.secretAccessKey()).isEqualTo("skid"); | ||
| } | ||
|
|
||
| @Test | ||
| public void toCredentials_Anonymous_returnsAnonymous() { | ||
| AwsCredentials awsCredentials = CredentialUtils.toCredentials(AwsBasicCredentials.ANONYMOUS_CREDENTIALS); | ||
| assertThat(awsCredentials.accessKeyId()).isNull(); | ||
| assertThat(awsCredentials.secretAccessKey()).isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toCredentialsProvider_null_returnsNull() { | ||
| assertThat(CredentialUtils.toCredentialsProvider(null)).isNull(); | ||
| } | ||
|
|
||
| @Test | ||
| public void toCredentialsProvider_IdentityProvider_converts() { | ||
| AwsCredentialsProvider credentialsProvider = CredentialUtils.toCredentialsProvider( | ||
| StaticCredentialsProvider.create(AwsBasicCredentials.create("akid", "skid"))); | ||
| AwsCredentials credentials = credentialsProvider.resolveCredentials(); | ||
| assertThat(credentials.accessKeyId()).isEqualTo("akid"); | ||
| assertThat(credentials.secretAccessKey()).isEqualTo("skid"); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.