From 55f4ba4e80180af8fe05fbac09c471fa3590e817 Mon Sep 17 00:00:00 2001 From: fuomag9 <1580624+fuomag9@users.noreply.github.com> Date: Sat, 28 Mar 2026 11:09:12 +0100 Subject: [PATCH] fix: make location rules integration test honest about what it tests Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/integration/proxy-hosts.test.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/integration/proxy-hosts.test.ts b/tests/integration/proxy-hosts.test.ts index bd77895e..e0838c85 100644 --- a/tests/integration/proxy-hosts.test.ts +++ b/tests/integration/proxy-hosts.test.ts @@ -132,24 +132,23 @@ describe('proxy-hosts integration', () => { expect(meta.location_rules[1]).toMatchObject({ path: '/api/*', upstreams: ['api:3000'] }); }); - it('sanitizes invalid location rules — drops entries missing path or upstreams', async () => { + it('stores location rules with mixed valid and invalid entries in raw meta', async () => { + const locationRules = [ + { path: '/good/*', upstreams: ['backend:8080'] }, + { path: '', upstreams: ['backend:8080'] }, + { path: '/no-upstreams/*', upstreams: [] }, + ]; const host = await insertProxyHost({ - name: 'bad-rules', - domains: JSON.stringify(['bad.example.com']), + name: 'mixed-rules', + domains: JSON.stringify(['mixed.example.com']), upstreams: JSON.stringify(['backend:80']), - meta: JSON.stringify({ - location_rules: [ - { path: '/good/*', upstreams: ['backend:8080'] }, - { path: '', upstreams: ['backend:8080'] }, - { path: '/no-upstreams/*', upstreams: [] }, - { path: '/bad-upstream/*', upstreams: [''] }, - 'not-an-object', - ], - }), + meta: JSON.stringify({ location_rules: locationRules }), }); const row = await db.query.proxyHosts.findFirst({ where: (t, { eq }) => eq(t.id, host.id) }); const meta = JSON.parse(row!.meta ?? '{}'); - expect(meta.location_rules).toHaveLength(5); // raw DB stores as-is + // Raw DB stores all entries as-is; sanitization happens at model layer (parseMeta) + expect(meta.location_rules).toHaveLength(3); + expect(meta.location_rules[0].path).toBe('/good/*'); }); it('filters out invalid redirect rules on parse', async () => {