fix(security): retire legacy direct CRM case creation endpoint
This commit is contained in:
@@ -4624,76 +4624,6 @@ test("getappealpdfdocuments catch path returns APPEAL_PDF_DOCUMENTS_FETCH_FAILED
|
||||
);
|
||||
});
|
||||
|
||||
test("createcase returns CASE_PAYLOAD_REQUIRED when body missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/createcase_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
getCaseBlob: async () => {},
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
axios: async () => ({ data: { ticketnumber: "CAS-1" } }),
|
||||
consoleLogger: () => {}
|
||||
});
|
||||
|
||||
const req = { query: {}, body: undefined };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "CASE_PAYLOAD_REQUIRED");
|
||||
});
|
||||
|
||||
test("createcase returns CONTACT_ID_REQUIRED when contactid missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/createcase_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
getCaseBlob: async () => {},
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
axios: async () => ({ data: { ticketnumber: "CAS-1" } }),
|
||||
consoleLogger: () => {}
|
||||
});
|
||||
|
||||
const req = {
|
||||
query: { appealTypeId: "a1", containername: "c1", lpaID: "l1" },
|
||||
body: { title: "x" }
|
||||
};
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "CONTACT_ID_REQUIRED");
|
||||
});
|
||||
|
||||
test("createcase catch path returns CASE_CREATE_FAILED", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/createcase_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
getCaseBlob: async () => {},
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
axios: async () => {
|
||||
throw new Error("create failed");
|
||||
},
|
||||
consoleLogger: () => {}
|
||||
});
|
||||
|
||||
const req = {
|
||||
query: {
|
||||
contactid: "c1",
|
||||
appealTypeId: "a1",
|
||||
containername: "container",
|
||||
lpaID: "l1"
|
||||
},
|
||||
body: { title: "x" }
|
||||
};
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "CASE_CREATE_FAILED");
|
||||
});
|
||||
|
||||
test("updatecase returns CASE_UPDATE_PAYLOAD_REQUIRED when body missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/updatecase_api.js", {
|
||||
respondError: respondErrorMock,
|
||||
@@ -4836,7 +4766,8 @@ test("gethash returns UNAUTHENTICATED when session missing", async () => {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
getSession: async () => null,
|
||||
getServerSession: async () => null,
|
||||
authOptions: () => ({}),
|
||||
nextConnect: () => {
|
||||
const handler = { registeredGet: null };
|
||||
handler.get = (cb) => {
|
||||
@@ -4860,7 +4791,10 @@ test("gethash returns INVALID_HASH_PATH when path is invalid", async () => {
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
getSession: async () => ({ user: { email: "user@test.local" } }),
|
||||
getServerSession: async () => ({
|
||||
user: { email: "user@test.local" }
|
||||
}),
|
||||
authOptions: () => ({}),
|
||||
nextConnect: () => {
|
||||
const handler = { registeredGet: null };
|
||||
handler.get = (cb) => {
|
||||
|
||||
Reference in New Issue
Block a user