From f76b6d4fb23fab495f7c5b3b61c67273166f0da8 Mon Sep 17 00:00:00 2001 From: Kamil Sobol Date: Wed, 12 Jul 2023 10:54:15 -0700 Subject: [PATCH] chore: headless test --- .../auth-lambda-callout-migration.test.ts | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/amplify-migration-tests/src/__tests__/migration_tests_v12/auth-lambda-callout-migration.test.ts b/packages/amplify-migration-tests/src/__tests__/migration_tests_v12/auth-lambda-callout-migration.test.ts index 5f18b019d2..8a72726c5b 100644 --- a/packages/amplify-migration-tests/src/__tests__/migration_tests_v12/auth-lambda-callout-migration.test.ts +++ b/packages/amplify-migration-tests/src/__tests__/migration_tests_v12/auth-lambda-callout-migration.test.ts @@ -16,10 +16,13 @@ import { signOutUser, getUserPool, listSocialIdpProviders, + updateHeadlessAuth, + addAuthWithDefault, } from '@aws-amplify/amplify-e2e-core'; import { validateVersionsForMigrationTest } from '../../migration-helpers'; import { expectLambdasInCfnTemplate, migratedLambdas, nonMigratedLambdas } from '../../migration-helpers-v12/auth-helpers/utilities'; import { initJSProjectWithProfileV12 } from '../../migration-helpers-v12/init'; +import { UpdateAuthRequest } from 'amplify-headless-interface'; const defaultsSettings = { name: 'authTest', @@ -136,4 +139,57 @@ describe('lambda callouts', () => { // check the Social Idp Provider exists expect(socialIdpProvidersV12).toEqual(socialIdpProvidersLatest); }); + + it('should be migrated when updating using headless commands', async () => { + await initJSProjectWithProfileV12(projRoot, defaultsSettings); + await addAuthWithDefault(projRoot, false); + await amplifyPushAuth(projRoot, false); + + const updateAuthRequest: UpdateAuthRequest = { + version: 2, + serviceModification: { + serviceName: 'Cognito', + userPoolModification: { + autoVerifiedAttributes: [ + { + type: 'EMAIL', + }, + ], + userPoolGroups: [ + { + groupName: 'group1', + }, + { + groupName: 'group2', + }, + ], + oAuth: { + domainPrefix: generateRandomShortId(), + redirectSigninURIs: ['http://localhost/'], + redirectSignoutURIs: ['http://localhost/'], + socialProviderConfigurations: [ + { + provider: 'FACEBOOK', + clientId: '1234', + clientSecret: '5678', + }, + ], + }, + }, + includeIdentityPool: true, + identityPoolModification: { + identitySocialFederation: [{ provider: 'GOOGLE', clientId: 'fakeClientId' }], + }, + }, + }; + + await updateHeadlessAuth(projRoot, updateAuthRequest, { testingWithLatestCodebase: true }); + await amplifyPushAuth(projRoot, true); + await amplifyPushForce(projRoot, true); + + const meta = getProjectMeta(projRoot); + const resourceName = Object.keys(meta.auth)[0]; + const template = await getCloudFormationTemplate(projRoot, 'auth', resourceName); + expectLambdasInCfnTemplate(template, nonMigratedLambdas, migratedLambdas); + }); });