Skip to content

Commit 062bde7

Browse files
authored
add required client configs to protocol test (#213)
* add required client configs to protocol test So that the protocol test can be run in environment without existing AWS configs
1 parent 65d97f3 commit 062bde7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ private void generateRequestTest(OperationShape operation, HttpRequestTestCase t
180180
testCase.getDocumentation().ifPresent(writer::writeDocs);
181181
writer.openBlock("it($S, async () => {", "});\n", testName, () -> {
182182
// Create a client with a custom request handler that intercepts requests.
183-
writer.openBlock("const client = new $T({", "});\n", serviceSymbol, () ->
184-
writer.write("requestHandler: new RequestSerializationTestHandler()"));
183+
writer.openBlock("const client = new $T({", "});\n", serviceSymbol, () -> {
184+
writer.write("...clientParams,");
185+
writer.write("requestHandler: new RequestSerializationTestHandler(),");
186+
});
185187

186188
// Run the parameters through a visitor to adjust for TS specific inputs.
187189
ObjectNode params = testCase.getParams();
@@ -387,15 +389,17 @@ private void writeResponseTestSetup(OperationShape operation, HttpResponseTestCa
387389
String body = testCase.getBody().orElse(null);
388390

389391
// Create a client with a custom request handler that intercepts requests.
390-
writer.openBlock("const client = new $T({", "});\n", serviceSymbol, () ->
392+
writer.openBlock("const client = new $T({", "});\n", serviceSymbol, () -> {
393+
writer.write("...clientParams,");
391394
writer.openBlock("requestHandler: new ResponseDeserializationTestHandler(", ")", () -> {
392395
writer.write("$L,", isSuccess);
393396
writer.write("$L,", testCase.getCode());
394397
writer.write("$L,", headers.isEmpty() ? "undefined" : headerParameters);
395398
if (body != null) {
396399
writer.write("`$L`,", body);
397400
}
398-
}));
401+
});
402+
});
399403

400404
// Set the command's parameters to empty, using the any type to
401405
// trick TS in to letting us send this command through.

smithy-typescript-codegen/src/main/resources/software/amazon/smithy/typescript/codegen/protocol-test-stub.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,8 @@ const equivalentContents = (expected: any, generated: any): boolean => {
132132

133133
return true;
134134
}
135+
136+
const clientParams = {
137+
region: "us-west-2",
138+
credentials: { accessKeyId: "key", secretAccessKey: "secret" }
139+
}

0 commit comments

Comments
 (0)