-
Notifications
You must be signed in to change notification settings - Fork 680
Expand file tree
/
Copy pathfromWebToken.integ.spec.ts
More file actions
57 lines (51 loc) · 1.65 KB
/
fromWebToken.integ.spec.ts
File metadata and controls
57 lines (51 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { S3 } from "@aws-sdk/client-s3";
import { fromWebToken } from "@aws-sdk/credential-providers";
import { describe, expect, test as it } from "vitest";
import { CTest } from "./_test-lib";
describe(fromWebToken.name, () => {
const ctest = new CTest({
credentialProvider: fromWebToken,
providerParams: (testParams) => {
return {
webIdentityToken: "token-contents",
roleArn: "arn:aws:iam::1234567890:role/Rigmarole",
...CTest.defaultRegionConfigProvider(testParams),
};
},
profileCredentials: false,
fallbackRegion: "us-east-1",
});
ctest.testRegion();
describe("configure from env", () => {
it("is not configurable from env", async () => {
expect("ok").toBeTruthy();
});
});
describe("configure from profile", () => {
it("is not configurable from profile", async () => {
expect("ok").toBeTruthy();
});
});
describe("configure from code", () => {
it("should be configurable from code", async () => {
const s3 = new S3({
region: "us-west-2",
credentials: fromWebToken({
webIdentityToken: "token-contents",
roleArn: "arn:aws:iam::1234567890:role/Rigmarole",
roleSessionName: "role-session-1234",
}),
});
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_STS_ASSUME_ROLE_WEB_ID: "k",
},
accessKeyId: "STS_ARWI_ACCESS_KEY_ID",
expiration: new Date("3000-01-01T00:00:00.000Z"),
secretAccessKey: "STS_ARWI_SECRET_ACCESS_KEY",
sessionToken: "STS_ARWI_SESSION_TOKEN_us-west-2",
});
});
});
});