feat: add comprehensive E2E test suite (Playwright + WireGuard + API)

Adds tests/e2e/ with three layers of E2E coverage:
- API layer (tests/e2e/api/): unauthenticated access, admin endpoints,
  peer endpoints, access control enforcement — 24 tests
- Playwright UI (tests/e2e/ui/): login flows, admin navigation, peer
  dashboard/services, role-based ACL, password change — 60+ tests
- WireGuard connectivity (tests/e2e/wg/): tunnel up/down, DNS resolution
  through VPN, service ACL enforcement via iptables, full-tunnel routing
Shared helpers: PicAPIClient, WGInterface, playwright_login, cleanup.
Makefile targets: test-e2e-api, test-e2e-ui, test-e2e-wg, test-e2e.
Adds scripts/reset_admin_password.py for test bootstrap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 16:41:13 -04:00
parent 1e81b3b618
commit 0d32038150
34 changed files with 2122 additions and 15 deletions
+29
View File
@@ -0,0 +1,29 @@
import pytest
import subprocess
pytestmark = pytest.mark.wg
def test_dns_resolves_via_vpn(connected_peer, admin_client):
"""Scenario 27: DNS queries for cell domain resolve via 10.0.0.1 (CoreDNS)."""
# Get the configured domain
r = admin_client.get('/api/config')
domain = r.json().get('domain', 'cell') if r.status_code == 200 else 'cell'
# Query CoreDNS at the server VPN IP
result = subprocess.run(
['dig', f'@10.0.0.1', f'mail.{domain}', '+short', '+time=5'],
capture_output=True, text=True, timeout=10
)
# CoreDNS should respond (not necessarily with an IP — just not SERVFAIL)
assert result.returncode == 0, f"DNS query failed: {result.stderr}"
def test_dns_server_reachable_via_vpn(connected_peer):
"""CoreDNS port 53 is reachable from within the VPN."""
result = subprocess.run(
['dig', '@10.0.0.1', 'health.check', '+time=2'],
capture_output=True, text=True, timeout=5
)
# Even a NXDOMAIN response means DNS is up
assert 'SERVFAIL' not in result.stdout or result.returncode == 0 or 'status:' in result.stdout