Skip to content

Commit

Permalink
test: fix profile selection
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed May 24, 2021
1 parent 8fc9156 commit 1ecec6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
15 changes: 5 additions & 10 deletions packages/amplify-e2e-core/src/init/initProjectHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const defaultSettings = {
disableAmplifyAppCreation: true,
disableCIDetection: false,
providerConfig: undefined,
permissionsBoundaryArn: undefined,
};

export function initJSProjectWithProfile(cwd: string, settings: Object): Promise<void> {
Expand All @@ -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')
Expand Down Expand Up @@ -367,16 +372,6 @@ export function amplifyInitSandbox(cwd: string, settings: {}): Promise<void> {
});
}

export async function initWithPermissionsBoundary(cwd: string, permissionsBoundaryArn: string): Promise<void> {
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<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['init', '--yes'], {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
getProjectMeta,
getTeamProviderInfo,
initJSProjectWithProfile,
initWithPermissionsBoundary,
} from 'amplify-e2e-core';
import _ from 'lodash';
import { updateEnvironment } from '../environment/env';
Expand Down Expand Up @@ -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;
Expand All @@ -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);
});
});

0 comments on commit 1ecec6d

Please sign in to comment.