Skip to content

Commit

Permalink
chore: Remove HttpInterceptor (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Sep 13, 2024
1 parent 47d9396 commit 5a7e443
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ class UnauthenticatedAPITests: XCTestCase {
}

// Interceptor & interceptor provider for sanity-checking that request is indeed unauthenticated.
class GetHeadersBeforeTransmit<InputType, OutputType>: HttpInterceptor {
class GetHeadersBeforeTransmit<InputType, OutputType>: Interceptor {
typealias RequestType = HTTPRequest
typealias ResponseType = HTTPResponse
func readBeforeTransmit(context: some AfterSerialization<InputType, RequestType>) async throws {
// Assert that the request is unauthenticated.
XCTAssertTrue(!context.getRequest().headers.exists(name: "Authorization"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ final class S3FlexibleChecksumsTests: S3XCTestCase {
}

// Streaming unsigned payload without checksum (chunked encoding)
class DisablePayloadSigning<InputType, OutputType>: HttpInterceptor {
class DisablePayloadSigning<InputType, OutputType>: Interceptor {
typealias RequestType = HTTPRequest
typealias ResponseType = HTTPResponse

func modifyBeforeRetryLoop(context: some MutableRequest<InputType, RequestType>) async throws {
context.getAttributes().set(key: SmithyHTTPAPIKeys.hasUnsignedPayloadTrait, value: true)
}
Expand Down
55 changes: 35 additions & 20 deletions IntegrationTests/XCTestPlans/AWSIntegrationTestsOnCI.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"id" : "FF4C1A8F-5D70-4A2A-BFDE-77467500C547",
"name" : "Test Scheme Action",
"options" : {

}
}
],
Expand All @@ -16,22 +17,22 @@
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSS3IntegrationTests",
"name" : "AWSS3IntegrationTests"
"identifier" : "AWSCognitoIdentityIntegrationTests",
"name" : "AWSCognitoIdentityIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSCloudFrontKeyValueStoreIntegrationTests",
"name" : "AWSCloudFrontKeyValueStoreIntegrationTests"
"identifier" : "AWSSTSIntegrationTests",
"name" : "AWSSTSIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSEC2IntegrationTests",
"name" : "AWSEC2IntegrationTests"
"identifier" : "AWSTranscribeStreamingIntegrationTests",
"name" : "AWSTranscribeStreamingIntegrationTests"
}
},
{
Expand All @@ -44,50 +45,64 @@
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSEventBridgeIntegrationTests",
"name" : "AWSEventBridgeIntegrationTests"
"identifier" : "AWSGlacierIntegrationTests",
"name" : "AWSGlacierIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSKinesisIntegrationTests",
"name" : "AWSKinesisIntegrationTests"
"identifier" : "AWSMediaConvertIntegrationTests",
"name" : "AWSMediaConvertIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSMediaConvertIntegrationTests",
"name" : "AWSMediaConvertIntegrationTests"
"identifier" : "AWSCloudFrontKeyValueStoreIntegrationTests",
"name" : "AWSCloudFrontKeyValueStoreIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSRoute53IntegrationTests",
"name" : "AWSRoute53IntegrationTests"
"identifier" : "AWSSQSIntegrationTests",
"name" : "AWSSQSIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSSQSIntegrationTests",
"name" : "AWSSQSIntegrationTests"
"identifier" : "AWSEventBridgeIntegrationTests",
"name" : "AWSEventBridgeIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSSTSIntegrationTests",
"name" : "AWSSTSIntegrationTests"
"identifier" : "AWSEC2IntegrationTests",
"name" : "AWSEC2IntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSTranscribeStreamingIntegrationTests",
"name" : "AWSTranscribeStreamingIntegrationTests"
"identifier" : "AWSKinesisIntegrationTests",
"name" : "AWSKinesisIntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSRoute53IntegrationTests",
"name" : "AWSRoute53IntegrationTests"
}
},
{
"target" : {
"containerPath" : "container:",
"identifier" : "AWSS3IntegrationTests",
"name" : "AWSS3IntegrationTests"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public struct AWSS3ErrorWith200StatusXMLMiddleware<OperationStackInput, Operatio
}
}

extension AWSS3ErrorWith200StatusXMLMiddleware: HttpInterceptor {
extension AWSS3ErrorWith200StatusXMLMiddleware: Interceptor {
public typealias InputType = OperationStackInput
public typealias OutputType = OperationStackOutput
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeDeserialization(
context: some MutableResponse<Self.InputType, Self.RequestType, Self.ResponseType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public struct AmzSdkInvocationIdMiddleware<InputType, OperationStackOutput> {
}
}

extension AmzSdkInvocationIdMiddleware: HttpInterceptor {
extension AmzSdkInvocationIdMiddleware: Interceptor {
public typealias InputType = InputType
public typealias OutputType = OperationStackOutput
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeRetryLoop(context: some MutableRequest<InputType, HTTPRequest>) async throws {
let builder = context.getRequest().toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public class AmzSdkRequestMiddleware<InputType, OperationStackOutput> {

}

extension AmzSdkRequestMiddleware: HttpInterceptor {
extension AmzSdkRequestMiddleware: Interceptor {
public typealias InputType = InputType
public typealias OutputType = OperationStackOutput
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeSigning(context: some MutableRequest<InputType, HTTPRequest>) async throws {
let builder = context.getRequest().toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ public struct FlexibleChecksumsRequestMiddleware<OperationStackInput, OperationS
}
}

extension FlexibleChecksumsRequestMiddleware: HttpInterceptor {
extension FlexibleChecksumsRequestMiddleware: Interceptor {
public typealias InputType = OperationStackInput
public typealias OutputType = OperationStackOutput
public typealias RequestType = SmithyHTTPAPI.HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeRetryLoop(context: some MutableRequest<InputType, RequestType>) async throws {
let builder = context.getRequest().toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ public struct FlexibleChecksumsResponseMiddleware<OperationStackInput, Operation
}
}

extension FlexibleChecksumsResponseMiddleware: HttpInterceptor {
extension FlexibleChecksumsResponseMiddleware: Interceptor {
public typealias InputType = OperationStackInput
public typealias OutputType = OperationStackOutput
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeRetryLoop(context: some MutableRequest<InputType, RequestType>) async throws {
context.getAttributes().set(key: AttributeKey<String>(name: "ChecksumHeaderValidated"), value: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import class Smithy.Context
import ClientRuntime
import SmithyHTTPAPI

public struct Route53TrimHostedZoneMiddleware<Input, Output> {
public let id: Swift.String = "Route53TrimHostedZoneMiddleware"
Expand All @@ -29,9 +30,11 @@ public struct Route53TrimHostedZoneMiddleware<Input, Output> {
}
}

extension Route53TrimHostedZoneMiddleware: HttpInterceptor {
extension Route53TrimHostedZoneMiddleware: Interceptor {
public typealias InputType = Input
public typealias OutputType = Output
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeSerialization(context: some MutableInput<Self.InputType>) async throws {
context.updateInput(updated: getUpdatedInput(input: context.getInput()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ public struct Sha256TreeHashMiddleware<OperationStackInput, OperationStackOutput
}
}

extension Sha256TreeHashMiddleware: HttpInterceptor {
extension Sha256TreeHashMiddleware: Interceptor {
public typealias InputType = OperationStackInput
public typealias OutputType = OperationStackOutput
public typealias RequestType = SmithyHTTPAPI.HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeSigning(context: some MutableRequest<Self.InputType, Self.RequestType>) async throws {
let request = context.getRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ public struct UserAgentMiddleware<OperationStackInput, OperationStackOutput> {
}
}

extension UserAgentMiddleware: HttpInterceptor {
extension UserAgentMiddleware: Interceptor {
public typealias InputType = OperationStackInput
public typealias OutputType = OperationStackOutput
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeTransmit(context: some MutableRequest<Self.InputType, HTTPRequest>) async throws {
let awsUserAgentString = AWSUserAgentMetadata.fromConfigAndContext(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ public struct XAmzTargetMiddleware<OperationStackInput, OperationStackOutput> {
}
}

extension XAmzTargetMiddleware: HttpInterceptor {
extension XAmzTargetMiddleware: Interceptor {
public typealias InputType = OperationStackInput
public typealias OutputType = OperationStackOutput
public typealias RequestType = HTTPRequest
public typealias ResponseType = HTTPResponse

public func modifyBeforeRetryLoop(context: some MutableRequest<Self.InputType, Self.RequestType>) async throws {
let builder = context.getRequest().toBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import software.amazon.smithy.swift.codegen.SwiftWriter
import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator
import software.amazon.smithy.swift.codegen.swiftmodules.ClientRuntimeTypes
import software.amazon.smithy.swift.codegen.swiftmodules.FoundationTypes
import software.amazon.smithy.swift.codegen.swiftmodules.SmithyHTTPAPITypes

class PredictInputEndpointURLHostMiddlewareHandler(
private val writer: SwiftWriter,
Expand All @@ -26,10 +27,12 @@ class PredictInputEndpointURLHostMiddlewareHandler(
"extension \$L: \$N {",
"}",
typeName,
ClientRuntimeTypes.Middleware.HttpInterceptor,
ClientRuntimeTypes.Middleware.Interceptor,
) {
writer.write("public typealias InputType = PredictInput")
writer.write("public typealias OutputType = PredictOutput")
writer.write("public typealias RequestType = \$N", SmithyHTTPAPITypes.HTTPRequest)
writer.write("public typealias ResponseType = \$N", SmithyHTTPAPITypes.HTTPResponse)
writer.write("")
writer.openBlock(
"public func modifyBeforeSerialization(context: some \$N<InputType>) async throws {",
Expand Down

0 comments on commit 5a7e443

Please sign in to comment.