From 2b2856a07a3b2b8e8b8b6129d91b922bd94d78eb Mon Sep 17 00:00:00 2001 From: Sebastian Villena <97059974+ruisebas@users.noreply.github.com> Date: Fri, 26 Apr 2024 14:31:23 -0400 Subject: [PATCH] fix(Auth): Fixing the Gen2 json configuration used by the Authenticator (#3647) --------- Co-authored-by: Michael Law <1365977+lawmicha@users.noreply.github.com> --- .../Support/Helpers/ConfigurationHelper.swift | 13 ++++++------- .../Support/ConfigurationHelperTests.swift | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Helpers/ConfigurationHelper.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Helpers/ConfigurationHelper.swift index 42f647f95e..877571243c 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Helpers/ConfigurationHelper.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/Helpers/ConfigurationHelper.swift @@ -220,7 +220,7 @@ struct ConfigurationHelper { AuthPluginErrorConstants.configurationMissingError ) } - let userPoolConfig = try parseUserPoolData(config) + let userPoolConfig = parseUserPoolData(config) let identityPoolConfig = parseIdentityPoolData(config) return try createAuthConfiguration(userPoolConfig: userPoolConfig, @@ -281,11 +281,10 @@ struct ConfigurationHelper { "verificationMechanism": .array(verificationMechanisms)]) } - return JSONValue.object( - ["auth": .object( - ["plugins": .object( - ["awsCognitoAuthPlugin": .object( - ["Auth": .object( - ["Default": authConfigObject])])])])]) + return JSONValue.object([ + "Auth": .object([ + "Default": authConfigObject + ]) + ]) } } diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/ConfigurationHelperTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/ConfigurationHelperTests.swift index 812cb05b7c..d2f5f732ff 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/ConfigurationHelperTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Support/ConfigurationHelperTests.swift @@ -246,7 +246,7 @@ final class ConfigurationHelperTests: XCTestCase { ])) let json = ConfigurationHelper.createUserPoolJsonConfiguration(config) - guard let authConfig = json.auth?.plugins?.awsCognitoAuthPlugin?.Auth?.Default else { + guard let authConfig = json.Auth?.Default else { XCTFail("Could not retrieve auth configuration from json") return }