Skip to content

modify ProcessCredentialsProviderTest to interpret session tokens #1528

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

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
public class ProcessCredentialsProviderTest {

private final static String PROCESS_RESOURCE_PATH = "/resources/process/";
private final static String RANDOM_SESSION_TOKEN = "RANDOM_TOKEN";
private static String scriptLocation;

@BeforeClass
Expand Down Expand Up @@ -102,8 +103,10 @@ public void resultsAreCached() {
public void expirationBufferOverrideIsApplied() {
ProcessCredentialsProvider credentialsProvider =
ProcessCredentialsProvider.builder()
.command(scriptLocation + " accessKeyId secretAccessKey sessionToken " +
DateUtils.formatIso8601Date(Instant.now().plusSeconds(20)))
.command(String.format("%s accessKeyId secretAccessKey %s %s",
scriptLocation,
RANDOM_SESSION_TOKEN,
DateUtils.formatIso8601Date(Instant.now().plusSeconds(20))))
.credentialRefreshThreshold(Duration.ofSeconds(20))
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ echo '"Version": 1,';
echo "\"AccessKeyId\": \"$1\",";
echo "\"SecretAccessKey\": \"$2\"";
if [[ $# -ge 3 ]]; then
echo ','
echo "\"SessionToken\": \"$RANDOM\"";
echo ',';
if [[ "$3" = "RANDOM_TOKEN" ]]; then
echo "\"SessionToken\": \"$RANDOM\""
else
echo "\"SessionToken\": \"$3\""
fi;
fi;
if [[ $# -ge 4 ]]; then
echo ','
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ ECHO "AccessKeyId": "%1",
ECHO "SecretAccessKey": "%2"
IF NOT "%3"=="" (
ECHO ,
ECHO "SessionToken": "%RANDOM"
IF "%3"=="RANDOM_TOKEN" (
ECHO "SessionToken": "%RANDOM%"
) ELSE (
ECHO "SessionToken": "%3"
)
)
IF NOT "%4"=="" (
ECHO ,
Expand Down