fix: make location rules integration test honest about what it tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
fuomag9
2026-03-28 11:09:12 +01:00
parent 0f9bd04ec7
commit 55f4ba4e80

View File

@@ -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 () => {