Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Adjust tests for client config changes #1884

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ class UnauthenticatedAPITests: XCTestCase {
cognitoIdentityClient = try CognitoIdentityClient(region: region)

// CognitoIdentity client for calling unauthenticated API against an identity pool.
let config = try await CognitoIdentityClient.CognitoIdentityClientConfiguration(region: region)
config.addInterceptorProvider(GetHeadersBeforeTransmitProvider())
let config = try await CognitoIdentityClient.Config(
region: region,
httpInterceptorProviders: [GetHeadersBeforeTransmitProvider()]
)
cognitoIdentityUnauthenticatedCheckClient = CognitoIdentityClient(config: config)

// Create identity pool & save its identity pool ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ final class S3FlexibleChecksumsTests: S3XCTestCase {
}

func test_putGetObject_streamining_unsigned_chunked() async throws {
let config = try await S3Client.S3ClientConfiguration(region: region)
config.addInterceptorProvider(DisablePayloadSigningProvider())
let config = try await S3Client.S3ClientConfiguration(
region: region,
httpInterceptorProviders: [DisablePayloadSigningProvider()]
)
let customizedClient = S3Client(config: config)

let bufferedStream = BufferedStream(data: originalData, isClosed: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ import class SmithyStreams.BufferedStream

/// Tests toggle unsigned payload using S3.
class S3ToggleUnsignedPayloadTests: S3XCTestCase {
private var s3Config: S3Client.S3ClientConfiguration!

override func setUp() async throws {
try await super.setUp()
s3Config = try await S3Client.S3ClientConfiguration(region: region)
s3Config.authSchemes = [SigV4AuthScheme(requestUnsignedBody: true)]
}

class CheckUnsignedPayloadHeader<InputType, OutputType>: Interceptor {
typealias RequestType = HTTPRequest
Expand Down Expand Up @@ -68,7 +61,11 @@ class S3ToggleUnsignedPayloadTests: S3XCTestCase {
)

// Upload
s3Config.addInterceptorProvider(CheckUnsignedPayloadHeaderProvider())
let s3Config = try await S3Client.S3ClientConfiguration(
region: region,
authSchemes: [SigV4AuthScheme(requestUnsignedBody: true)],
httpInterceptorProviders: [CheckUnsignedPayloadHeaderProvider()]
)
let s3Client = S3Client(config: s3Config)
_ = try await s3Client.putObject(input: putObjectInput)

Expand All @@ -93,7 +90,11 @@ class S3ToggleUnsignedPayloadTests: S3XCTestCase {
)

// Upload
s3Config.addInterceptorProvider(CheckStreamingUnsignedPayloadHeaderProvider())
let s3Config = try await S3Client.S3ClientConfiguration(
region: region,
authSchemes: [SigV4AuthScheme(requestUnsignedBody: true)],
httpInterceptorProviders: [CheckStreamingUnsignedPayloadHeaderProvider()]
)
let s3Client = S3Client(config: s3Config)
_ = try await s3Client.putObject(input: putObjectInput)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class SigV4ASigningRegionTest: XCTestCase {
private var sigv4aConfig: S3Client.S3ClientConfiguration!

override func setUp() async throws {
sigv4aConfig = try await S3Client.S3ClientConfiguration(region: "dummy-region")
sigv4aConfig.authSchemes = [SigV4AAuthScheme()]
sigv4aConfig.httpClientEngine = ProtocolTestClient() // Mock HTTP client that doesn't actually send a request
sigv4aConfig.addInterceptorProvider(SigningRegionAssertInterceptorProvider())
sigv4aConfig = try await S3Client.Config(
region: "dummy-region",
httpClientEngine: ProtocolTestClient(),
authSchemes: [SigV4AAuthScheme()],
httpInterceptorProviders: [SigningRegionAssertInterceptorProvider()]
)
sigv4aClient = S3Client(config: sigv4aConfig)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,6 @@ extension ExampleClient {
return "\(ExampleClient.clientName) - \(region ?? "")"
}

public func addInterceptorProvider(_ provider: ClientRuntime.InterceptorProvider) {
self.interceptorProviders.append(provider)
}

public func addInterceptorProvider(_ provider: ClientRuntime.HttpInterceptorProvider) {
self.httpInterceptorProviders.append(provider)
}

}

public static func builder() -> ClientRuntime.ClientBuilder<ExampleClient> {
Expand Down
Loading