-
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 tests to use multiple names scenario
- Loading branch information
1 parent
a7a1b1a
commit ec38843
Showing
3 changed files
with
119 additions
and
3 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
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
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); | ||
}); | ||
}); |