-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OJ-2837: Feat - update integration tests to use multiple names scenario
- Loading branch information
1 parent
59c07f1
commit 3cc194a
Showing
3 changed files
with
118 additions
and
3 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
integration-tests/api-gateway/check/check-multiple-name.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,63 @@ | ||
import { checkEndpoint, createMultipleNamesSession } from "../endpoints"; | ||
import { | ||
clearAttemptsTable, | ||
clearItemsFromTables, | ||
} from "../../resources/dynamodb-helper"; | ||
import { NINO } from "../env-variables"; | ||
import { stackOutputs } from "../../resources/cloudformation-helper"; | ||
|
||
jest.setTimeout(30000); | ||
|
||
describe("Given the session and NINO is valid", () => { | ||
let sessionId: string; | ||
let personIDTableName: string; | ||
let sessionTableName: string; | ||
let output: Partial<{ | ||
CommonStackName: string; | ||
StackName: string; | ||
NinoUsersTable: string; | ||
UserAttemptsTable: string; | ||
}>; | ||
|
||
afterEach(async () => { | ||
output = await stackOutputs(process.env.STACK_NAME); | ||
personIDTableName = `person-identity-${output.CommonStackName}`; | ||
sessionTableName = `session-${output.CommonStackName}`; | ||
await clearItemsFromTables( | ||
{ | ||
tableName: personIDTableName, | ||
items: { sessionId: sessionId }, | ||
}, | ||
{ | ||
tableName: `${output.NinoUsersTable}`, | ||
items: { sessionId: sessionId }, | ||
}, | ||
{ | ||
tableName: sessionTableName, | ||
items: { sessionId: sessionId }, | ||
} | ||
); | ||
await clearAttemptsTable(sessionId, `${output.UserAttemptsTable}`); | ||
}); | ||
|
||
it("Should receive a 200 response when /check endpoint is called without optional headers", async () => { | ||
const session = await createMultipleNamesSession(); | ||
const sessionData = await session.json(); | ||
sessionId = sessionData.session_id; | ||
const check = await checkEndpoint({ "session-id": sessionId }, NINO); | ||
const checkData = check.status; | ||
expect(checkData).toEqual(200); | ||
}); | ||
|
||
it("Should receive a 200 response when /check endpoint is called with optional headers", async () => { | ||
const session = await createMultipleNamesSession(); | ||
const sessionData = await session.json(); | ||
sessionId = sessionData.session_id; | ||
const check = await checkEndpoint( | ||
{ "session-id": sessionId, "txma-audit-encoded": "test encoded header" }, | ||
NINO | ||
); | ||
const checkData = check.status; | ||
expect(checkData).toEqual(200); | ||
}); | ||
}); |
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
27 changes: 27 additions & 0 deletions
27
integration-tests/api-gateway/session/session-multiple-names-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,27 @@ | ||
import { createMultipleNamesSession } from "../endpoints"; | ||
import { clearItemsFromTables } from "../../resources/dynamodb-helper"; | ||
describe("Given the session is valid", () => { | ||
let sessionId: string; | ||
|
||
afterEach(async () => { | ||
await clearItemsFromTables( | ||
{ | ||
tableName: "person-identity-common-cri-api", | ||
items: { sessionId: sessionId }, | ||
}, | ||
{ | ||
tableName: "session-common-cri-api", | ||
items: { sessionId: sessionId }, | ||
} | ||
); | ||
}); | ||
|
||
it("Should receive a valid session id when /session endpoint is called", async () => { | ||
const sessionResponse = await createMultipleNamesSession(); | ||
const jsonSession = await sessionResponse.json(); | ||
sessionId = jsonSession.session_id; | ||
|
||
expect(sessionId).toBeDefined(); | ||
expect(sessionResponse.status).toEqual(201); | ||
}); | ||
}); |