Files
qinglong/test/back/protected-path-case.test.cjs
T
whyour c5458596c8 feat(cron): expose run receipts and modularize execution
Return committed trigger IDs and add CLI wait and trigger-specific logs while
preserving API, CLI, transaction, deduplication and unknown-result semantics.

Move scheduling, lifecycle, settlement, queries and legacy adapters into
back/cron; remove obsolete internal import paths and circular dependencies.

Apply project formatting across the repository, cover CJS/MJS in formatting
hooks, add prettier:check and require formatting checks in AGENTS.md.

Validation: backend build; 1398 backend/frontend tests passed (17 platform
skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
2026-11-22 12:24:29 +08:00

58 lines
1.2 KiB
JavaScript

const assert = require('node:assert/strict');
const test = require('node:test');
const protectedPathCase =
require('../../back/middlewares/protectedPathCase').default;
function runMiddleware(path) {
let status;
let body;
let nextCalled = false;
const response = {
status(value) {
status = value;
return this;
},
json(value) {
body = value;
return this;
},
};
protectedPathCase({ path }, response, () => {
nextCalled = true;
});
return { status, body, nextCalled };
}
test('rejects case variations under protected API namespaces', () => {
for (const path of [
'/Api/configs/detail',
'/api/Configs/detail',
'/OPEN/scripts/detail',
'/open/scripts/Detail',
]) {
assert.deepEqual(runMiddleware(path), {
status: 400,
body: { code: 400, message: 'Invalid path format' },
nextCalled: false,
});
}
});
test('allows normalized protected paths and unrelated paths', () => {
for (const path of [
'/api/configs/detail',
'/open/scripts/detail',
'/OpenApi/status',
'/assets/AppBundle.js',
]) {
assert.deepEqual(runMiddleware(path), {
status: undefined,
body: undefined,
nextCalled: true,
});
}
});