amzn / smoke-aws

AWS services integration for the Smoke Framework
Apache License 2.0
111 stars 19 forks source link

Swift 5 / NIO 2 support #17

Closed rex-remind101 closed 4 years ago

rex-remind101 commented 5 years ago

Support for Swift 5 / NIO 2?

fabianfett commented 5 years ago

@jpeddicord Hi, is there any timeline on this? How could one help?

dillan commented 5 years ago

There is a milestone setup for this a few months but it's currently empty. https://github.com/amzn/smoke-aws/milestone/1

However, I see some activity in https://github.com/amzn/smoke-aws/tree/swift_5_nio_2

@jpeddicord - as @fabianfett mentioned, "How could one help?"

tachyonics commented 5 years ago

Thanks guys!

I have started doing some work for this on this branch- https://github.com/amzn/smoke-aws/tree/swift_5_nio_2

I do need to update the milestone and writeup what we want to include in this release. It would be really great i you'd be able to take a look at this branch, let me know what you think, if you have any suggestions and we can go from there to work out what is needed to get this released.

dillan commented 5 years ago

@tachyonics I've been experimenting with the branch you mentioned, but I think I'm blocked by a dependency on Swift 5 and NIO 2 in smoke-aws-credentials. I've opened up a related ticket there.

https://github.com/amzn/smoke-aws-credentials/issues/10

tachyonics commented 5 years ago

I have added this branch for initial testing-

https://github.com/amzn/smoke-aws-credentials/tree/swift_5_nio_2

dillan commented 5 years ago

@tachyonics I've done some initial testing on the swift_5_nio_2 branch, and I've run into an issue. I get the following error when attempting to get a list of S3 Buckets:

2019-09-09T10:04:48-0500 info: credentialsProvider=AwsContainer 'AWS_CONTAINER_CREDENTIALS_RELATIVE_URI' environment variable not specified. Rotating credentials not available.
Failed with error: HTTPClientError(responseCode: 400, cause: S3Model.S3CodingError.unrecognizedError("SignatureDoesNotMatch", Optional("The request signature we calculated does not match the signature you provided. Check your key and signing method.")))

I'm running from within Xcode, and set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables on the scheme to values from my AWS account.

import SmokeAWSCredentials
import SmokeAWSCore
import S3Client
import S3Model
import SmokeHTTPClient
import Logging

struct InvocationReporting: SmokeAWSInvocationReporting {
    let logger: Logging.Logger = Logging.Logger(label: "SmokeTesting")
}

func fetchBucketList() {
    let reporting = InvocationReporting()
    let credentialProvider: CredentialsProvider! = AwsContainerRotatingCredentialsProvider.get()
    let client = AWSS3Client(credentialsProvider: credentialProvider, awsRegion: .us_east_1)
    do {
        let response = try client.listBucketsSync(reporting: reporting)
        print("succeeded: \(response)")
    } catch let error {
        print("Failed with error: \(error)")
    }
}
tachyonics commented 5 years ago

I think the likely issue is with these changes here - https://github.com/amzn/smoke-aws/commit/ab3ec2f02d81dd303e9c36ea5c6f50b424b7e904#diff-e0a327b5789fd31d4c402f164e655803

In Sources/SmokeAWSHttp/String+hmac.swift and Sources/SmokeAWSHttp/sha256Extensions.swift.

It should be fairly easy to debug by enabling both the old and new code and comparing to determine what is doing something different.

I have been able to reproduce the issue and the next step for me is to set up this comparison for debugging.

tachyonics commented 5 years ago

It looks like the offending line was here-

https://github.com/amzn/smoke-aws/commit/f50e2ae4ceb46f88b3298993032767f7b184f857#diff-e0a327b5789fd31d4c402f164e655803R29

I was able to verify the change using a request to DynamoDb which succeeded and returned data as expected. Would you be able to verify this fix with your calls to S3?

tachyonics commented 4 years ago

This has merged into mainline and released under the 2.x releases, starting with 2.30.7.