From 1ecec6dc1132b4f062808fa55d6b11c21e2daafd Mon Sep 17 00:00:00 2001 From: Edward Foyle Date: Mon, 24 May 2021 11:20:21 -0700 Subject: [PATCH] test: fix profile selection --- .../src/init/initProjectHelper.ts | 15 +++++---------- .../__tests__/iam-permissions-boundary.test.ts | 5 ++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/amplify-e2e-core/src/init/initProjectHelper.ts b/packages/amplify-e2e-core/src/init/initProjectHelper.ts index 6b3dcb5a81d..7d825bd143d 100644 --- a/packages/amplify-e2e-core/src/init/initProjectHelper.ts +++ b/packages/amplify-e2e-core/src/init/initProjectHelper.ts @@ -19,6 +19,7 @@ const defaultSettings = { disableAmplifyAppCreation: true, disableCIDetection: false, providerConfig: undefined, + permissionsBoundaryArn: undefined, }; export function initJSProjectWithProfile(cwd: string, settings: Object): Promise { @@ -39,6 +40,10 @@ export function initJSProjectWithProfile(cwd: string, settings: Object): Promise cliArgs.push('--providers', JSON.stringify(s.providerConfig)); } + if (s.permissionsBoundaryArn) { + cliArgs.push('--permissions-boundary', s.permissionsBoundaryArn); + } + return new Promise((resolve, reject) => { const chain = spawn(getCLIPath(), cliArgs, { cwd, stripColors: true, env, disableCIDetection: s.disableCIDetection }) .wait('Enter a name for the project') @@ -367,16 +372,6 @@ export function amplifyInitSandbox(cwd: string, settings: {}): Promise { }); } -export async function initWithPermissionsBoundary(cwd: string, permissionsBoundaryArn: string): Promise { - return new Promise((resolve, reject) => { - spawn(getCLIPath(), ['init', '--yes', '--permissions-boundary', permissionsBoundaryArn], { - cwd, - stripColors: true, - env: { CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1' }, - }).run((err: Error) => (err ? reject(err) : resolve())); - }); -} - export function amplifyInitYes(cwd: string): Promise { return new Promise((resolve, reject) => { spawn(getCLIPath(), ['init', '--yes'], { diff --git a/packages/amplify-e2e-tests/src/__tests__/iam-permissions-boundary.test.ts b/packages/amplify-e2e-tests/src/__tests__/iam-permissions-boundary.test.ts index a523304cd3f..59ee3be9e65 100644 --- a/packages/amplify-e2e-tests/src/__tests__/iam-permissions-boundary.test.ts +++ b/packages/amplify-e2e-tests/src/__tests__/iam-permissions-boundary.test.ts @@ -8,7 +8,6 @@ import { getProjectMeta, getTeamProviderInfo, initJSProjectWithProfile, - initWithPermissionsBoundary, } from 'amplify-e2e-core'; import _ from 'lodash'; import { updateEnvironment } from '../environment/env'; @@ -45,7 +44,7 @@ describe('iam permissions boundary', () => { }); test('permissions boundary is applied during headless init', async () => { - await initWithPermissionsBoundary(projRoot, permissionsBoundaryArn); + await initJSProjectWithProfile(projRoot, { permissionsBoundaryArn }); const meta = getProjectMeta(projRoot); const authRoleName = meta?.providers?.awscloudformation?.AuthRoleName; const region = meta?.providers?.awscloudformation?.Region; @@ -54,7 +53,7 @@ describe('iam permissions boundary', () => { expect(actualPermBoundary).toEqual(permissionsBoundaryArn); const tpi = getTeamProviderInfo(projRoot); - const storedArn = _.get(tpi, ['dev', 'awscloudformation', 'PermissionsBoundaryPolicyArn']); + const storedArn = _.get(tpi, ['integtest', 'awscloudformation', 'PermissionsBoundaryPolicyArn']); expect(storedArn).toEqual(permissionsBoundaryArn); }); });