Skip to content

Commit 08bc9a8

Browse files
committed
test: use static credentials in integration
1 parent e0f9e81 commit 08bc9a8

File tree

5 files changed

+6
-63
lines changed

5 files changed

+6
-63
lines changed

packages/middleware-flexible-checksums/src/middleware-flexible-checksums.integ.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ describe("middleware-flexible-checksums", () => {
138138

139139
requireRequestsFrom(client).toMatch({
140140
headers: {
141-
"user-agent": new RegExp(`(.*?) m\/${id},E$`),
141+
"user-agent": new RegExp(`(.*?) m\/(.*?)${id}(.*?)$`),
142142
},
143143
});
144144

packages/middleware-sdk-s3/src/s3-express/middleware-s3-express.integ.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe("middleware-s3-express", () => {
9494

9595
requireRequestsFrom(client).toMatch({
9696
headers: {
97-
"user-agent": /(.*?) m\/J,E$/,
97+
"user-agent": /(.*?) m\/(.*?)J(.*?)$/,
9898
},
9999
});
100100

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 MOCK_TOKEN/]]),
16+
headers: new Map([[/authorization/i, /Bearer my-token/]]),
1717
});
1818
await client.getUserDetails({
1919
id: "my-id",

private/aws-util-test/package.json

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

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

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
import { HttpHandler, HttpRequest, HttpResponse } from "@smithy/protocol-http";
2-
import type { SignatureV4 } from "@smithy/signature-v4";
3-
import {
4-
AwsCredentialIdentity,
5-
Client,
6-
HandlerExecutionContext,
7-
HttpHandlerOptions,
8-
IdentityProvider,
9-
RequestHandler,
10-
RequestHandlerOutput,
11-
SelectedHttpAuthScheme,
12-
SMITHY_CONTEXT_KEY,
13-
} from "@smithy/types";
2+
import { Client, HttpHandlerOptions, RequestHandler, RequestHandlerOutput } from "@smithy/types";
143
import { expect } from "vitest";
154

165
/**
@@ -80,6 +69,8 @@ export class TestHttpHandler implements HttpHandler {
8069
for (const key in RESERVED_ENVIRONMENT_VARIABLES) {
8170
delete process.env[key];
8271
}
72+
process.env.AWS_ACCESS_KEY_ID = "INTEGRATION_TEST_MOCK";
73+
process.env.AWS_SECRET_ACCESS_KEY = "INTEGRATION_TEST_MOCK";
8374
}
8475

8576
/**
@@ -92,53 +83,6 @@ export class TestHttpHandler implements HttpHandler {
9283
this.client = client;
9384
this.originalRequestHandler = client.config.requestHandler;
9485
// mock credentials to avoid default chain lookup.
95-
client.config.credentials = async () => MOCK_CREDENTIALS;
96-
client.config.credentialDefaultProvider = () => {
97-
return async () => {
98-
return MOCK_CREDENTIALS;
99-
};
100-
};
101-
const signerProvider = client.config.signer;
102-
if (typeof signerProvider === "function") {
103-
client.config.signer = async () => {
104-
const _signer = await signerProvider();
105-
if (typeof _signer.credentialProvider === "function") {
106-
// signer is instance of SignatureV4
107-
_signer.credentialProvider = async () => {
108-
return MOCK_CREDENTIALS;
109-
};
110-
}
111-
return _signer;
112-
};
113-
}
114-
if (client.config.httpAuthSchemes) {
115-
for (const authScheme of client.config.httpAuthSchemes) {
116-
authScheme.identityProvider = () => {
117-
return async () => {
118-
return MOCK_CREDENTIALS;
119-
};
120-
};
121-
}
122-
}
123-
client.middlewareStack.addRelativeTo(
124-
(next: any, context: HandlerExecutionContext) => (args: any) => {
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-
}
132-
}
133-
return next(args);
134-
},
135-
{
136-
name: "integrationTestMiddleware",
137-
override: true,
138-
toMiddleware: "httpSigningMiddleware",
139-
relation: "before",
140-
}
141-
);
14286

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

0 commit comments

Comments
 (0)