fix: preserve route limits and harden restore marker
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { expect, test } from 'bun:test';
|
||||
import {
|
||||
parseRestoreMarkerPhase,
|
||||
RESTORE_MARKER_CONFIRMATION,
|
||||
validateRestoreMarkerTarget,
|
||||
validateRestoreMarkerWrite,
|
||||
} from '../src/lib/server/restore-marker';
|
||||
|
||||
test('restore marker defaults to a non-writing verification phase', () => {
|
||||
expect(parseRestoreMarkerPhase(undefined)).toBe('verify');
|
||||
expect(parseRestoreMarkerPhase('')).toBe('verify');
|
||||
});
|
||||
|
||||
test('restore marker rejects non-loopback targets before any backend call', () => {
|
||||
expect(() => validateRestoreMarkerTarget(undefined)).toThrow('required');
|
||||
expect(() => validateRestoreMarkerTarget('https://production.example.test')).toThrow('loopback');
|
||||
expect(() => validateRestoreMarkerTarget('http://192.0.2.10:3210')).toThrow('loopback');
|
||||
expect(validateRestoreMarkerTarget('http://127.0.0.1:3210').hostname).toBe('127.0.0.1');
|
||||
});
|
||||
|
||||
test('restore marker requires explicit disposable confirmation for writes', () => {
|
||||
expect(() => validateRestoreMarkerWrite({ phase: 'write', allowWrite: undefined, confirmation: undefined })).toThrow('SMOKE_ALLOW_WRITE');
|
||||
expect(() => validateRestoreMarkerWrite({ phase: 'write', allowWrite: '1', confirmation: 'wrong' })).toThrow('RESTORE_MARKER_CONFIRMATION');
|
||||
expect(() => validateRestoreMarkerWrite({ phase: 'write', allowWrite: '1', confirmation: RESTORE_MARKER_CONFIRMATION })).not.toThrow();
|
||||
expect(() => validateRestoreMarkerWrite({ phase: 'verify', allowWrite: undefined, confirmation: undefined })).not.toThrow();
|
||||
});
|
||||
Reference in New Issue
Block a user