From 6117f76af085ac0f6080cb8b08cf83abc30d44b8 Mon Sep 17 00:00:00 2001 From: Ian Saultz <52051793+atierian@users.noreply.github.com> Date: Mon, 9 Oct 2023 14:57:35 -0400 Subject: [PATCH] fix: remaining integration tests for sdk update (#3283) --- .github/workflows/integ_test_auth.yml | 8 +- .github/workflows/integ_test_predictions.yml | 4 +- .../xcshareddata/swiftpm/Package.resolved | 18 ++-- .../xcshareddata/swiftpm/Package.resolved | 18 ++-- .../AuthDeleteUserTests.swift | 22 +++-- .../DeviceTests/AuthForgetDeviceTests.swift | 8 +- .../SignInTests/AuthSRPSignInTests.swift | 19 ++-- .../AuthResendSignUpCodeTests.swift | 19 ++-- .../SignUpTests/AuthSignUpTests.swift | 2 +- .../xcschemes/AuthHostedUIApp.xcscheme | 3 +- .../AmplifyAWSServiceConfiguration.swift | 2 + ...reMLPredictionsPluginIntegrationTest.swift | 2 +- .../project.pbxproj | 86 +++++++++++++++++++ .../PredictionsHostApp/ContentView.swift | 66 -------------- .../Service/Storage/AWSS3StorageService.swift | 2 +- ...S3StoragePluginBasicIntegrationTests.swift | 4 +- .../AWSS3StoragePluginTestBase.swift | 1 + .../xcshareddata/swiftpm/Package.resolved | 18 ++-- .../xcschemes/StorageHostApp.xcscheme | 2 +- 19 files changed, 175 insertions(+), 129 deletions(-) diff --git a/.github/workflows/integ_test_auth.yml b/.github/workflows/integ_test_auth.yml index 1a76717c21..b628e68abe 100644 --- a/.github/workflows/integ_test_auth.yml +++ b/.github/workflows/integ_test_auth.yml @@ -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 @@ -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 @@ -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 @@ -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' diff --git a/.github/workflows/integ_test_predictions.yml b/.github/workflows/integ_test_predictions.yml index d0a9b8ac3d..58be80d7e8 100644 --- a/.github/workflows/integ_test_predictions.yml +++ b/.github/workflows/integ_test_predictions.yml @@ -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 @@ -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 diff --git a/AmplifyPlugins/Analytics/Tests/AnalyticsHostApp/AnalyticsHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AmplifyPlugins/Analytics/Tests/AnalyticsHostApp/AnalyticsHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2ef4d7901c..6203f7a6b6 100644 --- a/AmplifyPlugins/Analytics/Tests/AnalyticsHostApp/AnalyticsHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AmplifyPlugins/Analytics/Tests/AnalyticsHostApp/AnalyticsHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-crt-swift", "state" : { - "revision" : "6feec6c3787877807aa9a00fad09591b96752376", - "version" : "0.6.1" + "revision" : "997904873945e074aaf5c51ea968d9a84684525a", + "version" : "0.13.0" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-sdk-swift.git", "state" : { - "revision" : "24bae88a2391fe75da8a940a544d1ef6441f5321", - "version" : "0.13.0" + "revision" : "ace826dbfe96e7e3103fe7f45f815b8a590bcf21", + "version" : "0.26.0" } }, { @@ -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" } }, { @@ -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" } } ], diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index a8b70a2420..574dbfb6b0 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -23,8 +23,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-crt-swift.git", "state" : { - "revision" : "6feec6c3787877807aa9a00fad09591b96752376", - "version" : "0.6.1" + "revision" : "997904873945e074aaf5c51ea968d9a84684525a", + "version" : "0.13.0" } }, { @@ -32,8 +32,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-sdk-swift.git", "state" : { - "revision" : "24bae88a2391fe75da8a940a544d1ef6441f5321", - "version" : "0.13.0" + "revision" : "ace826dbfe96e7e3103fe7f45f815b8a590bcf21", + "version" : "0.26.0" } }, { @@ -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" } }, { @@ -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" } } ], diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/AuthDeleteUserTests/AuthDeleteUserTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/AuthDeleteUserTests/AuthDeleteUserTests.swift index a77f580fa9..5304a5b5e1 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/AuthDeleteUserTests/AuthDeleteUserTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/AuthDeleteUserTests/AuthDeleteUserTests.swift @@ -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 diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/DeviceTests/AuthForgetDeviceTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/DeviceTests/AuthForgetDeviceTests.swift index 3a2527539a..b1df2d456a 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/DeviceTests/AuthForgetDeviceTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/DeviceTests/AuthForgetDeviceTests.swift @@ -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 } @@ -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() diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/AuthSRPSignInTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/AuthSRPSignInTests.swift index 0c35eca521..3728939c28 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/AuthSRPSignInTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/AuthSRPSignInTests.swift @@ -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)") } } diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthResendSignUpCodeTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthResendSignUpCodeTests.swift index 53e6865176..05f8161581 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthResendSignUpCodeTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthResendSignUpCodeTests.swift @@ -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)") } } } diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthSignUpTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthSignUpTests.swift index e637b596c9..7f694195d5 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthSignUpTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignUpTests/AuthSignUpTests.swift @@ -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. diff --git a/AmplifyPlugins/Auth/Tests/AuthHostedUIApp/AuthHostedUIApp.xcodeproj/xcshareddata/xcschemes/AuthHostedUIApp.xcscheme b/AmplifyPlugins/Auth/Tests/AuthHostedUIApp/AuthHostedUIApp.xcodeproj/xcshareddata/xcschemes/AuthHostedUIApp.xcscheme index b919f7e960..bed1ed8b62 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostedUIApp/AuthHostedUIApp.xcodeproj/xcshareddata/xcschemes/AuthHostedUIApp.xcscheme +++ b/AmplifyPlugins/Auth/Tests/AuthHostedUIApp/AuthHostedUIApp.xcodeproj/xcshareddata/xcschemes/AuthHostedUIApp.xcscheme @@ -30,8 +30,7 @@ shouldAutocreateTestPlan = "YES"> + skipped = "NO">