Fix: licence read-only mode blocks the v2 routes too (1.52.3)
The read-only guard only listed v1 paths, and every screen has used /api/v2 since 1.51.15, so a suspended, revoked or unlicensed site could still create events, take registrations and start payments. The v2 successors of each blocked v1 route are blocked now; a test checks each blocked v2 path exists in the OpenAPI document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -105,6 +105,48 @@ describe('read-only mode', () => {
|
||||
['POST', '/api/users/login'],
|
||||
['POST', '/api/reports/pdf'],
|
||||
])('%s %s keeps working', (m, p) => expect(isBlocked(m, p)).toBe(false));
|
||||
|
||||
// 1.52.3: the screens use /api/v2, so its routes must be blocked too.
|
||||
test.each([
|
||||
['POST', '/api/v2/events'],
|
||||
['PATCH', '/api/v2/events/ev_1'],
|
||||
['POST', '/api/v2/events/ev_1/copy-from'],
|
||||
['POST', '/api/v2/events/ev_1/ticket-options'],
|
||||
['PATCH', '/api/v2/ticket-options/opt_1'],
|
||||
['PATCH', '/api/v2/variants/var_1'],
|
||||
['POST', '/api/v2/registrations'],
|
||||
['POST', '/api/v2/registrations/manual'],
|
||||
['PUT', '/api/v2/registrations/abc/items'],
|
||||
['POST', '/api/v2/registrations/abc/checkout'],
|
||||
['POST', '/api/v2/registrations/abc/payment-link/send'],
|
||||
['POST', '/api/v2/payments'],
|
||||
['POST', '/api/v2/payment-links/chk_1'],
|
||||
['POST', '/api/v2/waitlist'],
|
||||
['POST', '/api/v2/season-passes/p1/buy'],
|
||||
['POST', '/api/v2/volunteer-roles/r1/sign-up'],
|
||||
])('v2 %s %s is blocked', (m, p) => expect(isBlocked(m, p)).toBe(true));
|
||||
|
||||
test.each([
|
||||
['POST', '/api/v2/checkin/QR123'],
|
||||
['GET', '/api/v2/events'],
|
||||
['PUT', '/api/v2/events/ev_1/notify-recipients'],
|
||||
['POST', '/api/v2/registrations/abc/cancel'],
|
||||
['POST', '/api/v2/payments/refunds'],
|
||||
['POST', '/api/v2/me/privacy/requests'],
|
||||
['POST', '/api/v2/auth/login'],
|
||||
])('v2 %s %s keeps working', (m, p) => expect(isBlocked(m, p)).toBe(false));
|
||||
|
||||
test('every blocked v2 path is a real v2 route', () => {
|
||||
const doc = require('../../frontend/src/lib/api-v2/openapi.json');
|
||||
const routes = Object.entries(doc.paths).flatMap(([p, ops]) =>
|
||||
Object.keys(ops).map(m => [m.toUpperCase(), `/api/v2${p.replace(/\{[^}]+\}/g, 'x1')}`]));
|
||||
const { BLOCKED } = require('../src/hub/readOnly');
|
||||
const unmatched = BLOCKED
|
||||
.filter(([, re]) => re.source.startsWith('^\\/api\\/v2'))
|
||||
.filter(([m, re]) => !routes.some(([rm, rp]) => rm === m && re.test(rp)))
|
||||
.map(([m, re]) => `${m} ${re}`);
|
||||
expect(unmatched).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('pasting the Hub public key', () => {
|
||||
|
||||
Reference in New Issue
Block a user