-
Notifications
You must be signed in to change notification settings - Fork 680
Expand file tree
/
Copy pathfromHttp.integ.spec.ts
More file actions
58 lines (53 loc) · 1.78 KB
/
fromHttp.integ.spec.ts
File metadata and controls
58 lines (53 loc) · 1.78 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
58
import { S3 } from "@aws-sdk/client-s3";
import { fromHttp } from "@aws-sdk/credential-providers";
import { describe, expect, test as it } from "vitest";
import { CTest } from "./_test-lib";
describe(fromHttp.name, () => {
const ctest = new CTest({
credentialProvider: fromHttp,
});
describe("configure from env", () => {
it("is not configurable from env", async () => {
process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI = "http://169.254.170.23";
process.env.AWS_CONTAINER_AUTHORIZATION_TOKEN = "container-authorization";
const s3 = new S3({
credentials: fromHttp(),
});
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_HTTP: "z",
},
accessKeyId: "CONTAINER_ACCESS_KEY",
expiration: new Date("3000-01-01T00:00:00.000Z"),
secretAccessKey: "CONTAINER_SECRET_ACCESS_KEY",
sessionToken: "CONTAINER_TOKEN",
});
});
});
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({
credentials: fromHttp({
awsContainerCredentialsFullUri: "http://169.254.170.23",
authorizationToken: "container-authorization",
}),
});
await s3.listBuckets();
expect(await s3.config.credentials()).toEqual({
$source: {
CREDENTIALS_HTTP: "z",
},
accessKeyId: "CONTAINER_ACCESS_KEY",
expiration: new Date("3000-01-01T00:00:00.000Z"),
secretAccessKey: "CONTAINER_SECRET_ACCESS_KEY",
sessionToken: "CONTAINER_TOKEN",
});
});
});
});