Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: environment variable is "AWS_SESSION_TOKEN" and not "Token" #772

Merged
merged 1 commit into from Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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