Skip to content

Commit b2e3639

Browse files
committed
fixup! migrate latest aws sdk v2 parts to aws sdk v3
migrate latest aws sdk v2 parts to aws sdk v3
1 parent f24da75 commit b2e3639

File tree

1 file changed

+24
-9
lines changed
  • tests/functional/aws-node-sdk/test/rateLimit

1 file changed

+24
-9
lines changed

tests/functional/aws-node-sdk/test/rateLimit/tooling.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,38 @@ const { config } = require('../../../../../lib/Config');
1010

1111
const skipIfRateLimitDisabled = config.rateLimiting.enabled ? describe : describe.skip;
1212

13-
function buildHttpRequest(method, host, path, body = '') {
14-
const url = new URL(`http://${host}`);
15-
return new HttpRequest({
13+
function buildHttpRequest(method, host, rawPath, body = '') {
14+
const endpoint = new URL(`http://${host}`);
15+
const target = new URL(rawPath, `http://${host}`);
16+
17+
const query = {};
18+
target.searchParams.forEach((value, key) => {
19+
if (Object.prototype.hasOwnProperty.call(query, key)) {
20+
const current = query[key];
21+
query[key] = Array.isArray(current) ? current.concat(value) : [current, value];
22+
} else {
23+
query[key] = value ?? '';
24+
}
25+
});
26+
27+
const request = new HttpRequest({
1628
method: method.toUpperCase(),
17-
protocol: url.protocol,
18-
hostname: url.hostname,
19-
port: url.port ? Number(url.port) : undefined,
20-
path,
29+
protocol: endpoint.protocol,
30+
hostname: endpoint.hostname,
31+
port: endpoint.port ? Number(endpoint.port) : undefined,
32+
path: target.pathname,
33+
query: Object.keys(query).length ? query : undefined,
2134
headers: {
2235
host,
2336
},
2437
body: body || undefined,
2538
});
39+
40+
return { request, target };
2641
}
2742

2843
async function sendRateLimitRequest(method, host, path, body = '') {
29-
const request = buildHttpRequest(method, host, path, body);
44+
const { request, target } = buildHttpRequest(method, host, path, body);
3045

3146
const credentials = getCredentials('lisa');
3247
const signer = new SignatureV4({
@@ -37,7 +52,7 @@ async function sendRateLimitRequest(method, host, path, body = '') {
3752
});
3853
const signedRequest = await signer.sign(request);
3954

40-
const url = `http://${host}${path}`;
55+
const url = target.href;
4156
const options = {
4257
method: signedRequest.method,
4358
headers: signedRequest.headers,

0 commit comments

Comments
 (0)