Skip to content

Commit e0f9e81

Browse files
committed
test: override signer credential provider in integration
1 parent 467913a commit e0f9e81

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

private/aws-util-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"dependencies": {
2020
"@aws-sdk/aws-protocoltests-json": "*",
2121
"@smithy/protocol-http": "^4.1.4",
22+
"@smithy/signature-v4": "^4.2.0",
2223
"@smithy/types": "^3.5.0",
2324
"tslib": "^2.6.2"
2425
},

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
2+
import type { SignatureV4 } from "@smithy/signature-v4";
23
import {
4+
AwsCredentialIdentity,
35
Client,
46
HandlerExecutionContext,
57
HttpHandlerOptions,
8+
IdentityProvider,
69
RequestHandler,
710
RequestHandlerOutput,
11+
SelectedHttpAuthScheme,
812
SMITHY_CONTEXT_KEY,
913
} from "@smithy/types";
1014
import { expect } from "vitest";
@@ -118,8 +122,13 @@ export class TestHttpHandler implements HttpHandler {
118122
}
119123
client.middlewareStack.addRelativeTo(
120124
(next: any, context: HandlerExecutionContext) => (args: any) => {
121-
if (context[SMITHY_CONTEXT_KEY]?.selectedHttpAuthScheme) {
122-
(context[SMITHY_CONTEXT_KEY] as any).selectedHttpAuthScheme.identity = MOCK_CREDENTIALS;
125+
const scheme = context[SMITHY_CONTEXT_KEY]?.selectedHttpAuthScheme as SelectedHttpAuthScheme;
126+
if (scheme) {
127+
scheme.identity = MOCK_CREDENTIALS as AwsCredentialIdentity;
128+
if ((scheme.signer as any).credentialProvider) {
129+
(scheme.signer as any).credentialProvider = (async () =>
130+
MOCK_CREDENTIALS) as IdentityProvider<AwsCredentialIdentity>;
131+
}
123132
}
124133
return next(args);
125134
},

0 commit comments

Comments
 (0)