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 5f18b019d2a..8a72726c5bc 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); + }); });