Research-Stack/4-Infrastructure/k3s-flake/tests/vaultwarden-verify-sso.spec.ts
allaun d7c60cf60c feat(infra): secure Vaultwarden installation using Authentik API and Caddy
- Set SIGNUPS_ALLOWED=false in Vaultwarden environment on cupfox to disable public signups.
- Automated OIDC/Proxy setup via configure_vault_authentik.py by registering proxy provider, application, and updating the embedded outpost.
- Modified /etc/caddy/Caddyfile.vault on racknerd to forward authentication requests through the Authentik outpost.
- Added vaultwarden-verify-sso.spec.ts Playwright verification test ensuring SSO redirects, successful login, and disabled registration are enforced.

Build: 3314 jobs, 0 errors (lake build)
2026-06-30 01:49:03 -05:00

57 lines
2.5 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('Verify Vaultwarden SSO and signup disable', async ({ page }) => {
page.on('console', msg => console.log(`Browser Console [${msg.type()}]:`, msg.text()));
page.on('requestfailed', req => console.log('Request Failed:', req.url(), req.failure()?.errorText));
page.on('pageerror', err => console.log('Page Error:', err.message));
test.setTimeout(60000);
console.log('Navigating to Vaultwarden via domain...');
await page.goto('https://vault.researchstack.info');
await page.waitForTimeout(5000);
console.log('Current URL:', page.url());
console.log('Page Title:', await page.title());
// 1. Verify we redirected to Authentik
expect(page.url()).toContain('auth.researchstack.info');
expect(await page.title()).toContain('authentik');
// 2. Perform SSO Login
console.log('Entering SSO username...');
await page.locator('input[placeholder*="Username"], input[name="uid"], input[type="text"]').first().fill('allaun');
const continueBtn = page.locator('button:has-text("Log in"), button:has-text("Continue"), input[type="submit"]').first();
await continueBtn.click();
await page.waitForTimeout(2000);
console.log('Entering SSO password...');
await page.locator('input[name="password"], input[type="password"]').first().fill('Silverkitten14');
await continueBtn.click();
await page.waitForTimeout(10000);
console.log('Redirected URL after login:', page.url());
console.log('Redirected Page Title:', await page.title());
// 3. Verify redirection back to Vaultwarden
expect(page.url()).toContain('vault.researchstack.info');
expect((await page.title()).toLowerCase()).toContain('vaultwarden');
// 4. Verify that the 'Create account' button is NOT visible (public registration is disabled)
const createAccountBtn = page.locator('button:has-text("Create account"), a:has-text("Create account")');
const count = await createAccountBtn.count();
console.log('Create account button count:', count);
if (count > 0) {
const isVisible = await createAccountBtn.first().isVisible();
console.log('Create account button isVisible:', isVisible);
expect(isVisible).toBeFalsy();
} else {
console.log('Create account button not found in the DOM (expected).');
}
// 5. Take screenshot and save to artifacts
const screenshotPath = '/home/allaun/.gemini/antigravity/brain/6ba3635d-8e65-4264-89be-c9d2e259d0d3/vaultwarden-verify-final.png';
await page.screenshot({ path: screenshotPath });
console.log('Screenshot saved to:', screenshotPath);
});