Skip to content

Commit

Permalink
chore(protocoltests): add tests with ContentEncoding
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Jan 4, 2024
1 parent 61e6172 commit 6262be8
Show file tree
Hide file tree
Showing 30 changed files with 204 additions and 36 deletions.
1 change: 1 addition & 0 deletions private/aws-protocoltests-ec2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@smithy/fetch-http-handler": "^2.3.2",
"@smithy/hash-node": "^2.0.18",
"@smithy/invalid-dependency": "^2.0.16",
"@smithy/middleware-compression": "^2.0.1",
"@smithy/middleware-content-length": "^2.0.18",
"@smithy/middleware-retry": "^2.0.26",
"@smithy/middleware-serde": "^2.0.16",
Expand Down
18 changes: 13 additions & 5 deletions private/aws-protocoltests-ec2/src/EC2ProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import {
resolveEndpointsConfig,
resolveRegionConfig,
} from "@smithy/config-resolver";
import {
CompressionInputConfig,
CompressionResolvedConfig,
resolveCompressionConfig,
} from "@smithy/middleware-compression";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
import { HttpHandler as __HttpHandler } from "@smithy/protocol-http";
Expand Down Expand Up @@ -293,7 +298,8 @@ export type EC2ProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpHa
EndpointsInputConfig &
RetryInputConfig &
HostHeaderInputConfig &
UserAgentInputConfig;
UserAgentInputConfig &
CompressionInputConfig;
/**
* @public
*
Expand All @@ -311,7 +317,8 @@ export type EC2ProtocolClientResolvedConfigType = __SmithyResolvedConfiguration<
EndpointsResolvedConfig &
RetryResolvedConfig &
HostHeaderResolvedConfig &
UserAgentResolvedConfig;
UserAgentResolvedConfig &
CompressionResolvedConfig;
/**
* @public
*
Expand Down Expand Up @@ -341,9 +348,10 @@ export class EC2ProtocolClient extends __Client<
const _config_3 = resolveRetryConfig(_config_2);
const _config_4 = resolveHostHeaderConfig(_config_3);
const _config_5 = resolveUserAgentConfig(_config_4);
const _config_6 = resolveRuntimeExtensions(_config_5, configuration?.extensions || []);
super(_config_6);
this.config = _config_6;
const _config_6 = resolveCompressionConfig(_config_5);
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
super(_config_7);
this.config = _config_7;
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { getCompressionPlugin } from "@smithy/middleware-compression";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,7 +63,10 @@ export class PutWithContentEncodingCommand extends $Command
ServiceOutputTypes
>()
.m(function (this: any, Command: any, cs: any, config: EC2ProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getCompressionPlugin(config, { encodings: ["gzip"] }),
];
})
.s("AwsEc2", "PutWithContentEncoding", {})
.n("EC2ProtocolClient", "PutWithContentEncodingCommand")
Expand Down
7 changes: 7 additions & 0 deletions private/aws-protocoltests-ec2/src/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { Sha256 } from "@aws-crypto/sha256-browser";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver";
import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler";
import {
DEFAULT_DISABLE_REQUEST_COMPRESSION,
DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
} from "@smithy/middleware-compression";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry";
import { EC2ProtocolClientConfig } from "./EC2ProtocolClient";
Expand All @@ -29,8 +33,11 @@ export const getRuntimeConfig = (config: EC2ProtocolClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression: config?.disableRequestCompression ?? DEFAULT_DISABLE_REQUEST_COMPRESSION,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
Expand Down
8 changes: 8 additions & 0 deletions private/aws-protocoltests-ec2/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
} from "@smithy/config-resolver";
import { Hash } from "@smithy/hash-node";
import {
NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS,
NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS,
} from "@smithy/middleware-compression";
import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry";
import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider";
import { NodeHttpHandler as RequestHandler, streamCollector } from "@smithy/node-http-handler";
Expand Down Expand Up @@ -38,8 +42,12 @@ export const getRuntimeConfig = (config: EC2ProtocolClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression:
config?.disableRequestCompression ?? loadNodeConfig(NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS),
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? loadNodeConfig(NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS),
retryMode:
config?.retryMode ??
loadNodeConfig({
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-json-10/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@smithy/fetch-http-handler": "^2.3.2",
"@smithy/hash-node": "^2.0.18",
"@smithy/invalid-dependency": "^2.0.16",
"@smithy/middleware-compression": "^2.0.1",
"@smithy/middleware-content-length": "^2.0.18",
"@smithy/middleware-retry": "^2.0.26",
"@smithy/middleware-serde": "^2.0.16",
Expand Down
18 changes: 13 additions & 5 deletions private/aws-protocoltests-json-10/src/JSONRPC10Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import {
resolveEndpointsConfig,
resolveRegionConfig,
} from "@smithy/config-resolver";
import {
CompressionInputConfig,
CompressionResolvedConfig,
resolveCompressionConfig,
} from "@smithy/middleware-compression";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
import { HttpHandler as __HttpHandler } from "@smithy/protocol-http";
Expand Down Expand Up @@ -260,7 +265,8 @@ export type JSONRPC10ClientConfigType = Partial<__SmithyConfiguration<__HttpHand
EndpointsInputConfig &
RetryInputConfig &
HostHeaderInputConfig &
UserAgentInputConfig;
UserAgentInputConfig &
CompressionInputConfig;
/**
* @public
*
Expand All @@ -278,7 +284,8 @@ export type JSONRPC10ClientResolvedConfigType = __SmithyResolvedConfiguration<__
EndpointsResolvedConfig &
RetryResolvedConfig &
HostHeaderResolvedConfig &
UserAgentResolvedConfig;
UserAgentResolvedConfig &
CompressionResolvedConfig;
/**
* @public
*
Expand Down Expand Up @@ -307,9 +314,10 @@ export class JSONRPC10Client extends __Client<
const _config_3 = resolveRetryConfig(_config_2);
const _config_4 = resolveHostHeaderConfig(_config_3);
const _config_5 = resolveUserAgentConfig(_config_4);
const _config_6 = resolveRuntimeExtensions(_config_5, configuration?.extensions || []);
super(_config_6);
this.config = _config_6;
const _config_6 = resolveCompressionConfig(_config_5);
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
super(_config_7);
this.config = _config_7;
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { getCompressionPlugin } from "@smithy/middleware-compression";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,7 +63,10 @@ export class PutWithContentEncodingCommand extends $Command
ServiceOutputTypes
>()
.m(function (this: any, Command: any, cs: any, config: JSONRPC10ClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getCompressionPlugin(config, { encodings: ["gzip"] }),
];
})
.s("JsonRpc10", "PutWithContentEncoding", {})
.n("JSONRPC10Client", "PutWithContentEncodingCommand")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { Sha256 } from "@aws-crypto/sha256-browser";
import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver";
import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler";
import {
DEFAULT_DISABLE_REQUEST_COMPRESSION,
DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
} from "@smithy/middleware-compression";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry";
import { JSONRPC10ClientConfig } from "./JSONRPC10Client";
Expand All @@ -29,8 +33,11 @@ export const getRuntimeConfig = (config: JSONRPC10ClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression: config?.disableRequestCompression ?? DEFAULT_DISABLE_REQUEST_COMPRESSION,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
Expand Down
8 changes: 8 additions & 0 deletions private/aws-protocoltests-json-10/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import {
NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
} from "@smithy/config-resolver";
import { Hash } from "@smithy/hash-node";
import {
NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS,
NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS,
} from "@smithy/middleware-compression";
import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry";
import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider";
import { NodeHttpHandler as RequestHandler, streamCollector } from "@smithy/node-http-handler";
Expand Down Expand Up @@ -38,8 +42,12 @@ export const getRuntimeConfig = (config: JSONRPC10ClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression:
config?.disableRequestCompression ?? loadNodeConfig(NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS),
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? loadNodeConfig(NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS),
retryMode:
config?.retryMode ??
loadNodeConfig({
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@smithy/fetch-http-handler": "^2.3.2",
"@smithy/hash-node": "^2.0.18",
"@smithy/invalid-dependency": "^2.0.16",
"@smithy/middleware-compression": "^2.0.1",
"@smithy/middleware-content-length": "^2.0.18",
"@smithy/middleware-retry": "^2.0.26",
"@smithy/middleware-serde": "^2.0.16",
Expand Down
18 changes: 13 additions & 5 deletions private/aws-protocoltests-json/src/JsonProtocolClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import {
resolveEndpointsConfig,
resolveRegionConfig,
} from "@smithy/config-resolver";
import {
CompressionInputConfig,
CompressionResolvedConfig,
resolveCompressionConfig,
} from "@smithy/middleware-compression";
import { getContentLengthPlugin } from "@smithy/middleware-content-length";
import { getRetryPlugin, resolveRetryConfig, RetryInputConfig, RetryResolvedConfig } from "@smithy/middleware-retry";
import { HttpHandler as __HttpHandler } from "@smithy/protocol-http";
Expand Down Expand Up @@ -282,7 +287,8 @@ export type JsonProtocolClientConfigType = Partial<__SmithyConfiguration<__HttpH
RetryInputConfig &
HostHeaderInputConfig &
AwsAuthInputConfig &
UserAgentInputConfig;
UserAgentInputConfig &
CompressionInputConfig;
/**
* @public
*
Expand All @@ -301,7 +307,8 @@ export type JsonProtocolClientResolvedConfigType = __SmithyResolvedConfiguration
RetryResolvedConfig &
HostHeaderResolvedConfig &
AwsAuthResolvedConfig &
UserAgentResolvedConfig;
UserAgentResolvedConfig &
CompressionResolvedConfig;
/**
* @public
*
Expand Down Expand Up @@ -331,9 +338,10 @@ export class JsonProtocolClient extends __Client<
const _config_4 = resolveHostHeaderConfig(_config_3);
const _config_5 = resolveAwsAuthConfig(_config_4);
const _config_6 = resolveUserAgentConfig(_config_5);
const _config_7 = resolveRuntimeExtensions(_config_6, configuration?.extensions || []);
super(_config_7);
this.config = _config_7;
const _config_7 = resolveCompressionConfig(_config_6);
const _config_8 = resolveRuntimeExtensions(_config_7, configuration?.extensions || []);
super(_config_8);
this.config = _config_8;
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// smithy-typescript generated code
import { getCompressionPlugin } from "@smithy/middleware-compression";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";
Expand Down Expand Up @@ -62,7 +63,10 @@ export class PutWithContentEncodingCommand extends $Command
ServiceOutputTypes
>()
.m(function (this: any, Command: any, cs: any, config: JsonProtocolClientResolvedConfig, o: any) {
return [getSerdePlugin(config, this.serialize, this.deserialize)];
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getCompressionPlugin(config, { encodings: ["gzip"] }),
];
})
.s("JsonProtocol", "PutWithContentEncoding", {})
.n("JsonProtocolClient", "PutWithContentEncodingCommand")
Expand Down
7 changes: 7 additions & 0 deletions private/aws-protocoltests-json/src/runtimeConfig.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { defaultUserAgent } from "@aws-sdk/util-user-agent-browser";
import { DEFAULT_USE_DUALSTACK_ENDPOINT, DEFAULT_USE_FIPS_ENDPOINT } from "@smithy/config-resolver";
import { FetchHttpHandler as RequestHandler, streamCollector } from "@smithy/fetch-http-handler";
import { invalidProvider } from "@smithy/invalid-dependency";
import {
DEFAULT_DISABLE_REQUEST_COMPRESSION,
DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
} from "@smithy/middleware-compression";
import { calculateBodyLength } from "@smithy/util-body-length-browser";
import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE } from "@smithy/util-retry";
import { JsonProtocolClientConfig } from "./JsonProtocolClient";
Expand All @@ -32,9 +36,12 @@ export const getRuntimeConfig = (config: JsonProtocolClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression: config?.disableRequestCompression ?? DEFAULT_DISABLE_REQUEST_COMPRESSION,
maxAttempts: config?.maxAttempts ?? DEFAULT_MAX_ATTEMPTS,
region: config?.region ?? invalidProvider("Region is missing"),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? DEFAULT_NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES,
retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || DEFAULT_RETRY_MODE),
sha256: config?.sha256 ?? Sha256,
streamCollector: config?.streamCollector ?? streamCollector,
Expand Down
8 changes: 8 additions & 0 deletions private/aws-protocoltests-json/src/runtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import {
NODE_USE_FIPS_ENDPOINT_CONFIG_OPTIONS,
} from "@smithy/config-resolver";
import { Hash } from "@smithy/hash-node";
import {
NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS,
NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS,
} from "@smithy/middleware-compression";
import { NODE_MAX_ATTEMPT_CONFIG_OPTIONS, NODE_RETRY_MODE_CONFIG_OPTIONS } from "@smithy/middleware-retry";
import { loadConfig as loadNodeConfig } from "@smithy/node-config-provider";
import { NodeHttpHandler as RequestHandler, streamCollector } from "@smithy/node-http-handler";
Expand Down Expand Up @@ -44,9 +48,13 @@ export const getRuntimeConfig = (config: JsonProtocolClientConfig) => {
defaultUserAgentProvider:
config?.defaultUserAgentProvider ??
defaultUserAgent({ serviceId: clientSharedValues.serviceId, clientVersion: packageInfo.version }),
disableRequestCompression:
config?.disableRequestCompression ?? loadNodeConfig(NODE_DISABLE_REQUEST_COMPRESSION_CONFIG_OPTIONS),
maxAttempts: config?.maxAttempts ?? loadNodeConfig(NODE_MAX_ATTEMPT_CONFIG_OPTIONS),
region: config?.region ?? loadNodeConfig(NODE_REGION_CONFIG_OPTIONS, NODE_REGION_CONFIG_FILE_OPTIONS),
requestHandler: config?.requestHandler ?? new RequestHandler(defaultConfigProvider),
requestMinCompressionSizeBytes:
config?.requestMinCompressionSizeBytes ?? loadNodeConfig(NODE_REQUEST_MIN_COMPRESSION_SIZE_BYTES_CONFIG_OPTIONS),
retryMode:
config?.retryMode ??
loadNodeConfig({
Expand Down
1 change: 1 addition & 0 deletions private/aws-protocoltests-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@smithy/fetch-http-handler": "^2.3.2",
"@smithy/hash-node": "^2.0.18",
"@smithy/invalid-dependency": "^2.0.16",
"@smithy/middleware-compression": "^2.0.1",
"@smithy/middleware-content-length": "^2.0.18",
"@smithy/middleware-retry": "^2.0.26",
"@smithy/middleware-serde": "^2.0.16",
Expand Down
Loading

0 comments on commit 6262be8

Please sign in to comment.