This commit is contained in:
miles committed 2026-11-09 17:25:42 -06:00
1 parent c250653961
commit f26fdd9d07
18 files changed
+493 -83

No files matched your search

+34
View File
@@ -76,12 +76,29 @@ test('HTTP app exposes documented APIs, security headers, and CORS allowlist', a
});
assert.equal(preflight.status, 204);
assert.equal(preflight.headers.get('access-control-allow-origin'), 'https://milesallen.site');
assert.equal(preflight.headers.get('access-control-allow-credentials'), 'true');
const apiPreflight = await fetch(base + '/api/status', {
method: 'OPTIONS',
headers: {
Origin: 'https://api.milesallen.site',
'Access-Control-Request-Method': 'GET'
}
});
assert.equal(apiPreflight.status, 204);
assert.equal(apiPreflight.headers.get('access-control-allow-origin'), 'https://api.milesallen.site');
assert.equal(apiPreflight.headers.get('access-control-allow-credentials'), 'true');
assert.equal(apiPreflight.headers.get('access-control-expose-headers'), 'Retry-After');
const blocked = await fetch(base + '/api/status', {
headers: { Origin: 'https://evil.example' }
});
assert.equal(blocked.status, 403);
const siteConfig = await fetch(base + '/site-config.js');
assert.equal(siteConfig.status, 200);
assert.match(await siteConfig.text(), /api\.milesallen\.site/);
const missing = await fetch(base + '/api/nope');
assert.equal(missing.status, 404);
const missingBody = await missing.json();
@@ -108,6 +125,17 @@ test('Moon Vault content is server-gated and the old passphrase is gone from pub
const deniedGame = await fetch(base + '/games/dino.html', { redirect: 'manual' });
assert.equal(deniedGame.status, 302);
for (const encoded of [
'/games%2Fdino.html',
'/%67ames/dino.html',
'/games/%2564ino.html',
'/GAMES/dino.html',
'/Games/dino.html'
]) {
const bypass = await fetch(base + encoded, { redirect: 'manual' });
assert.equal(bypass.status, 302, `protected path must stay gated: ${encoded}`);
}
const badLogin = await fetch(base + '/api/vault/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -143,6 +171,12 @@ test('Moon Vault content is server-gated and the old passphrase is gone from pub
assert.equal(game.status, 200);
assert.equal(game.headers.get('cache-control'), 'no-store', 'protected games must not be cached');
const encodedGame = await fetch(base + '/games%2Fdino.html', {
headers: { Cookie: cookie },
redirect: 'manual'
});
assert.equal(encodedGame.status, 200, 'encoded protected paths work for authenticated sessions');
const logout = await fetch(base + '/api/vault/logout', {
method: 'POST',
headers: { Cookie: cookie }