Skip to content

Commit 5f755a3

Browse files
authored
test(core/httpAuthSchemes): add unit test for sigv4 configResolver (#6962)
1 parent 3f9fdc0 commit 5f755a3

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { AwsCredentialIdentityProvider, IdentityProvider } from "@smithy/types";
2+
import { describe, expect, test as it, vi } from "vitest";
3+
4+
import { resolveAwsSdkSigV4Config } from "./resolveAwsSdkSigV4Config";
5+
6+
describe(resolveAwsSdkSigV4Config.name, () => {
7+
it("should allow one argument to be passed to the resolved credentials function", async () => {
8+
const fn = vi.fn();
9+
10+
const myCredentialsProvider: AwsCredentialIdentityProvider = async (arg) => {
11+
fn(arg);
12+
return {
13+
accessKeyId: "",
14+
secretAccessKey: "",
15+
};
16+
};
17+
18+
const input = {
19+
credentials: myCredentialsProvider,
20+
region: "us-east-1",
21+
sha256: vi.fn(),
22+
serviceId: "",
23+
useDualstackEndpoint: async () => false,
24+
useFipsEndpoint: async () => false,
25+
};
26+
27+
const config = resolveAwsSdkSigV4Config(input);
28+
29+
const arg = {
30+
forceRefresh: true,
31+
a: "a",
32+
b: "b",
33+
[Math.random()]: Math.random(),
34+
};
35+
36+
await config.credentials(arg);
37+
expect(fn).toHaveBeenCalledWith(expect.objectContaining(arg));
38+
// todo: callerClientConfig should be `config` after https://github.com/aws/aws-sdk-js-v3/pull/6959.
39+
// expect(fn).toHaveBeenCalledWith({
40+
// ...arg,
41+
// callerClientConfig: input,
42+
// });
43+
});
44+
});

0 commit comments

Comments
 (0)