Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiyv-improving committed Jan 11, 2024
1 parent 24cafef commit 0fd5838
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

import java.util.Properties;
import java.util.concurrent.locks.ReentrantLock;
import org.checkerframework.checker.nullness.qual.Nullable;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.jdbc.HostSpec;
import software.amazon.jdbc.PropertyDefinition;
import software.amazon.jdbc.util.Messages;
import software.amazon.jdbc.util.StringUtils;

public class AwsCredentialsManager {
private static AwsCredentialsProviderHandler handler = null;
Expand Down Expand Up @@ -64,7 +66,11 @@ public static AwsCredentialsProvider getProvider(final HostSpec hostSpec, final
}
}

private static AwsCredentialsProvider getDefaultProvider() {
return DefaultCredentialsProvider.create();
private static AwsCredentialsProvider getDefaultProvider(final @Nullable String awsProfileName) {
DefaultCredentialsProvider.Builder builder = DefaultCredentialsProvider.builder();
if (!StringUtils.isNullOrEmpty(awsProfileName)) {
builder.profileName(awsProfileName);
}
return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ public void testAwsCredentialsManager() {
@Test
public void testNullProvider() {
AwsCredentialsManager.setCustomHandler(((hostSpec, props) -> null));
assertThrows(IllegalArgumentException.class,
() -> AwsCredentialsManager.getProvider(mockHostSpec, mockProps));
assertTrue(AwsCredentialsManager.getProvider(mockHostSpec, mockProps) instanceof DefaultCredentialsProvider);
}
}

0 comments on commit 0fd5838

Please sign in to comment.