Skip to content

Commit 1c572bf

Browse files
authored
refactor: allow tests to run with IAM users without MFA (#9)
1 parent 16d8ae5 commit 1c572bf

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

wrapper/src/test/java/integration/host/AuroraPostgresContainerTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public class AuroraPostgresContainerTest {
103103
static void setUp() throws SQLException, InterruptedException, UnknownHostException {
104104
Assertions.assertNotNull(AWS_ACCESS_KEY_ID);
105105
Assertions.assertNotNull(AWS_SECRET_ACCESS_KEY);
106-
Assertions.assertNotNull(AWS_SESSION_TOKEN);
107106

108107
if (TEST_WITH_EXISTING_DB) {
109108
dbConnStrSuffix = EXISTING_DB_CONN_SUFFIX;
@@ -212,7 +211,7 @@ public void debugPerformanceTestInContainer()
212211
protected static GenericContainer<?> initializeTestContainer(
213212
final Network network, List<String> postgresInstances) {
214213

215-
final GenericContainer<?> container =
214+
GenericContainer<?> container =
216215
containerHelper
217216
.createTestContainer("aws/rds-test-container")
218217
.withNetworkAliases(AURORA_POSTGRES_TEST_HOST_NAME)
@@ -229,8 +228,10 @@ protected static GenericContainer<?> initializeTestContainer(
229228
"PROXIED_CLUSTER_TEMPLATE", "?." + dbConnStrSuffix + PROXIED_DOMAIN_NAME_SUFFIX)
230229
.withEnv("DB_CONN_STR_SUFFIX", "." + dbConnStrSuffix)
231230
.withEnv("AWS_ACCESS_KEY_ID", AWS_ACCESS_KEY_ID)
232-
.withEnv("AWS_SECRET_ACCESS_KEY", AWS_SECRET_ACCESS_KEY)
233-
.withEnv("AWS_SESSION_TOKEN", AWS_SESSION_TOKEN);
231+
.withEnv("AWS_SECRET_ACCESS_KEY", AWS_SECRET_ACCESS_KEY);
232+
if (AWS_SESSION_TOKEN != null) {
233+
container = container.withEnv("AWS_SESSION_TOKEN", AWS_SESSION_TOKEN);
234+
}
234235

235236
// Add postgres instances & proxies to container env
236237
for (int i = 0; i < postgresInstances.size(); i++) {

0 commit comments

Comments
 (0)