Fix duplicate certificate display for wildcard-covered subdomains

When a wildcard cert (e.g. *.domain.de) existed and a proxy host was created
for a subdomain (e.g. sub.domain.de) without explicitly linking it, the
certificates page showed it as a separate ACME entry. Now hosts covered by
an existing wildcard cert are attributed to that cert's "Used by" list instead.

Closes #110

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
fuomag9
2026-04-18 12:10:17 +02:00
parent ef62ef232f
commit 92fa1cb9d8
4 changed files with 171 additions and 2 deletions
+47
View File
@@ -22,4 +22,51 @@ test.describe('Certificates', () => {
await page.goto('/certificates');
await expect(page).not.toHaveURL(/login/);
});
test('wildcard cert covers subdomain — no duplicate in ACME tab', async ({ page }) => {
const BASE_URL = 'http://localhost:3000';
const API = `${BASE_URL}/api/v1`;
const headers = { 'Content-Type': 'application/json', 'Origin': BASE_URL };
const domain = `wc-test-${Date.now()}.example`;
// 1. Create a managed certificate with wildcard + base domain
const certRes = await page.request.post(`${API}/certificates`, {
data: {
name: `Wildcard ${domain}`,
type: 'managed',
domainNames: [domain, `*.${domain}`],
autoRenew: true,
},
headers,
});
expect(certRes.status()).toBe(201);
const cert = await certRes.json();
// 2. Create a proxy host for a subdomain (no explicit certificateId → auto ACME)
const hostRes = await page.request.post(`${API}/proxy-hosts`, {
data: {
name: `Sub ${domain}`,
domains: [`sub.${domain}`],
upstreams: ['127.0.0.1:8080'],
},
headers,
});
expect(hostRes.status()).toBe(201);
const host = await hostRes.json();
try {
// 3. Visit certificates page — the subdomain host should NOT appear in the ACME tab
await page.goto('/certificates');
await expect(page.getByRole('tab', { name: /acme/i })).toBeVisible();
await page.getByRole('tab', { name: /acme/i }).click();
// The subdomain should not be listed as a separate ACME entry
const acmeTab = page.locator('[role="tabpanel"]');
await expect(acmeTab.getByText(`sub.${domain}`)).not.toBeVisible({ timeout: 5_000 });
} finally {
// Cleanup: delete the proxy host and certificate
await page.request.delete(`${API}/proxy-hosts/${host.id}`, { headers });
await page.request.delete(`${API}/certificates/${cert.id}`, { headers });
}
});
});