Skip to content

Commit

Permalink
fix: remaining integration tests for sdk update (#3283)
Browse files Browse the repository at this point in the history
  • Loading branch information
atierian authored Oct 9, 2023
1 parent 6322946 commit 6117f76
Show file tree
Hide file tree
Showing 19 changed files with 175 additions and 129 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/integ_test_auth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ permissions:

jobs:
auth-integration-test-iOS:
runs-on: macos-12
runs-on: macos-13
environment: IntegrationTest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
Expand All @@ -32,6 +32,8 @@ jobs:
with:
project_path: ./AmplifyPlugins/Auth/Tests/AuthHostApp/
scheme: AuthIntegrationTests
destination: 'platform=iOS Simulator,name=iPhone 14,OS=latest'
xcode_path: '/Applications/Xcode_14.3.app'

auth-integration-test-tvOS:
runs-on: macos-13
Expand Down Expand Up @@ -90,7 +92,7 @@ jobs:
xcode_path: '/Applications/Xcode_14.3.app'

auth-ui-integration-test-iOS:
runs-on: macos-12
runs-on: macos-13
environment: IntegrationTest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
Expand All @@ -113,3 +115,5 @@ jobs:
with:
project_path: ./AmplifyPlugins/Auth/Tests/AuthHostedUIApp/
scheme: AuthHostedUIApp
destination: 'platform=iOS Simulator,name=iPhone 14,OS=latest'
xcode_path: '/Applications/Xcode_14.3.app'
4 changes: 3 additions & 1 deletion .github/workflows/integ_test_predictions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
predictions-integration-test-iOS:
continue-on-error: true
timeout-minutes: 30
runs-on: macos-12
runs-on: macos-13
environment: IntegrationTest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
Expand All @@ -37,6 +37,8 @@ jobs:
with:
project_path: ./AmplifyPlugins/Predictions/Tests/PredictionsHostApp
scheme: AWSPredictionsPluginIntegrationTests
destination: 'platform=iOS Simulator,name=iPhone 14,OS=latest'
xcode_path: '/Applications/Xcode_14.3.app'

predictions-integration-test-tvOS:
continue-on-error: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-crt-swift",
"state" : {
"revision" : "6feec6c3787877807aa9a00fad09591b96752376",
"version" : "0.6.1"
"revision" : "997904873945e074aaf5c51ea968d9a84684525a",
"version" : "0.13.0"
}
},
{
"identity" : "aws-sdk-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-sdk-swift.git",
"state" : {
"revision" : "24bae88a2391fe75da8a940a544d1ef6441f5321",
"version" : "0.13.0"
"revision" : "ace826dbfe96e7e3103fe7f45f815b8a590bcf21",
"version" : "0.26.0"
}
},
{
Expand All @@ -57,10 +57,10 @@
{
"identity" : "smithy-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/smithy-swift",
"location" : "https://github.com/smithy-lang/smithy-swift",
"state" : {
"revision" : "7b28da158d92cd06a3549140d43b8fbcf64a94a6",
"version" : "0.15.0"
"revision" : "eed3f3d8e5aa704fcd60bb227b0fc89bf3328c42",
"version" : "0.30.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/MaxDesiatov/XMLCoder.git",
"state" : {
"revision" : "b1e944cbd0ef33787b13f639a5418d55b3bed501",
"version" : "0.17.1"
"revision" : "80b4a1646399b8e4e0ce80711653476a85bd5e37",
"version" : "0.17.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-crt-swift.git",
"state" : {
"revision" : "6feec6c3787877807aa9a00fad09591b96752376",
"version" : "0.6.1"
"revision" : "997904873945e074aaf5c51ea968d9a84684525a",
"version" : "0.13.0"
}
},
{
"identity" : "aws-sdk-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/aws-sdk-swift.git",
"state" : {
"revision" : "24bae88a2391fe75da8a940a544d1ef6441f5321",
"version" : "0.13.0"
"revision" : "ace826dbfe96e7e3103fe7f45f815b8a590bcf21",
"version" : "0.26.0"
}
},
{
Expand All @@ -57,10 +57,10 @@
{
"identity" : "smithy-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/awslabs/smithy-swift.git",
"location" : "https://github.com/smithy-lang/smithy-swift",
"state" : {
"revision" : "7b28da158d92cd06a3549140d43b8fbcf64a94a6",
"version" : "0.15.0"
"revision" : "eed3f3d8e5aa704fcd60bb227b0fc89bf3328c42",
"version" : "0.30.0"
}
},
{
Expand Down Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/MaxDesiatov/XMLCoder.git",
"state" : {
"revision" : "c438dad94f6a243b411b70a4b4bac54595064808",
"version" : "0.15.0"
"revision" : "80b4a1646399b8e4e0ce80711653476a85bd5e37",
"version" : "0.17.0"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ class AuthDeleteUserTests: AWSAuthBaseTest {
do {
_ = try await AuthSignInHelper.signInUser(username: username, password: password)
XCTFail("signIn after account deletion should fail")
} catch {
guard case AuthError.service(_, _, let underlyingError) = error else {
XCTFail("Should produce service error instead of \(String(describing: error))")
return
}
guard case .userNotFound = (underlyingError as? AWSCognitoAuthError) else {
XCTFail("Underlying error should be userNotFound instead of \(String(describing: error))")
return
} catch let error as AuthError {
switch error {
case .service(_, _, let underlying):
XCTAssert(
[.userNotFound, .limitExceeded].contains(underlying as? AWSCognitoAuthError)
)
default:
XCTFail("""
Should produce .service error with underlyingError of .userNotFound || .limitExceed
Received: \(error)
""")

}
} catch {
XCTFail("Expected AuthError - received: \(error)")
}

// Check if the auth session is signed out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ class AuthForgetDeviceTests: AWSAuthBaseTest {
let username = "integTest\(UUID().uuidString)"
let password = "P123@\(UUID().uuidString)"

let signInExpectation = asyncExpectation(description: "SignIn event should be fired")
let signInExpectation = expectation(description: "SignIn event should be fired")

unsubscribeToken = Amplify.Hub.listen(to: .auth) { payload in
switch payload.eventName {
case HubPayload.EventName.Auth.signedIn:
Task {
await signInExpectation.fulfill()
}
signInExpectation.fulfill()
default:
break
}
Expand All @@ -55,7 +53,7 @@ class AuthForgetDeviceTests: AWSAuthBaseTest {
username: username,
password: password,
email: defaultTestEmail)
await waitForExpectations([signInExpectation], timeout: networkTimeout)
await fulfillment(of: [signInExpectation], timeout: networkTimeout)

_ = try await Amplify.Auth.rememberDevice()
_ = try await Amplify.Auth.forgetDevice()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,20 @@ class AuthSRPSignInTests: AWSAuthBaseTest {
do {
_ = try await Amplify.Auth.signIn(username: "username-doesnot-exist", password: "password")
XCTFail("SignIn with unknown user should not succeed")
} catch let error as AuthError {
let underlyingError = error.underlyingError as? AWSCognitoAuthError
switch underlyingError {
case .userNotFound, .limitExceeded: break
default:
XCTFail(
"""
Expected AWSCognitoAuthError.userNotFound || AWSCognitoAuthError.limitExceed
Recevied: \(error)
"""
)
}
} catch {
guard let authError = error as? AuthError, let cognitoError = authError.underlyingError as? AWSCognitoAuthError,
case .userNotFound = cognitoError
else {
XCTFail("Should return userNotFound error")
return
}
XCTFail("Expected `AuthError` - received: \(error)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,20 @@ class AuthResendSignUpCodeTests: AWSAuthBaseTest {
do {
_ = try await Amplify.Auth.resendSignUpCode(for: "user-non-exists")
XCTFail("resendSignUpCode with non existing user should not return result")
} catch {
guard let authError = error as? AuthError, let cognitoError = authError.underlyingError as? AWSCognitoAuthError,
case .userNotFound = cognitoError else {
print(error)
XCTFail("Should return userNotFound")
return
} catch let error as AuthError {
let underlyingError = error.underlyingError as? AWSCognitoAuthError
switch underlyingError {
case .userNotFound, .limitExceeded: break
default:
XCTFail(
"""
Expected AWSCognitoAuthError.userNotFound || AWSCognitoAuthError.limitExceed
Recevied: \(error)
"""
)
}
} catch {
XCTFail("Expected `AuthError` - received: \(error)")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AuthSignUpTests: AWSAuthBaseTest {
signUpExpectation.fulfill()
}
}
await waitForExpectations(timeout: 2)
await fulfillment(of: [signUpExpectation], timeout: 5, enforceOrder: false)
}

// /// Test if user registration is successful.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "B41080DD291ACF7E00297354"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public class AmplifyAWSServiceConfiguration {
public static let platformName = "amplify-swift"

public static let userAgentLib: String = "lib/\(platformName)#\(amplifyVersion)"

public static let userAgentOS: String = "os/\(DeviceInfo.current.operatingSystem.name)#\(DeviceInfo.current.operatingSystem.version)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CoreMLPredictionsPluginIntegrationTest: AWSPredictionsPluginTestBase {
in: url
)

XCTAssertEqual(result.labels.count, 0, String(describing: result))
XCTAssertEqual(result.labels.count, 2, String(describing: result))
XCTAssertNil(result.unsafeContent, String(describing: result))
}

Expand Down
Loading

0 comments on commit 6117f76

Please sign in to comment.