Skip to content

Commit

Permalink
fix: environment variable is "AWS_SESSION_TOKEN" and not "Token" (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsirac committed Oct 20, 2021
1 parent 3971244 commit c8c3073
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Expand Up @@ -273,7 +273,7 @@ AwsSecurityCredentials getAwsSecurityCredentials() throws IOException {
// Check environment variables for credentials first.
String accessKeyId = getEnvironmentProvider().getEnv("AWS_ACCESS_KEY_ID");
String secretAccessKey = getEnvironmentProvider().getEnv("AWS_SECRET_ACCESS_KEY");
String token = getEnvironmentProvider().getEnv("Token");
String token = getEnvironmentProvider().getEnv("AWS_SESSION_TOKEN");
if (accessKeyId != null && secretAccessKey != null) {
return new AwsSecurityCredentials(accessKeyId, secretAccessKey, token);
}
Expand Down
Expand Up @@ -276,7 +276,7 @@ void getAwsSecurityCredentials_fromEnvironmentVariablesWithToken() throws IOExce
environmentProvider
.setEnv("AWS_ACCESS_KEY_ID", "awsAccessKeyId")
.setEnv("AWS_SECRET_ACCESS_KEY", "awsSecretAccessKey")
.setEnv("Token", "token");
.setEnv("AWS_SESSION_TOKEN", "awsSessionToken");

AwsCredentials testAwsCredentials =
(AwsCredentials)
Expand All @@ -288,7 +288,7 @@ void getAwsSecurityCredentials_fromEnvironmentVariablesWithToken() throws IOExce

assertEquals("awsAccessKeyId", credentials.getAccessKeyId());
assertEquals("awsSecretAccessKey", credentials.getSecretAccessKey());
assertEquals("token", credentials.getToken());
assertEquals("awsSessionToken", credentials.getToken());
}

@Test
Expand Down
Expand Up @@ -535,9 +535,9 @@ public AwsSecurityCredentials retrieveAwsSecurityCredentials() throws IOExceptio

GenericJson json = parser.parseAndClose(stream, StandardCharsets.UTF_8, GenericJson.class);

String awsToken = (String) json.get("Token");
String secretAccessKey = (String) json.get("SecretAccessKey");
String accessKeyId = (String) json.get("AccessKeyId");
String secretAccessKey = (String) json.get("SecretAccessKey");
String awsToken = (String) json.get("Token");

return new AwsSecurityCredentials(accessKeyId, secretAccessKey, awsToken);
}
Expand Down
Expand Up @@ -138,7 +138,7 @@ void awsCredentials() throws Exception {
testEnvironmentProvider
.setEnv("AWS_ACCESS_KEY_ID", awsAccessKeyId)
.setEnv("AWS_SECRET_ACCESS_KEY", awsSecretAccessKey)
.setEnv("Token", awsSessionToken)
.setEnv("AWS_SESSION_TOKEN", awsSessionToken)
.setEnv("AWS_REGION", "us-east-2");

AwsCredentials awsCredential =
Expand Down

0 comments on commit c8c3073

Please sign in to comment.