import { test, expect } from "@playwright/test"
import {
ALLOWED_UPLOAD_EXTENSIONS,
isAllowedUploadExt,
extOf,
contentTypeForKey,
contentMatchesExtension,
keyBelongsToOwner,
} from "@/lib/storage"
/**
* Upload validation is the boundary between "a landlord attached a lease PDF"
* and "a tenant stored an HTML file that executes on our origin". Two
* independent gates matter: the extension allowlist and the magic-byte check.
* Neither is sufficient alone.
*/
const sig = (...bytes: number[]) => Buffer.from(bytes)
const PDF = sig(0x25, 0x50, 0x44, 0x46, 0x2d, 0x31, 0x2e, 0x37)
const PNG = sig(0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a)
const JPG = sig(0xff, 0xd8, 0xff, 0xe0)
const GIF = sig(0x47, 0x49, 0x46, 0x38, 0x39, 0x61)
const ZIP = sig(0x50, 0x4b, 0x03, 0x04)
const OLE = sig(0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1)
const WEBP = Buffer.concat([sig(0x52, 0x49, 0x46, 0x46), sig(0, 0, 0, 0), sig(0x57, 0x45, 0x42, 0x50)])
const HTML = Buffer.from("", "utf8")
const SVG = Buffer.from('