Skip to content

Commit

Permalink
Fix tests after replacing of httpClientProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Apr 10, 2024
1 parent 6fafcc5 commit d7b92b1
Show file tree
Hide file tree
Showing 17 changed files with 19 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Tests/SotoTests/AWSRequestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extension AWSHTTPBody {

/// Tests to check the formatting of various AWSHTTPRequest bodies
class AWSHTTPRequestTests: XCTestCase {
static let client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
static let client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)

/// test AWSHTTPRequest body is expected string
func testRequestedBody(expected: String, result: AWSHTTPRequest) throws {
Expand Down
1 change: 0 additions & 1 deletion Tests/SotoTests/Services/APIGateway/APIGatewayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class APIGatewayTests: XCTestCase {
Self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
httpClientProvider: .createNew,
logger: TestEnvironment.logger
)
Self.apiGateway = APIGateway(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class APIGatewayV2Tests: XCTestCase {
Self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
httpClientProvider: .createNew,
logger: TestEnvironment.logger
)
Self.apiGatewayV2 = ApiGatewayV2(
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/CloudTrail/CloudTrailTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CloudTrailTests: XCTestCase {
static var cloudTrail: CloudTrail!

override class func setUp() {
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.cloudTrail = CloudTrail(
client: CloudTrailTests.client,
region: .euwest1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/DynamoDB/DynamoDBTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DynamoDBTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.dynamoDB = DynamoDB(
client: DynamoDBTests.client,
region: .useast1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/EC2/EC2Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EC2Tests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.ec2 = EC2(
client: EC2Tests.client,
region: .useast1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/Glacier/GlacierTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class GlacierTests: XCTestCase {
static var glacier: Glacier!

override class func setUp() {
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.glacier = Glacier(
client: GlacierTests.client,
region: .euwest1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/IAM/IAMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IAMTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.iam = IAM(
client: IAMTests.client,
endpoint: TestEnvironment.getEndPoint(environment: "LOCALSTACK_ENDPOINT")
Expand Down
3 changes: 1 addition & 2 deletions Tests/SotoTests/Services/Lambda/LambdaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ class LambdaTests: XCTestCase {

Self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
httpClientProvider: .createNew
middleware: TestEnvironment.middlewares
)
Self.lambda = Lambda(
client: LambdaTests.client,
Expand Down
9 changes: 3 additions & 6 deletions Tests/SotoTests/Services/S3/S3ExtensionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,7 @@ extension S3Tests {
credentialProvider: .static(
accessKeyId: "AKIAIOSFODNN7EXAMPLE",
secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
),
httpClientProvider: .createNew
)
)
let s3 = S3(client: client, region: .useast1)

Expand Down Expand Up @@ -455,8 +454,7 @@ extension S3Tests {
credentialProvider: .static(
accessKeyId: "AKIAIOSFODNN7EXAMPLE",
secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
),
httpClientProvider: .createNew
)
)
let s3 = S3(client: client, region: .useast1)

Expand Down Expand Up @@ -485,8 +483,7 @@ extension S3Tests {
credentialProvider: .static(
accessKeyId: "AKIAIOSFODNN7EXAMPLE",
secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
),
httpClientProvider: .createNew
)
)
let s3 = S3(client: client, region: .useast1)

Expand Down
12 changes: 3 additions & 9 deletions Tests/SotoTests/Services/S3/S3Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import XCTest
@testable import SotoS3Control

class S3Tests: XCTestCase {
static var eventLoopGroup: EventLoopGroup!
static var client: AWSClient!
static var s3: S3!
static var randomBytes: ByteBuffer!
Expand All @@ -35,11 +34,9 @@ class S3Tests: XCTestCase {
print("Connecting to AWS")
}

Self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
Self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
httpClientProvider: .createNewWithEventLoopGroup(Self.eventLoopGroup)
middleware: TestEnvironment.middlewares
)
Self.s3 = S3(
client: Self.client,
Expand All @@ -51,7 +48,6 @@ class S3Tests: XCTestCase {

override class func tearDown() {
XCTAssertNoThrow(try Self.client.syncShutdown())
XCTAssertNoThrow(try Self.eventLoopGroup.syncShutdownGracefully())
}

static func createRandomBuffer(size: Int) -> ByteBuffer {
Expand Down Expand Up @@ -407,8 +403,6 @@ class S3Tests: XCTestCase {
try XCTSkipIf(TestEnvironment.isUsingLocalstack)

let name = TestEnvironment.generateResourceName()
let httpClient = HTTPClient(eventLoopGroupProvider: .singleton)
defer { XCTAssertNoThrow(try httpClient.syncShutdown()) }
let s3Url = URL(string: "https://\(name).s3.us-east-1.amazonaws.com/\(name)!=%25+/(*)_.txt")!

try await testBucket(name) { _ in
Expand All @@ -417,14 +411,14 @@ class S3Tests: XCTestCase {
var request = HTTPClientRequest(url: putURL.absoluteString)
request.method = .PUT
request.body = .bytes(byteBuffer)
let response = try await httpClient.execute(request, timeout: .minutes(1))
let response = try await HTTPClient.shared.execute(request, timeout: .minutes(1))
XCTAssertEqual(response.status, .ok)

let listResponse = try await Self.s3.listObjectsV2(.init(bucket: name))
XCTAssertEqual(listResponse.contents?.first?.key, "\(name)!=%+/(*)_.txt")

let getURL = try await Self.s3.signURL(url: s3Url, httpMethod: .GET, expires: .minutes(5))
let getResponse = try await httpClient.execute(.init(url: getURL.absoluteString), timeout: .minutes(1))
let getResponse = try await HTTPClient.shared.execute(.init(url: getURL.absoluteString), timeout: .minutes(1))

let getBuffer = try await getResponse.body.collect(upTo: .max)
XCTAssertEqual(response.status, .ok)
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/SES/SESTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SESTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.ses = SES(
client: Self.client,
region: .useast1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/SNS/SNSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SNSTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.sns = SNS(
client: SNSTests.client,
region: .useast1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/SQS/SQSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SQSTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.sqs = SQS(
client: SQSTests.client,
region: .useast1,
Expand Down
2 changes: 1 addition & 1 deletion Tests/SotoTests/Services/SSM/SSMTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SSMTests: XCTestCase {
print("Connecting to AWS")
}

Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares, httpClientProvider: .createNew)
Self.client = AWSClient(credentialProvider: TestEnvironment.credentialProvider, middleware: TestEnvironment.middlewares)
Self.ssm = SSM(
client: SSMTests.client,
region: .useast1,
Expand Down
6 changes: 2 additions & 4 deletions Tests/SotoTests/Services/STS/STSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class STSTests: XCTestCase {
Self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
httpClientProvider: .createNew,
logger: Logger(label: "Soto")
)
Self.sts = STS(
Expand All @@ -55,7 +54,7 @@ class STSTests: XCTestCase {
func testSTSCredentialProviderShutdown() async throws {
let request = STS.AssumeRoleRequest(roleArn: "arn:aws:iam::000000000000:role/Admin", roleSessionName: "test-session")
let credentialProvider = CredentialProviderFactory.stsAssumeRole(request: request, region: .euwest2)
let client = AWSClient(credentialProvider: credentialProvider, httpClientProvider: .createNew, logger: TestEnvironment.logger)
let client = AWSClient(credentialProvider: credentialProvider, logger: TestEnvironment.logger)
try await client.shutdown()
}

Expand All @@ -69,7 +68,7 @@ class STSTests: XCTestCase {
}
return request
}
let client = AWSClient(credentialProvider: credentialProvider, httpClientProvider: .createNew, logger: TestEnvironment.logger)
let client = AWSClient(credentialProvider: credentialProvider, logger: TestEnvironment.logger)
_ = try? await client.credentialProvider.getCredential(logger: TestEnvironment.logger)
try await client.shutdown()
returnedRequest.withLockedValue { value in
Expand Down Expand Up @@ -104,7 +103,6 @@ class STSTests: XCTestCase {
credentialProvider: TestEnvironment.credentialProvider,
region: .useast1
),
httpClientProvider: .createNew,
logger: Logger(label: "Soto")
)
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class TimestreamWriteTests: XCTestCase {
self.client = AWSClient(
credentialProvider: TestEnvironment.credentialProvider,
middleware: TestEnvironment.middlewares,
httpClientProvider: .createNew,
logger: Logger(label: "Soto")
)
self.ts = TimestreamWrite(
Expand Down

0 comments on commit d7b92b1

Please sign in to comment.