6698ef1a92
- Ändern, Entfernen, Logo-Upload und -Abruf, Sammelprüfung nur mit Verwalten - Stündlicher Auftrag beim Start registriert, Prüfung je Cloud an ihren Mandanten gebunden - Sortierung nach Kundenname, Status, Version und Support-Ende, je Benutzer gemerkt - Formular zum Anlegen und Bearbeiten, Zugriffsinventar angepasst Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { checkLogoUpload, NEXTCLOUD_LOGO_MAX_BYTES } from './nextcloud-logo-rules';
|
|
|
|
const PNG = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
const JPEG = [0xff, 0xd8, 0xff, 0xe0];
|
|
const GIF = [0x47, 0x49, 0x46, 0x38, 0x39, 0x61];
|
|
const WEBP = [0x52, 0x49, 0x46, 0x46, 0, 0, 0, 0, 0x57, 0x45, 0x42, 0x50];
|
|
|
|
describe('checkLogoUpload', () => {
|
|
it.each([
|
|
['PNG', PNG, 'image/png'],
|
|
['JPEG', JPEG, 'image/jpeg'],
|
|
['GIF', GIF, 'image/gif'],
|
|
['WebP', WEBP, 'image/webp'],
|
|
])('erkennt %s', (_name, bytes, mime) => {
|
|
expect(checkLogoUpload(Buffer.from([...bytes, 1, 2, 3]))).toBe(mime);
|
|
});
|
|
|
|
it('lehnt SVG-Text, PDF, leere Dateien und umbenanntes HTML ab', () => {
|
|
expect(
|
|
checkLogoUpload(Buffer.from('<svg xmlns="http://www.w3.org/2000/svg"></svg>')),
|
|
).toBeNull();
|
|
expect(checkLogoUpload(Buffer.from('%PDF-1.7 ...'))).toBeNull();
|
|
expect(checkLogoUpload(Buffer.alloc(0))).toBeNull();
|
|
expect(checkLogoUpload(Buffer.from('<html><script>alert(1)</script></html>'))).toBeNull();
|
|
});
|
|
|
|
it('genau 1 MiB ist erlaubt, ein Byte mehr nicht', () => {
|
|
const ok = Buffer.concat([
|
|
Buffer.from(PNG),
|
|
Buffer.alloc(NEXTCLOUD_LOGO_MAX_BYTES - PNG.length),
|
|
]);
|
|
expect(ok.length).toBe(NEXTCLOUD_LOGO_MAX_BYTES);
|
|
expect(checkLogoUpload(ok)).toBe('image/png');
|
|
expect(checkLogoUpload(Buffer.concat([ok, Buffer.from([0])]))).toBeNull();
|
|
});
|
|
});
|