Skip to content

Commit 293511a

Browse files
committed
test(aws-util-test): add httpAuthScheme mocking for integ tests
1 parent 6b988d4 commit 293511a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/middleware-token/src/middleware-token.integ.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("middleware-token", () => {
1313
},
1414
});
1515
requireRequestsFrom(client).toMatch({
16-
headers: new Map([[/authorization/i, /Bearer my-token/]]),
16+
headers: new Map([[/authorization/i, /Bearer MOCK_TOKEN/]]),
1717
});
1818
await client.getUserDetails({
1919
id: "my-id",

private/aws-util-test/src/requests/test-http-handler.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ export class TestHttpHandler implements HttpHandler {
9999
return _signer;
100100
};
101101
}
102+
if (client.config.httpAuthSchemes) {
103+
for (const authScheme of client.config.httpAuthSchemes) {
104+
authScheme.identityProvider = () => {
105+
return async () => {
106+
return {
107+
...MOCK_CREDENTIALS,
108+
token: "MOCK_TOKEN",
109+
};
110+
};
111+
};
112+
}
113+
}
102114

103115
client.config.requestHandler = new TestHttpHandler(matcher);
104116
if (!(client as any)[TestHttpHandler.WATCHER]) {

0 commit comments

Comments
 (0)