Skip to content
Permalink
Browse files
fix: environment variable is "AWS_SESSION_TOKEN" and not "Token" (#772)
  • Loading branch information
lsirac committed Oct 20, 2021
1 parent 3971244 commit c8c3073790ca2f660eabd2c410b0e295f693040b
@@ -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);
}
@@ -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)
@@ -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
@@ -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);
}
@@ -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 =

0 comments on commit c8c3073

Please sign in to comment.