-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd28cf3
commit 838f7dc
Showing
6 changed files
with
104 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/amplify-e2e-tests/src/__tests__/iam-permission-boundary.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
addFunction, | ||
amplifyConfigureProject, | ||
amplifyPushAuth, | ||
createNewProjectDir, | ||
deleteProject, | ||
deleteProjectDir, | ||
getPermissionBoundary, | ||
getProjectMeta, | ||
initJSProjectWithProfile, | ||
} from 'amplify-e2e-core'; | ||
import { addSimpleFunction } from '../schema-api-directives/functionTester'; | ||
|
||
// Using a random AWS managed policy as a permission boundary | ||
const permissionBoundaryArn = 'arn:aws:iam::aws:policy/AlexaForBusinessFullAccess'; | ||
|
||
describe('iam permission boundary', () => { | ||
let projRoot: string; | ||
beforeEach(async () => { | ||
projRoot = await createNewProjectDir('init'); | ||
}); | ||
|
||
afterEach(async () => { | ||
await deleteProject(projRoot); | ||
deleteProjectDir(projRoot); | ||
}); | ||
test('permission boundary is applied to roles created by the CLI', async () => { | ||
await initJSProjectWithProfile(projRoot, {}); | ||
await amplifyConfigureProject({ cwd: projRoot, permissionBoundaryArn }); | ||
// adding a function isn't strictly part of the test, it just causes the project to have changes to push | ||
await addFunction(projRoot, { functionTemplate: 'Hello World' }, 'nodejs'); | ||
await amplifyPushAuth(projRoot); | ||
const meta = getProjectMeta(projRoot); | ||
const authRoleName = meta?.providers?.awscloudformation?.AuthRoleName; | ||
const region = meta?.providers?.awscloudformation?.Region; | ||
|
||
const actualPermBoundary = await getPermissionBoundary(authRoleName, region); | ||
expect(actualPermBoundary).toEqual(permissionBoundaryArn); | ||
}); | ||
}); |