Skip to content

Commit 1506492

Browse files
committed
chore(protocol-tests): update protocol tests to unblock ci
1 parent 7ec5152 commit 1506492

File tree

6 files changed

+146
-1
lines changed

6 files changed

+146
-1
lines changed

protocol_tests/aws-query/tests/functional/awsquery.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,6 @@ it("QueryComplexError:Error:GreetingWithErrors", async () => {
607607
<Error>
608608
<Type>Sender</Type>
609609
<Code>ComplexError</Code>
610-
<Message>Hi</Message>
611610
<TopLevel>Top level</TopLevel>
612611
<Nested>
613612
<Foo>bar</Foo>

protocol_tests/aws-restjson/RestJsonProtocol.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ import {
4444
GreetingWithErrorsCommandInput,
4545
GreetingWithErrorsCommandOutput,
4646
} from "./commands/GreetingWithErrorsCommand";
47+
import {
48+
HostWithPathOperationCommand,
49+
HostWithPathOperationCommandInput,
50+
HostWithPathOperationCommandOutput,
51+
} from "./commands/HostWithPathOperationCommand";
4752
import {
4853
HttpEnumPayloadCommand,
4954
HttpEnumPayloadCommandInput,
@@ -501,6 +506,35 @@ export class RestJsonProtocol extends RestJsonProtocolClient {
501506
}
502507
}
503508

509+
public hostWithPathOperation(
510+
args: HostWithPathOperationCommandInput,
511+
options?: __HttpHandlerOptions
512+
): Promise<HostWithPathOperationCommandOutput>;
513+
public hostWithPathOperation(
514+
args: HostWithPathOperationCommandInput,
515+
cb: (err: any, data?: HostWithPathOperationCommandOutput) => void
516+
): void;
517+
public hostWithPathOperation(
518+
args: HostWithPathOperationCommandInput,
519+
options: __HttpHandlerOptions,
520+
cb: (err: any, data?: HostWithPathOperationCommandOutput) => void
521+
): void;
522+
public hostWithPathOperation(
523+
args: HostWithPathOperationCommandInput,
524+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: HostWithPathOperationCommandOutput) => void),
525+
cb?: (err: any, data?: HostWithPathOperationCommandOutput) => void
526+
): Promise<HostWithPathOperationCommandOutput> | void {
527+
const command = new HostWithPathOperationCommand(args);
528+
if (typeof optionsOrCb === "function") {
529+
this.send(command, optionsOrCb);
530+
} else if (typeof cb === "function") {
531+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
532+
this.send(command, optionsOrCb || {}, cb);
533+
} else {
534+
return this.send(command, optionsOrCb);
535+
}
536+
}
537+
504538
public httpEnumPayload(
505539
args: HttpEnumPayloadCommandInput,
506540
options?: __HttpHandlerOptions

protocol_tests/aws-restjson/RestJsonProtocolClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import {
2525
EndpointWithHostLabelOperationCommandOutput,
2626
} from "./commands/EndpointWithHostLabelOperationCommand";
2727
import { GreetingWithErrorsCommandInput, GreetingWithErrorsCommandOutput } from "./commands/GreetingWithErrorsCommand";
28+
import {
29+
HostWithPathOperationCommandInput,
30+
HostWithPathOperationCommandOutput,
31+
} from "./commands/HostWithPathOperationCommand";
2832
import { HttpEnumPayloadCommandInput, HttpEnumPayloadCommandOutput } from "./commands/HttpEnumPayloadCommand";
2933
import { HttpPayloadTraitsCommandInput, HttpPayloadTraitsCommandOutput } from "./commands/HttpPayloadTraitsCommand";
3034
import {
@@ -168,6 +172,7 @@ export type ServiceInputTypes =
168172
| EndpointOperationCommandInput
169173
| EndpointWithHostLabelOperationCommandInput
170174
| GreetingWithErrorsCommandInput
175+
| HostWithPathOperationCommandInput
171176
| HttpEnumPayloadCommandInput
172177
| HttpPayloadTraitsCommandInput
173178
| HttpPayloadTraitsWithMediaTypeCommandInput
@@ -214,6 +219,7 @@ export type ServiceOutputTypes =
214219
| EndpointOperationCommandOutput
215220
| EndpointWithHostLabelOperationCommandOutput
216221
| GreetingWithErrorsCommandOutput
222+
| HostWithPathOperationCommandOutput
217223
| HttpEnumPayloadCommandOutput
218224
| HttpPayloadTraitsCommandOutput
219225
| HttpPayloadTraitsWithMediaTypeCommandOutput
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { RestJsonProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RestJsonProtocolClient";
2+
import {
3+
deserializeAws_restJson1HostWithPathOperationCommand,
4+
serializeAws_restJson1HostWithPathOperationCommand,
5+
} from "../protocols/Aws_restJson1";
6+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
7+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
8+
import { Command as $Command } from "@aws-sdk/smithy-client";
9+
import {
10+
FinalizeHandlerArguments,
11+
Handler,
12+
HandlerExecutionContext,
13+
MiddlewareStack,
14+
HttpHandlerOptions as __HttpHandlerOptions,
15+
MetadataBearer as __MetadataBearer,
16+
SerdeContext as __SerdeContext,
17+
} from "@aws-sdk/types";
18+
19+
export interface HostWithPathOperationCommandInput {}
20+
export interface HostWithPathOperationCommandOutput extends __MetadataBearer {}
21+
22+
export class HostWithPathOperationCommand extends $Command<
23+
HostWithPathOperationCommandInput,
24+
HostWithPathOperationCommandOutput,
25+
RestJsonProtocolClientResolvedConfig
26+
> {
27+
// Start section: command_properties
28+
// End section: command_properties
29+
30+
constructor(readonly input: HostWithPathOperationCommandInput) {
31+
// Start section: command_constructor
32+
super();
33+
// End section: command_constructor
34+
}
35+
36+
/**
37+
* @internal
38+
*/
39+
resolveMiddleware(
40+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
41+
configuration: RestJsonProtocolClientResolvedConfig,
42+
options?: __HttpHandlerOptions
43+
): Handler<HostWithPathOperationCommandInput, HostWithPathOperationCommandOutput> {
44+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
45+
46+
const stack = clientStack.concat(this.middlewareStack);
47+
48+
const { logger } = configuration;
49+
const clientName = "RestJsonProtocolClient";
50+
const commandName = "HostWithPathOperationCommand";
51+
const handlerExecutionContext: HandlerExecutionContext = {
52+
logger,
53+
clientName,
54+
commandName,
55+
inputFilterSensitiveLog: (input: any) => input,
56+
outputFilterSensitiveLog: (output: any) => output,
57+
};
58+
const { requestHandler } = configuration;
59+
return stack.resolve(
60+
(request: FinalizeHandlerArguments<any>) =>
61+
requestHandler.handle(request.request as __HttpRequest, options || {}),
62+
handlerExecutionContext
63+
);
64+
}
65+
66+
private serialize(input: HostWithPathOperationCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
67+
return serializeAws_restJson1HostWithPathOperationCommand(input, context);
68+
}
69+
70+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<HostWithPathOperationCommandOutput> {
71+
return deserializeAws_restJson1HostWithPathOperationCommand(output, context);
72+
}
73+
74+
// Start section: command_body_extra
75+
// End section: command_body_extra
76+
}

protocol_tests/aws-restjson/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from "./commands/EmptyInputAndEmptyOutputCommand";
99
export * from "./commands/EndpointOperationCommand";
1010
export * from "./commands/EndpointWithHostLabelOperationCommand";
1111
export * from "./commands/GreetingWithErrorsCommand";
12+
export * from "./commands/HostWithPathOperationCommand";
1213
export * from "./commands/HttpEnumPayloadCommand";
1314
export * from "./commands/HttpPayloadTraitsCommand";
1415
export * from "./commands/HttpPayloadTraitsWithMediaTypeCommand";

protocol_tests/aws-restjson/tests/functional/restjson1.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { EmptyInputAndEmptyOutputCommand } from "../../commands/EmptyInputAndEmp
88
import { EndpointOperationCommand } from "../../commands/EndpointOperationCommand";
99
import { EndpointWithHostLabelOperationCommand } from "../../commands/EndpointWithHostLabelOperationCommand";
1010
import { GreetingWithErrorsCommand } from "../../commands/GreetingWithErrorsCommand";
11+
import { HostWithPathOperationCommand } from "../../commands/HostWithPathOperationCommand";
1112
import { HttpEnumPayloadCommand } from "../../commands/HttpEnumPayloadCommand";
1213
import { HttpPayloadTraitsCommand } from "../../commands/HttpPayloadTraitsCommand";
1314
import { HttpPayloadTraitsWithMediaTypeCommand } from "../../commands/HttpPayloadTraitsWithMediaTypeCommand";
@@ -1862,6 +1863,34 @@ it("RestJsonInvalidGreetingError:Error:GreetingWithErrors", async () => {
18621863
fail("Expected an exception to be thrown from response");
18631864
});
18641865

1866+
/**
1867+
* Custom endpoints supplied by users can have paths
1868+
*/
1869+
it("RestJsonHostWithPath:Request", async () => {
1870+
const client = new RestJsonProtocolClient({
1871+
...clientParams,
1872+
endpoint: "https://example.com/custom",
1873+
requestHandler: new RequestSerializationTestHandler(),
1874+
});
1875+
1876+
const command = new HostWithPathOperationCommand({});
1877+
try {
1878+
await client.send(command);
1879+
fail("Expected an EXPECTED_REQUEST_SERIALIZATION_ERROR to be thrown");
1880+
return;
1881+
} catch (err) {
1882+
if (!(err instanceof EXPECTED_REQUEST_SERIALIZATION_ERROR)) {
1883+
fail(err);
1884+
return;
1885+
}
1886+
const r = err.request;
1887+
expect(r.method).toBe("GET");
1888+
expect(r.path).toBe("/custom/HostWithPathOperation");
1889+
1890+
expect(r.body).toBeFalsy();
1891+
}
1892+
});
1893+
18651894
it("EnumPayloadRequest:Request", async () => {
18661895
const client = new RestJsonProtocolClient({
18671896
...clientParams,

0 commit comments

Comments
 (0)