From a0a657c963148dad42a6055cb8752bc19c67c778 Mon Sep 17 00:00:00 2001 From: akshbhu <39866697+akshbhu@users.noreply.github.com> Date: Sun, 7 Nov 2021 16:30:42 -0800 Subject: [PATCH] fix: auth issue in export tests (#8710) * fix: auth issue in export tests * fix: address comments --- packages/amplify-category-auth/src/index.js | 5 +++-- .../auth-inputs-manager/auth-input-state.ts | 7 +++++++ packages/amplify-e2e-core/src/export/index.ts | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/amplify-category-auth/src/index.js b/packages/amplify-category-auth/src/index.js index 26a970529f4..3e6649684ed 100644 --- a/packages/amplify-category-auth/src/index.js +++ b/packages/amplify-category-auth/src/index.js @@ -106,8 +106,9 @@ async function externalAuthEnable(context, externalCategory, resourceName, requi currentAuthName = await getAuthResourceName(context); // check for migration when auth has been enabled await checkAuthResourceMigration(context, currentAuthName); - const cliState = new AuthInputState(currentAuthName); - currentAuthParams = await cliState.loadResourceParameters(context, cliState.getCLIInputPayload()); + const { provider } = serviceMetadata.Cognito; + const providerPlugin = context.amplify.getPluginInstance(context, provider); + currentAuthParams = providerPlugin.loadResourceParameters(context, 'auth', currentAuthName); if (requirements.authSelections.includes('identityPoolOnly') && currentAuthParams.userPoolName) { requirements.authSelections = 'identityPoolAndUserPool'; diff --git a/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-inputs-manager/auth-input-state.ts b/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-inputs-manager/auth-input-state.ts index 5818f5d69fe..82ed4b152c4 100644 --- a/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-inputs-manager/auth-input-state.ts +++ b/packages/amplify-category-auth/src/provider-utils/awscloudformation/auth-inputs-manager/auth-input-state.ts @@ -46,6 +46,13 @@ export class AuthInputState extends CategoryInputState { } public async saveCLIInputPayload(cliInputs: CognitoCLIInputs): Promise { + // converting stringified triggers to object + if (!_.isEmpty(cliInputs.cognitoConfig.triggers)) { + cliInputs.cognitoConfig.triggers = + typeof cliInputs.cognitoConfig.triggers === 'string' + ? JSONUtilities.parse(cliInputs.cognitoConfig.triggers) + : cliInputs.cognitoConfig.triggers; + } if (await this.isCLIInputsValid(cliInputs)) { fs.ensureDirSync(path.join(pathManager.getBackendDirPath(), this.#category, this._resourceName)); JSONUtilities.writeJson(this.#cliInputsFilePath, cliInputs); diff --git a/packages/amplify-e2e-core/src/export/index.ts b/packages/amplify-e2e-core/src/export/index.ts index 8799e8ad2a8..8dc474adc7e 100644 --- a/packages/amplify-e2e-core/src/export/index.ts +++ b/packages/amplify-e2e-core/src/export/index.ts @@ -22,7 +22,7 @@ export function exportPullBackend(cwd: string, settings: { exportPath: string; f ['export', 'pull', '--out', settings.exportPath, '--frontend', settings.frontend, '--rootStackName', settings.rootStackName], { cwd, stripColors: true }, ) - .wait('Successfully generated frontend config files') + // .wait('Successfully generated frontend config files') .sendEof() .run((err: Error) => { if (!err) { @@ -33,4 +33,3 @@ export function exportPullBackend(cwd: string, settings: { exportPath: string; f }); }); } -