File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
main/java/software/amazon/awssdk/auth/credentials
test/java/software/amazon/awssdk/auth/credentials Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,9 @@ public static AwsCredentialsProvider toCredentialsProvider(
97
97
if (identityProvider == null ) {
98
98
return null ;
99
99
}
100
+ if (identityProvider instanceof AwsCredentialsProvider ) {
101
+ return (AwsCredentialsProvider ) identityProvider ;
102
+ }
100
103
return () -> {
101
104
// TODO: Exception handling for CompletionException thrown from join?
102
105
AwsCredentialsIdentity awsCredentialsIdentity = identityProvider .resolveIdentity ().join ();
Original file line number Diff line number Diff line change 20
20
import org .junit .jupiter .api .Test ;
21
21
import software .amazon .awssdk .identity .spi .AwsCredentialsIdentity ;
22
22
import software .amazon .awssdk .identity .spi .AwsSessionCredentialsIdentity ;
23
+ import software .amazon .awssdk .identity .spi .IdentityProvider ;
23
24
24
25
public class CredentialUtilsTest {
25
26
@@ -83,7 +84,7 @@ public String sessionToken() {
83
84
}
84
85
85
86
@ Test
86
- public void toCredentials_AwsCredentials_doesNotCreateNewObject () {
87
+ public void toCredentials_AwsCredentials_returnsAsIs () {
87
88
AwsCredentialsIdentity input = AwsBasicCredentials .create ("ak" , "sk" );
88
89
AwsCredentials output = CredentialUtils .toCredentials (input );
89
90
assertThat (output ).isSameAs (input );
@@ -130,6 +131,14 @@ public void toCredentialsProvider_null_returnsNull() {
130
131
assertThat (CredentialUtils .toCredentialsProvider (null )).isNull ();
131
132
}
132
133
134
+ @ Test
135
+ public void toCredentialsProvider_AwsCredentialsProvider_returnsAsIs () {
136
+ IdentityProvider <AwsCredentialsIdentity > input =
137
+ StaticCredentialsProvider .create (AwsBasicCredentials .create ("akid" , "skid" ));
138
+ AwsCredentialsProvider output = CredentialUtils .toCredentialsProvider (input );
139
+ assertThat (output ).isSameAs (input );
140
+ }
141
+
133
142
@ Test
134
143
public void toCredentialsProvider_IdentityProvider_converts () {
135
144
AwsCredentialsProvider credentialsProvider = CredentialUtils .toCredentialsProvider (
You can’t perform that action at this time.
0 commit comments