|
21 | 21 | import static org.assertj.core.api.Assertions.assertThat;
|
22 | 22 |
|
23 | 23 | import jakarta.annotation.Nonnull;
|
| 24 | +import java.time.Instant; |
24 | 25 | import java.util.EnumMap;
|
25 | 26 | import java.util.List;
|
26 | 27 | import java.util.Set;
|
|
49 | 50 |
|
50 | 51 | class AwsCredentialsStorageIntegrationTest {
|
51 | 52 |
|
| 53 | + public static final Instant EXPIRE_TIME = Instant.now().plusMillis(3600_000); |
| 54 | + |
52 | 55 | public static final AssumeRoleResponse ASSUME_ROLE_RESPONSE =
|
53 | 56 | AssumeRoleResponse.builder()
|
54 | 57 | .credentials(
|
55 | 58 | Credentials.builder()
|
56 | 59 | .accessKeyId("accessKey")
|
57 | 60 | .secretAccessKey("secretKey")
|
58 | 61 | .sessionToken("sess")
|
| 62 | + .expiration(EXPIRE_TIME) |
59 | 63 | .build())
|
60 | 64 | .build();
|
61 | 65 | public static final String AWS_PARTITION = "aws";
|
@@ -93,7 +97,10 @@ public void testGetSubscopedCreds() {
|
93 | 97 | .isNotEmpty()
|
94 | 98 | .containsEntry(PolarisCredentialProperty.AWS_TOKEN, "sess")
|
95 | 99 | .containsEntry(PolarisCredentialProperty.AWS_KEY_ID, "accessKey")
|
96 |
| - .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey"); |
| 100 | + .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey") |
| 101 | + .containsEntry( |
| 102 | + PolarisCredentialProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS, |
| 103 | + String.valueOf(EXPIRE_TIME.toEpochMilli())); |
97 | 104 | }
|
98 | 105 |
|
99 | 106 | @ParameterizedTest
|
@@ -255,7 +262,10 @@ public void testGetSubscopedCredsInlinePolicy(String awsPartition) {
|
255 | 262 | .isNotEmpty()
|
256 | 263 | .containsEntry(PolarisCredentialProperty.AWS_TOKEN, "sess")
|
257 | 264 | .containsEntry(PolarisCredentialProperty.AWS_KEY_ID, "accessKey")
|
258 |
| - .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey"); |
| 265 | + .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey") |
| 266 | + .containsEntry( |
| 267 | + PolarisCredentialProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS, |
| 268 | + String.valueOf(EXPIRE_TIME.toEpochMilli())); |
259 | 269 | break;
|
260 | 270 | default:
|
261 | 271 | throw new IllegalArgumentException("Unknown aws partition: " + awsPartition);
|
@@ -353,7 +363,10 @@ public void testGetSubscopedCredsInlinePolicyWithoutList() {
|
353 | 363 | .isNotEmpty()
|
354 | 364 | .containsEntry(PolarisCredentialProperty.AWS_TOKEN, "sess")
|
355 | 365 | .containsEntry(PolarisCredentialProperty.AWS_KEY_ID, "accessKey")
|
356 |
| - .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey"); |
| 366 | + .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey") |
| 367 | + .containsEntry( |
| 368 | + PolarisCredentialProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS, |
| 369 | + String.valueOf(EXPIRE_TIME.toEpochMilli())); |
357 | 370 | }
|
358 | 371 |
|
359 | 372 | @Test
|
@@ -445,7 +458,10 @@ public void testGetSubscopedCredsInlinePolicyWithoutWrites() {
|
445 | 458 | .isNotEmpty()
|
446 | 459 | .containsEntry(PolarisCredentialProperty.AWS_TOKEN, "sess")
|
447 | 460 | .containsEntry(PolarisCredentialProperty.AWS_KEY_ID, "accessKey")
|
448 |
| - .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey"); |
| 461 | + .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey") |
| 462 | + .containsEntry( |
| 463 | + PolarisCredentialProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS, |
| 464 | + String.valueOf(EXPIRE_TIME.toEpochMilli())); |
449 | 465 | }
|
450 | 466 |
|
451 | 467 | @Test
|
@@ -507,7 +523,10 @@ public void testGetSubscopedCredsInlinePolicyWithEmptyReadAndWrite() {
|
507 | 523 | .isNotEmpty()
|
508 | 524 | .containsEntry(PolarisCredentialProperty.AWS_TOKEN, "sess")
|
509 | 525 | .containsEntry(PolarisCredentialProperty.AWS_KEY_ID, "accessKey")
|
510 |
| - .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey"); |
| 526 | + .containsEntry(PolarisCredentialProperty.AWS_SECRET_KEY, "secretKey") |
| 527 | + .containsEntry( |
| 528 | + PolarisCredentialProperty.AWS_SESSION_TOKEN_EXPIRES_AT_MS, |
| 529 | + String.valueOf(EXPIRE_TIME.toEpochMilli())); |
511 | 530 | }
|
512 | 531 |
|
513 | 532 | @ParameterizedTest
|
|
0 commit comments