security: retire obsolete CRM representation deletion endpoint
This commit is contained in:
@@ -1262,6 +1262,8 @@ test("getadvancedsearchpaged catch path returns ADVANCED_SEARCH_PAGED_FETCH_FAIL
|
||||
relayGet: async ({ res, errorResponse }) =>
|
||||
respondErrorMock(res, errorResponse),
|
||||
azureHeadersPagedCustom: () => ({}),
|
||||
hasOwn: (obj, key) =>
|
||||
obj != null && Object.prototype.hasOwnProperty.call(obj, key),
|
||||
_: { has: () => false }
|
||||
});
|
||||
|
||||
@@ -3073,56 +3075,6 @@ test("deletewatchedcasesproxy catch path returns WATCHED_CASE_PROXY_DELETE_FAILE
|
||||
);
|
||||
});
|
||||
|
||||
test("deletemyrepresentations returns MY_REPRESENTATION_ID_REQUIRED when myRepresentationsID missing", async () => {
|
||||
const mod = loadModule(
|
||||
"pages/api/endpoint/deletemyrepresentations_api.js",
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
axios: async () => ({ data: {} }),
|
||||
consoleLogger: () => {}
|
||||
}
|
||||
);
|
||||
|
||||
const req = { query: {} };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
res.state.jsonBody.error.code,
|
||||
"MY_REPRESENTATION_ID_REQUIRED"
|
||||
);
|
||||
});
|
||||
|
||||
test("deletemyrepresentations catch path returns MY_REPRESENTATION_DELETE_FAILED", async () => {
|
||||
const mod = loadModule(
|
||||
"pages/api/endpoint/deletemyrepresentations_api.js",
|
||||
{
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
getToken: async () => ({ access_token: "token" }),
|
||||
hashAPIPath: () => "&hash=expected",
|
||||
axios: async () => {
|
||||
throw new Error("delete failed");
|
||||
},
|
||||
consoleLogger: () => {}
|
||||
}
|
||||
);
|
||||
|
||||
const req = { query: { myRepresentationsID: "r1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(
|
||||
res.state.jsonBody.error.code,
|
||||
"MY_REPRESENTATION_DELETE_FAILED"
|
||||
);
|
||||
});
|
||||
|
||||
test("deleteawaitingsubmissions returns INCIDENT_ID_REQUIRED when incidentID missing", async () => {
|
||||
const mod = loadModule(
|
||||
"pages/api/endpoint/deleteawaitingsubmissions_api.js",
|
||||
@@ -4021,7 +3973,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) => {
|
||||
@@ -4045,7 +3998,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) => {
|
||||
@@ -4178,10 +4134,11 @@ test("getToken catch path returns TOKEN_FETCH_FAILED", async () => {
|
||||
|
||||
test("getsipsmedia returns success contract", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getsipsmedia_api.js", {
|
||||
respondSuccess: respondSuccessMock
|
||||
relayGet: async ({ res }) =>
|
||||
respondSuccessMock(res, { "@odata.count": 4 })
|
||||
});
|
||||
|
||||
const req = { query: {} };
|
||||
const req = { query: { caseid: "case-1" } };
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
@@ -4189,9 +4146,8 @@ test("getsipsmedia returns success contract", async () => {
|
||||
assert.strictEqual(res.state.jsonBody["@odata.count"], 4);
|
||||
});
|
||||
|
||||
test("getsipsmedia returns METHOD_NOT_ALLOWED for non-GET methods", async () => {
|
||||
test("getsipsmedia returns CASE_ID_REQUIRED when caseid missing", async () => {
|
||||
const mod = loadModule("pages/api/endpoint/getsipsmedia_api.js", {
|
||||
respondSuccess: respondSuccessMock,
|
||||
respondError: respondErrorMock
|
||||
});
|
||||
|
||||
@@ -4199,8 +4155,8 @@ test("getsipsmedia returns METHOD_NOT_ALLOWED for non-GET methods", async () =>
|
||||
const res = createRes();
|
||||
await mod.default(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 405);
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "METHOD_NOT_ALLOWED");
|
||||
assert.strictEqual(res.state.statusCode, 400);
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "CASE_ID_REQUIRED");
|
||||
});
|
||||
|
||||
test("getappealtypesfornewappeal returns METHOD_NOT_ALLOWED for non-GET methods", async () => {
|
||||
|
||||
Reference in New Issue
Block a user