TASK22224: harden setupcontainer hash compatibility parity
This commit is contained in:
@@ -596,6 +596,31 @@ test("setupcontainer handler returns MISSING_REQUIRED_QUERY when ident missing",
|
||||
assert.strictEqual(res.state.jsonBody.error.code, "MISSING_REQUIRED_QUERY");
|
||||
});
|
||||
|
||||
test("setupcontainer handler accepts encoded ident hash variant", async () => {
|
||||
const mod = loadModule("pages/api/file/setupcontainer.js", {
|
||||
nextConnect: createNextConnectMock(),
|
||||
middleware: () => {},
|
||||
hashAPIPath: (queryPath) =>
|
||||
queryPath.includes("ident=container%2Fname")
|
||||
? "&hash=expected"
|
||||
: "&hash=other",
|
||||
consoleLogger: () => {},
|
||||
respondError: respondErrorMock,
|
||||
respondSuccess: respondSuccessMock,
|
||||
createContainer: async () => ({ created: true })
|
||||
});
|
||||
|
||||
const req = { query: { ident: "container/name", hash: "expected" } };
|
||||
const res = createRes();
|
||||
await mod.default.handler(req, res);
|
||||
|
||||
assert.strictEqual(res.state.statusCode, 200);
|
||||
assert.deepStrictEqual(JSON.parse(JSON.stringify(res.state.jsonBody)), {
|
||||
data: "success",
|
||||
output: { created: true }
|
||||
});
|
||||
});
|
||||
|
||||
test("upload handler success returns data payload with 200", async () => {
|
||||
const mod = loadModule("pages/api/file/upload.js", {
|
||||
nextConnect: createNextConnectMock(),
|
||||
|
||||
Reference in New Issue
Block a user