From 53d92e0da69b5e2a0d8d788ec81473c926a54640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Fri, 20 Nov 2026 19:51:43 +0100 Subject: [PATCH] v0.39.1 --- scripts/test_public_cookie_template.cjs | 41 ------------------------- 1 file changed, 41 deletions(-) delete mode 100644 scripts/test_public_cookie_template.cjs diff --git a/scripts/test_public_cookie_template.cjs b/scripts/test_public_cookie_template.cjs deleted file mode 100644 index d7578fd..0000000 --- a/scripts/test_public_cookie_template.cjs +++ /dev/null @@ -1,41 +0,0 @@ -// Source-level UI template contract test; does not execute the Rust proxy. -'use strict'; -const assert = require('node:assert/strict'); -const fs = require('node:fs'); -const vm = require('node:vm'); -const path = require('node:path'); -const root = path.resolve(__dirname, '..'); -const ui = fs.readFileSync(path.join(root, 'src/admin/web/cache-rules.js'), 'utf8'); -const sandbox = { window: {}, t: key => key }; -vm.runInNewContext(ui, sandbox, { filename: 'cache-rules.js' }); -const tpl = sandbox.window.rustProxyCacheRules.TEMPLATES.publiccookies; -assert.equal(typeof tpl, 'function', 'new template is registered'); -const rules = JSON.parse(JSON.stringify(tpl())); -assert.equal(rules.length, 1); -const rule = rules[0]; -assert.equal(rule.enabled, false, 'operator must opt in explicitly'); -assert.equal(rule.stage, 'request'); -assert.equal(rule.match, 'all'); -assert.equal(rule.stop, true); -assert.deepEqual(rule.actions, [{ type: 'strip_cookies', keep: [] }, { type: 'lookup' }]); -const method = rule.conditions.find(c => c.field === 'method'); -assert.deepEqual(method.values, ['GET', 'HEAD']); -const cookie = rule.conditions.find(c => c.name === 'Cookie'); -assert.equal(cookie.operator, 'exists'); -const auth = rule.conditions.find(c => c.name === 'Authorization'); -assert.equal(auth.operator, 'exists'); -assert.equal(auth.negate, true); -const restricted = rule.conditions.find(c => c.field === 'path'); -assert.equal(restricted.negate, true); -const rex = new RegExp(restricted.values[0]); -for (const path of ['/admin', '/admin/orders', '/api/public', '/konto', '/login?next=/']) - assert.ok(rex.test(path), `protect ${path}`); -for (const path of ['/', '/rezerwa/15', '/catalog', '/stories/article']) - assert.ok(!rex.test(path), `public ${path}`); -assert.match(ui, /filter\(key => scope === "vhost" \|\| key !== "publiccookies"\)/, - 'dangerous opt-in template is unavailable in global editor'); -const vcl = fs.readFileSync(path.join(root, 'examples/vcl/public-vhost-ignore-cookies.vcl'), 'utf8'); -assert.ok(vcl.includes(restricted.values[0]), 'VCL and UI use the same excluded paths'); -for (const line of ['unset req.http.Cookie;', 'return(hash);', 'req.http.Cookie', '!req.http.Authorization']) - assert.ok(vcl.includes(line), `${line} is in example VCL`); -console.log('Public-cookie graphical template/VCL contract: OK');