From f777299e989d3fa8d1ac35cdd2ac4e9fd3193ac9 Mon Sep 17 00:00:00 2001 From: George Fu Date: Tue, 11 Nov 2025 20:40:41 -0500 Subject: [PATCH] test(client-cloudwatch): e2e test of protocol selection --- .../test/e2e/CloudWatch.e2e.spec.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 clients/client-cloudwatch/test/e2e/CloudWatch.e2e.spec.ts diff --git a/clients/client-cloudwatch/test/e2e/CloudWatch.e2e.spec.ts b/clients/client-cloudwatch/test/e2e/CloudWatch.e2e.spec.ts new file mode 100644 index 000000000000..0bbad7991a15 --- /dev/null +++ b/clients/client-cloudwatch/test/e2e/CloudWatch.e2e.spec.ts @@ -0,0 +1,51 @@ +import { CloudWatch } from "@aws-sdk/client-cloudwatch"; +import { AwsJson1_0Protocol, AwsQueryProtocol, AwsSmithyRpcV2CborProtocol } from "@aws-sdk/core"; +import { describe, expect, test as it } from "vitest"; + +describe(CloudWatch.name, () => { + const cloudwatch = { + cbor: new CloudWatch({ + region: "us-west-2", + protocol: new AwsSmithyRpcV2CborProtocol({ + defaultNamespace: "com.amazonaws.cloudwatch", + awsQueryCompatible: true, + }), + }), + query: new CloudWatch({ + region: "us-west-2", + protocol: new AwsQueryProtocol({ + defaultNamespace: "com.amazonaws.cloudwatch", + /** + * Hi security scanners. I see you looking at my xml namespace. + * It's not a link, ok? We're not going to make requests over http here. + * Thanks. + */ + xmlNamespace: "http://monitoring.amazonaws.com/doc/2010-08-01/", + version: "2010-08-01", + }), + }), + json: new CloudWatch({ + region: "us-west-2", + protocol: new AwsJson1_0Protocol({ + defaultNamespace: "com.amazonaws.cloudwatch", + serviceTarget: "GraniteServiceVersion20100801", + awsQueryCompatible: true, + }), + }), + }; + + it("can make requests with AWS Query protocol", async () => { + const dashes = await cloudwatch.query.listDashboards(); + expect(dashes.DashboardEntries ?? []).toBeInstanceOf(Array); + }); + + it("can make requests with Smithy RPCv2 CBOR protocol", async () => { + const dashes = await cloudwatch.cbor.listDashboards(); + expect(dashes.DashboardEntries ?? []).toBeInstanceOf(Array); + }); + + it("can make requests with AWS JSON RPC protocol", async () => { + const dashes = await cloudwatch.json.listDashboards(); + expect(dashes.DashboardEntries ?? []).toBeInstanceOf(Array); + }); +});