Files
ServerKit/backend/tests/test_ssl_unified_surface.py
Juan DenisandClaude Opus 4.8 15fce59543 refactor(unify): §5 — single SSL surface (basic + advanced)
Unifies "SSL Certificates" and "Advanced SSL" into one lifecycle surface.

Backend:
- The advanced cert operations (wildcard DNS-01, SAN, custom upload, TLS
  profiles, health, expiry alerts) now mount under /api/v1/ssl alongside the
  basic certbot routes — no path collisions. /api/v1/ssl/advanced kept as a
  deprecated alias (same blueprint, second registration).

Frontend:
- api client advanced methods repointed to the unified /ssl/* paths.
- SSLCertificates.jsx (already the single SSL page) gains the two cert-creation
  paths that were previously UI-inaccessible: a "Wildcard (DNS-01)" mode in the
  New Certificate modal (Cloudflare token / Route 53 keys) and an "Upload"
  action + modal for bring-your-own PEM cert/key/chain.

Deferred (documented follow-up): a unified Certificate registry model + disk
scan, and surfacing health/profiles panels — the API is unified and the client
methods exist; these are read-side enhancements.

Verified: 3 backend route-unification tests + existing SSL suites pass (19);
frontend build + eslint clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 14:40:08 -04:00

37 lines
1.3 KiB
Python

"""§5 unification — one /ssl surface.
The advanced certificate operations (wildcard, SAN, upload, profiles, health,
expiry alerts) are mounted under /api/v1/ssl alongside the basic certbot routes,
with /api/v1/ssl/advanced kept as a deprecated alias. Both resolve to the same
handlers.
"""
def test_advanced_routes_mounted_under_ssl():
from app import create_app
application = create_app('testing')
rules = {r.rule for r in application.url_map.iter_rules()}
# Unified surface
assert '/api/v1/ssl/profiles' in rules
assert '/api/v1/ssl/wildcard' in rules
assert '/api/v1/ssl/upload' in rules
assert '/api/v1/ssl/expiry-alerts' in rules
# Deprecated alias still present
assert '/api/v1/ssl/advanced/profiles' in rules
def test_basic_ssl_routes_still_present():
from app import create_app
application = create_app('testing')
rules = {r.rule for r in application.url_map.iter_rules()}
assert '/api/v1/ssl/certificates' in rules
assert '/api/v1/ssl/status' in rules
def test_profiles_resolves_on_both_prefixes(app, client, auth_headers):
unified = client.get('/api/v1/ssl/profiles', headers=auth_headers)
alias = client.get('/api/v1/ssl/advanced/profiles', headers=auth_headers)
assert unified.status_code == 200
assert alias.status_code == 200
assert unified.get_json() == alias.get_json()