This repository has been archived by the owner on Dec 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: step template integration tests (#338)
* feat: add support for project id when a researcher session si created * fix: typo in the default value * feat: framework update - implement default clean up logic * Trigger notification * fix: typo * fix: use this.childType instead of this.type when inserting a cleanup task * feat: aws apis foundational classes * chore: Trigger notification * chore: address the PR comments * chore: add - to the check of runId * chore: address PR comment and add '-' to the runId check * fix: typo * test: step-template integration tests Co-authored-by: Hatim Khan <hatimk@amazon.com>
- Loading branch information
Showing
9 changed files
with
609 additions
and
6 deletions.
There are no files selected for viewing
106 changes: 106 additions & 0 deletions
106
main/integration-tests/__test__/api-tests/step-templates/get-step-template-version.test.js
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,106 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
const { runSetup } = require('../../../support/setup'); | ||
const errorCode = require('../../../support/utils/error-code'); | ||
|
||
describe('Get a step templates version scenarios', () => { | ||
let setup; | ||
let adminSession; | ||
let templateId; | ||
|
||
beforeAll(async () => { | ||
setup = await runSetup(); | ||
adminSession = await setup.defaultAdminSession(); | ||
templateId = setup.gen.defaultStepTemplateId(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await setup.cleanup(); | ||
}); | ||
|
||
describe('Getting a step template version data', () => { | ||
it('should fail for anonymous user', async () => { | ||
const anonymousSession = await setup.createAnonymousSession(); | ||
await expect( | ||
anonymousSession.resources.stepTemplates | ||
.versions(templateId) | ||
.version(1) | ||
.get(), | ||
).rejects.toMatchObject({ | ||
code: errorCode.http.code.badImplementation, | ||
}); | ||
}); | ||
|
||
it('should fail for inactive user', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await adminSession.resources.users.deactivateUser(researcherSession.user); | ||
|
||
await expect( | ||
researcherSession.resources.stepTemplates | ||
.versions(templateId) | ||
.version(1) | ||
.get(), | ||
).rejects.toMatchObject({ | ||
code: errorCode.http.code.unauthorized, | ||
}); | ||
}); | ||
|
||
it('should fail for internal guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'internal-guest', projectId: [] }); | ||
await expect( | ||
guestSession.resources.stepTemplates | ||
.versions(templateId) | ||
.version(1) | ||
.get(), | ||
).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if external guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'guest', projectId: [] }); | ||
await expect( | ||
guestSession.resources.stepTemplates | ||
.versions(templateId) | ||
.version(1) | ||
.get(), | ||
).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if researcher', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await expect( | ||
researcherSession.resources.stepTemplates | ||
.versions(templateId) | ||
.version(1) | ||
.get(), | ||
).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should return the step template if admin', async () => { | ||
await expect( | ||
adminSession.resources.stepTemplates | ||
.versions(templateId) | ||
.version(1) | ||
.get(), | ||
).resolves.toHaveProperty('v', 1); | ||
}); | ||
}); | ||
}); |
122 changes: 122 additions & 0 deletions
122
main/integration-tests/__test__/api-tests/step-templates/get-step-template-versions.test.js
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,122 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
const { runSetup } = require('../../../support/setup'); | ||
const errorCode = require('../../../support/utils/error-code'); | ||
|
||
describe('Get step templates versions scenarios', () => { | ||
let setup; | ||
let adminSession; | ||
let templateId; | ||
|
||
beforeAll(async () => { | ||
setup = await runSetup(); | ||
adminSession = await setup.defaultAdminSession(); | ||
templateId = setup.gen.defaultStepTemplateId(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await setup.cleanup(); | ||
}); | ||
|
||
describe('Getting step template versions', () => { | ||
it('should fail for anonymous user', async () => { | ||
const anonymousSession = await setup.createAnonymousSession(); | ||
await expect(anonymousSession.resources.stepTemplates.versions(templateId).get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.badImplementation, | ||
}); | ||
}); | ||
|
||
it('should fail for inactive user', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await adminSession.resources.users.deactivateUser(researcherSession.user); | ||
|
||
await expect(researcherSession.resources.stepTemplates.versions(templateId).get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.unauthorized, | ||
}); | ||
}); | ||
|
||
it('should fail for internal guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'internal-guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.versions(templateId).get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if external guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.versions(templateId).get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if researcher', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await expect(researcherSession.resources.stepTemplates.versions(templateId).get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should return step templates if admin', async () => { | ||
await expect(adminSession.resources.stepTemplates.versions(templateId).get()).resolves.not.toHaveLength(0); | ||
}); | ||
}); | ||
|
||
describe('Getting latest step template version', () => { | ||
it('should fail for anonymous user', async () => { | ||
const anonymousSession = await setup.createAnonymousSession(); | ||
await expect(anonymousSession.resources.stepTemplates.versions(templateId).latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.badImplementation, | ||
}); | ||
}); | ||
|
||
it('should fail for inactive user', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await adminSession.resources.users.deactivateUser(researcherSession.user); | ||
|
||
await expect(researcherSession.resources.stepTemplates.versions(templateId).latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.unauthorized, | ||
}); | ||
}); | ||
|
||
it('should fail for internal guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'internal-guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.versions(templateId).latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if external guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.versions(templateId).latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if researcher', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await expect(researcherSession.resources.stepTemplates.versions(templateId).latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should return step templates if admin', async () => { | ||
await expect(adminSession.resources.stepTemplates.versions(templateId).latest()).resolves.toHaveProperty( | ||
'id', | ||
templateId, | ||
); | ||
}); | ||
}); | ||
}); |
117 changes: 117 additions & 0 deletions
117
main/integration-tests/__test__/api-tests/step-templates/get-step-templates.test.js
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,117 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
const { runSetup } = require('../../../support/setup'); | ||
const errorCode = require('../../../support/utils/error-code'); | ||
|
||
describe('Get step templates scenarios', () => { | ||
let setup; | ||
let adminSession; | ||
|
||
beforeAll(async () => { | ||
setup = await runSetup(); | ||
adminSession = await setup.defaultAdminSession(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await setup.cleanup(); | ||
}); | ||
|
||
describe('Getting step templates', () => { | ||
it('should fail for anonymous user', async () => { | ||
const anonymousSession = await setup.createAnonymousSession(); | ||
await expect(anonymousSession.resources.stepTemplates.get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.badImplementation, | ||
}); | ||
}); | ||
|
||
it('should fail for inactive user', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await adminSession.resources.users.deactivateUser(researcherSession.user); | ||
|
||
await expect(researcherSession.resources.stepTemplates.get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.unauthorized, | ||
}); | ||
}); | ||
|
||
it('should fail for internal guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'internal-guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if external guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if researcher', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await expect(researcherSession.resources.stepTemplates.get()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should return step templates if admin', async () => { | ||
await expect(adminSession.resources.stepTemplates.get()).resolves.not.toHaveLength(0); | ||
}); | ||
}); | ||
|
||
describe('Getting latest step templates', () => { | ||
it('should fail for anonymous user', async () => { | ||
const anonymousSession = await setup.createAnonymousSession(); | ||
await expect(anonymousSession.resources.stepTemplates.latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.badImplementation, | ||
}); | ||
}); | ||
|
||
it('should fail for inactive user', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await adminSession.resources.users.deactivateUser(researcherSession.user); | ||
|
||
await expect(researcherSession.resources.stepTemplates.latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.unauthorized, | ||
}); | ||
}); | ||
|
||
it('should fail for internal guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'internal-guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if external guest', async () => { | ||
const guestSession = await setup.createUserSession({ userRole: 'guest', projectId: [] }); | ||
await expect(guestSession.resources.stepTemplates.latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should fail if researcher', async () => { | ||
const researcherSession = await setup.createResearcherSession(); | ||
await expect(researcherSession.resources.stepTemplates.latest()).rejects.toMatchObject({ | ||
code: errorCode.http.code.forbidden, | ||
}); | ||
}); | ||
|
||
it('should return step templates if admin', async () => { | ||
await expect(adminSession.resources.stepTemplates.latest()).resolves.not.toHaveLength(0); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.