From 96cdb46edb4daee29ebd9f89655a67f09f96344e Mon Sep 17 00:00:00 2001 From: Harshdeep Singh <6162866+harsh62@users.noreply.github.com> Date: Sat, 23 Nov 2024 12:47:34 -0500 Subject: [PATCH] chore: running passwordless integration tests on GEN2 backend --- .../AuthHostApp.xcodeproj/project.pbxproj | 14 +++++++++++++- .../PasswordlessAutoSignInTests.swift | 5 ++++- .../PasswordlessConfirmSignUpTests.swift | 5 ++++- .../PasswordlessSignInTests.swift | 5 ++++- .../PasswordlessSignUpTests.swift | 5 ++++- .../AuthWebAuthnApp/AuthWebAuthnAppApp.swift | 14 +++----------- 6 files changed, 32 insertions(+), 16 deletions(-) rename AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/{SignInTests => PasswordlessTests}/PasswordlessSignInTests.swift (99%) diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.pbxproj b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.pbxproj index 3a1d821654..89765429fc 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.pbxproj +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthHostApp.xcodeproj/project.pbxproj @@ -61,6 +61,12 @@ 485CB5C027B61F1E006CCEC7 /* SignedOutAuthSessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 485CB5BC27B61F1D006CCEC7 /* SignedOutAuthSessionTests.swift */; }; 485CB5C127B61F1E006CCEC7 /* AuthSignOutTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 485CB5BD27B61F1D006CCEC7 /* AuthSignOutTests.swift */; }; 485CB5C227B61F1E006CCEC7 /* AuthSRPSignInTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 485CB5BE27B61F1D006CCEC7 /* AuthSRPSignInTests.swift */; }; + 486D622F2CF23FA6001FD075 /* PasswordlessSignUpTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979D8A572CE283CA00E9B28F /* PasswordlessSignUpTests.swift */; }; + 486D62302CF23FA6001FD075 /* PasswordlessConfirmSignUpTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979D8A592CE283DD00E9B28F /* PasswordlessConfirmSignUpTests.swift */; }; + 486D62312CF23FA6001FD075 /* PasswordlessAutoSignInTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979D8A5B2CE283E900E9B28F /* PasswordlessAutoSignInTests.swift */; }; + 486D62322CF23FA6001FD075 /* PasswordlessAutoSignInTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979D8A5B2CE283E900E9B28F /* PasswordlessAutoSignInTests.swift */; }; + 486D62332CF23FA6001FD075 /* PasswordlessConfirmSignUpTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979D8A592CE283DD00E9B28F /* PasswordlessConfirmSignUpTests.swift */; }; + 486D62342CF23FA6001FD075 /* PasswordlessSignUpTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 979D8A572CE283CA00E9B28F /* PasswordlessSignUpTests.swift */; }; 487C40232CACF303009CF221 /* EmailMFAWithAllMFATypesRequiredTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487C40222CACF2FD009CF221 /* EmailMFAWithAllMFATypesRequiredTests.swift */; }; 487C40242CACF303009CF221 /* EmailMFAWithAllMFATypesRequiredTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487C40222CACF2FD009CF221 /* EmailMFAWithAllMFATypesRequiredTests.swift */; }; 487C40252CACF303009CF221 /* EmailMFAWithAllMFATypesRequiredTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487C40222CACF2FD009CF221 /* EmailMFAWithAllMFATypesRequiredTests.swift */; }; @@ -424,7 +430,6 @@ 485CB5C327B61F4A006CCEC7 /* SignInTests */ = { isa = PBXGroup; children = ( - 48DEF5992CDB1FF500BDB995 /* PasswordlessSignInTests.swift */, 485CB5BE27B61F1D006CCEC7 /* AuthSRPSignInTests.swift */, 4821B2F328737130000EC1D7 /* AuthCustomSignInTests.swift */, ); @@ -515,6 +520,7 @@ 979D8A572CE283CA00E9B28F /* PasswordlessSignUpTests.swift */, 979D8A592CE283DD00E9B28F /* PasswordlessConfirmSignUpTests.swift */, 979D8A5B2CE283E900E9B28F /* PasswordlessAutoSignInTests.swift */, + 48DEF5992CDB1FF500BDB995 /* PasswordlessSignInTests.swift */, ); path = PasswordlessTests; sourceTree = ""; @@ -852,6 +858,9 @@ buildActionMask = 2147483647; files = ( 21F762A52BD6B1AA0048845A /* AuthSessionHelper.swift in Sources */, + 486D62322CF23FA6001FD075 /* PasswordlessAutoSignInTests.swift in Sources */, + 486D62332CF23FA6001FD075 /* PasswordlessConfirmSignUpTests.swift in Sources */, + 486D62342CF23FA6001FD075 /* PasswordlessSignUpTests.swift in Sources */, 21F762A62BD6B1AA0048845A /* AsyncTesting.swift in Sources */, 21F762A72BD6B1AA0048845A /* AuthSRPSignInTests.swift in Sources */, 21F762A82BD6B1AA0048845A /* AuthForgetDeviceTests.swift in Sources */, @@ -964,6 +973,9 @@ 681B76A92A3CBBAE004B59D9 /* AuthFetchDeviceTests.swift in Sources */, 48BCE8922A5456460012C3CD /* TOTPSetupWhenAuthenticatedTests.swift in Sources */, 48BCE8962A5456600012C3CD /* TOTPHelper.swift in Sources */, + 486D622F2CF23FA6001FD075 /* PasswordlessSignUpTests.swift in Sources */, + 486D62302CF23FA6001FD075 /* PasswordlessConfirmSignUpTests.swift in Sources */, + 486D62312CF23FA6001FD075 /* PasswordlessAutoSignInTests.swift in Sources */, 681B76AA2A3CBBAE004B59D9 /* AsyncExpectation.swift in Sources */, 48BCE8932A54564C0012C3CD /* TOTPSetupWhenUnauthenticatedTests.swift in Sources */, 681B76AB2A3CBBAE004B59D9 /* GetCurrentUserTests.swift in Sources */, diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessAutoSignInTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessAutoSignInTests.swift index 03b75a1f0b..7097032b83 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessAutoSignInTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessAutoSignInTests.swift @@ -13,8 +13,11 @@ import AWSAPIPlugin class PasswordlessAutoSignInTests: AWSAuthBaseTest { override func setUp() async throws { + // Only run these tests with Gen2 configuration + onlyUseGen2Configuration = true + // Use a custom configuration these tests - amplifyConfigurationFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplifyconfiguration" + amplifyOutputsFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplify_outputs" // Add API plugin to Amplify let awsApiPlugin = AWSAPIPlugin() diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessConfirmSignUpTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessConfirmSignUpTests.swift index 09662e3523..aacbe758a2 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessConfirmSignUpTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessConfirmSignUpTests.swift @@ -13,8 +13,11 @@ import AWSAPIPlugin class PasswordlessConfirmSignUpTests: AWSAuthBaseTest { override func setUp() async throws { + // Only run these tests with Gen2 configuration + onlyUseGen2Configuration = true + // Use a custom configuration these tests - amplifyConfigurationFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplifyconfiguration" + amplifyOutputsFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplify_outputs" // Add API plugin to Amplify let awsApiPlugin = AWSAPIPlugin() diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/PasswordlessSignInTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignInTests.swift similarity index 99% rename from AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/PasswordlessSignInTests.swift rename to AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignInTests.swift index 30876f535c..6cb45a49e1 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/SignInTests/PasswordlessSignInTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignInTests.swift @@ -17,8 +17,11 @@ class PasswordlessSignInTests: AWSAuthBaseTest { override func setUp() async throws { + // Only run these tests with Gen2 configuration + onlyUseGen2Configuration = true + // Use a custom configuration these tests - amplifyConfigurationFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplifyconfiguration" + amplifyOutputsFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplify_outputs" // Add API plugin to Amplify let awsApiPlugin = AWSAPIPlugin() diff --git a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignUpTests.swift b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignUpTests.swift index 0b14bbd025..76c65e8e72 100644 --- a/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignUpTests.swift +++ b/AmplifyPlugins/Auth/Tests/AuthHostApp/AuthIntegrationTests/PasswordlessTests/PasswordlessSignUpTests.swift @@ -13,8 +13,11 @@ import AWSAPIPlugin class PasswordlessSignUpTests: AWSAuthBaseTest { override func setUp() async throws { + // Only run these tests with Gen2 configuration + onlyUseGen2Configuration = true + // Use a custom configuration these tests - amplifyConfigurationFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplifyconfiguration" + amplifyOutputsFile = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplify_outputs" // Add API plugin to Amplify let awsApiPlugin = AWSAPIPlugin() diff --git a/AmplifyPlugins/Auth/Tests/AuthWebAuthnApp/AuthWebAuthnApp/AuthWebAuthnAppApp.swift b/AmplifyPlugins/Auth/Tests/AuthWebAuthnApp/AuthWebAuthnApp/AuthWebAuthnAppApp.swift index c9fe60a646..795b463849 100644 --- a/AmplifyPlugins/Auth/Tests/AuthWebAuthnApp/AuthWebAuthnApp/AuthWebAuthnAppApp.swift +++ b/AmplifyPlugins/Auth/Tests/AuthWebAuthnApp/AuthWebAuthnApp/AuthWebAuthnAppApp.swift @@ -11,20 +11,15 @@ import SwiftUI @main struct AuthWebAuthnAppApp: App { - private let amplifyConfigurationFilePath = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplifyconfiguration" + private let amplifyOutputsFilePath = "testconfiguration/AWSCognitoPluginPasswordlessIntegrationTests-amplify_outputs" init() { do { try Amplify.add(plugin: AWSCognitoAuthPlugin()) - if useGen2Configuration { - let data = try TestConfigHelper.retrieve(forResource: amplifyOutputsFilePath) - try Amplify.configure(with: .data(data)) - } else { - let config = try TestConfigHelper.retrieveAmplifyConfiguration(forResource: amplifyConfigurationFilePath) - try Amplify.configure(config) - } + let data = try TestConfigHelper.retrieve(forResource: amplifyOutputsFilePath) + try Amplify.configure(with: .data(data)) print("Amplify configured!") } catch { print("Failed to init Amplify", error) @@ -37,7 +32,4 @@ struct AuthWebAuthnAppApp: App { } } - private var useGen2Configuration: Bool { - ProcessInfo.processInfo.arguments.contains("GEN2") - } }