Skip to content

Commit

Permalink
fix: updated ejs template for empty object triggers (#7351)
Browse files Browse the repository at this point in the history
  • Loading branch information
akshbhu authored May 18, 2021
1 parent 708330f commit 572ddbd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Resources:
Mutable: true
<% } %>
<% } %>
<%if (!props.breakCircularDependency && props.triggers && props.dependsOn) { %>
<%if (!props.breakCircularDependency && props.triggers && props.triggers !== '{}' && props.dependsOn) { %>
LambdaConfig:
<%if (props.dependsOn.find(i => i.resourceName.includes('CreateAuthChallenge'))) { %>
CreateAuthChallenge: !Ref function<%=props.resourceName%>CreateAuthChallengeArn
Expand Down
46 changes: 46 additions & 0 deletions packages/amplify-e2e-core/src/categories/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1302,3 +1302,49 @@ export function updateAuthAddAdminQueries(projectDir: string, groupName: string
});
});
}

export function updateAuthWithoutTrigger(cwd: string, settings: any): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['update', 'auth'], { cwd, stripColors: true })
.wait('What do you want to do?')
.send(KEY_DOWN_ARROW)
.sendCarriageReturn()
.wait('Select the authentication/authorization services that you want to use:')
.send(KEY_DOWN_ARROW)
.sendCarriageReturn()
.wait('Do you want to add User Pool Groups?')
.send(KEY_DOWN_ARROW)
.sendCarriageReturn()
.wait('Do you want to add an admin queries API?')
.send(KEY_DOWN_ARROW)
.sendCarriageReturn()
.wait('Multifactor authentication (MFA) user login options:')
.sendCarriageReturn()
.wait('Email based user registration/forgot password:')
.sendCarriageReturn()
.wait('Please specify an email verification subject:')
.sendCarriageReturn()
.wait('Please specify an email verification message:')
.sendCarriageReturn()
.wait('Do you want to override the default password policy for this User Pool?')
.sendCarriageReturn()
.wait("Specify the app's refresh token expiration period (in days):")
.sendCarriageReturn()
.wait('Do you want to specify the user attributes this app can read and write?')
.sendCarriageReturn()
.wait('Do you want to enable any of the following capabilities?')
.sendCarriageReturn()
.wait('Do you want to use an OAuth flow?')
.send(KEY_DOWN_ARROW)
.sendCarriageReturn()
.wait('Do you want to configure Lambda Triggers for Cognito?')
.sendLine('n')
.run((err: Error) => {
if (!err) {
resolve();
} else {
reject(err);
}
});
});
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
addAuthWithCustomTrigger,
addAuthWithDefault,
amplifyPushAuth,
createNewProjectDir,
deleteProject,
Expand All @@ -9,6 +10,7 @@ import {
getUserPool,
getUserPoolClients,
updateAuthWithoutCustomTrigger,
updateAuthWithoutTrigger,
} from 'amplify-e2e-core';
import * as fs from 'fs-extra';
import { join } from 'path';
Expand Down Expand Up @@ -59,4 +61,14 @@ describe('amplify auth migration', () => {
expect(updatedDirContents.includes('email-filter-denylist.js')).toBeTruthy();
expect(updatedFunction.Configuration.Environment.Variables.MODULES).toEqual('email-filter-denylist');
});

it('...should init a project and add auth with default, and then update with latest and push', async () => {
// init, add and push auth with installed cli
await initJSProjectWithProfile(projRoot, { name: 'authMigration' });
await addAuthWithDefault(projRoot, {});
await amplifyPushAuth(projRoot);
// update and push with codebase
await updateAuthWithoutTrigger(projRoot, { testingWithLatestCodebase: true });
await amplifyPushAuth(projRoot, true);
});
});

0 comments on commit 572ddbd

Please sign in to comment.