Merged PR 2315: Auth stabilistatiion and hardening

Related work items: #23020
This commit is contained in:
Robert Bond
2026-05-14 08:55:49 +00:00
parent d295a507ac
commit d0b2fd077a
41 changed files with 1462 additions and 418 deletions
@@ -30,7 +30,8 @@ module.exports = {
const context = {
module: { exports: {} },
exports: {},
require
require,
Date
};
vm.runInNewContext(source, context, { filename: filePath });
@@ -67,8 +68,15 @@ const baseInput = (overrides = {}) => ({
...overrides
});
const normalizeForAssertion = (value) =>
JSON.parse(JSON.stringify(value ?? null));
const buildOptions = (overrides = {}) =>
buildRepsArrFromContext(buildRepresentationContext(baseInput(overrides)));
normalizeForAssertion(
buildRepsArrFromContext(
buildRepresentationContext(baseInput(overrides))
)
);
test("baseline truth-table: non-DNS non-SIPS across windows/capacities/ownership", () => {
const capacities = [
@@ -227,13 +235,15 @@ test("DNS rules: statement/LIR ownership behaviour and questionnaire exclusion",
};
const dnsOptions = (overrides = {}) =>
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
appealType: APPEAL_TYPES.DNS,
detailsObj: dnsDetails,
...overrides
})
normalizeForAssertion(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
appealType: APPEAL_TYPES.DNS,
detailsObj: dnsDetails,
...overrides
})
)
)
);
@@ -339,59 +349,69 @@ test("deduplication and ordering are stable", () => {
test("invalid or missing dates suppress date-gated options but SIPS consultation persists", () => {
assert.deepStrictEqual(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
detailsObj: {
pinswg_statementduedate: "2026-04-30T00:00:00.000Z",
pinswg_finalcommentsduedate: "2026-05-25T00:00:00.000Z"
}
})
normalizeForAssertion(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
detailsObj: {
pinswg_statementduedate: "2026-04-30T00:00:00.000Z",
pinswg_finalcommentsduedate:
"2026-05-25T00:00:00.000Z"
}
})
)
)
),
[]
);
assert.deepStrictEqual(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
detailsObj: {
pinswg_startdate: "2026-04-01T00:00:00.000Z",
pinswg_finalcommentsduedate: "2026-05-25T00:00:00.000Z"
}
})
normalizeForAssertion(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
detailsObj: {
pinswg_startdate: "2026-04-01T00:00:00.000Z",
pinswg_finalcommentsduedate:
"2026-05-25T00:00:00.000Z"
}
})
)
)
),
[]
);
assert.deepStrictEqual(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
detailsObj: {
pinswg_startdate: "2026-04-01T00:00:00.000Z",
pinswg_statementduedate: "2026-04-30T00:00:00.000Z"
},
involvementType: INVOLVEMENT_TYPES.LPA,
now: new Date("2026-05-10T10:00:00.000Z")
})
normalizeForAssertion(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
detailsObj: {
pinswg_startdate: "2026-04-01T00:00:00.000Z",
pinswg_statementduedate: "2026-04-30T00:00:00.000Z"
},
involvementType: INVOLVEMENT_TYPES.LPA,
now: new Date("2026-05-10T10:00:00.000Z")
})
)
)
),
[]
);
assert.deepStrictEqual(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
appealType: APPEAL_TYPES.SIPS,
detailsObj: {},
selectedCapacity: "agent",
isNRW: true,
now: new Date("2026-06-20T10:00:00.000Z")
})
normalizeForAssertion(
buildRepsArrFromContext(
buildRepresentationContext(
baseInput({
appealType: APPEAL_TYPES.SIPS,
detailsObj: {},
selectedCapacity: "agent",
isNRW: true,
now: new Date("2026-06-20T10:00:00.000Z")
})
)
)
),
["Consultation Response", "Local Impact Report", "Marine Impact Report"]