17 lines
697 B
TypeScript
17 lines
697 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { isValidImportBase64 } from '../../server/assessor-http-server';
|
|
|
|
describe('import Base64 validation', () => {
|
|
it('validates a 5.9 MB file payload iteratively without exhausting the call stack', () => {
|
|
const encoded = Buffer.alloc(5_900_000, 0x61).toString('base64');
|
|
|
|
expect(isValidImportBase64(encoded)).toBe(true);
|
|
expect(isValidImportBase64(encoded.slice(0, -4) + '***=')).toBe(false);
|
|
});
|
|
|
|
it('rejects misplaced padding and incomplete groups', () => {
|
|
expect(isValidImportBase64('YQ==')).toBe(true);
|
|
expect(isValidImportBase64('Y=Q=')).toBe(false);
|
|
expect(isValidImportBase64('YQ=')).toBe(false);
|
|
});
|
|
}); |