Feat v0.9.1 server side subpath routing (#74)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 5s
CI/CD / test-go-pg (push) Successful in 2m55s
CI/CD / test-sqlite (push) Successful in 2m58s
CI/CD / build-and-deploy (push) Successful in 1m12s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #74.
This commit is contained in:
2026-04-03 13:42:57 +00:00
committed by xcaliber
parent 5ad6d77c56
commit d03dfe502f
7 changed files with 461 additions and 12 deletions

View File

@@ -168,6 +168,57 @@ func TestFindNavSurface_NoMatch(t *testing.T) {
}
}
// ── aggregateAccess tests ──────────────────────────────────
func TestAggregateAccess_AllPublic(t *testing.T) {
surfaces := []any{
map[string]any{"path": "/", "access": "public"},
map[string]any{"path": "/submit", "access": "public"},
}
if got := aggregateAccess(surfaces); got != "public" {
t.Errorf("expected public, got %s", got)
}
}
func TestAggregateAccess_AllAuthenticated(t *testing.T) {
surfaces := []any{
map[string]any{"path": "/", "access": "authenticated"},
map[string]any{"path": "/admin", "access": "admin"},
}
if got := aggregateAccess(surfaces); got != "authenticated" {
t.Errorf("expected authenticated, got %s", got)
}
}
func TestAggregateAccess_Mixed(t *testing.T) {
surfaces := []any{
map[string]any{"path": "/submit", "access": "public"},
map[string]any{"path": "/dashboard", "access": "authenticated"},
}
if got := aggregateAccess(surfaces); got != "mixed" {
t.Errorf("expected mixed, got %s", got)
}
}
func TestAggregateAccess_DefaultAccess(t *testing.T) {
// No access field → defaults to "authenticated"
surfaces := []any{
map[string]any{"path": "/"},
}
if got := aggregateAccess(surfaces); got != "authenticated" {
t.Errorf("expected authenticated (default), got %s", got)
}
}
func TestAggregateAccess_SinglePublic(t *testing.T) {
surfaces := []any{
map[string]any{"path": "/", "access": "public"},
}
if got := aggregateAccess(surfaces); got != "public" {
t.Errorf("expected public, got %s", got)
}
}
// ── evaluateAccess tests ────────────────────────────────────
// Note: evaluateAccess depends on gin.Context which is hard to unit test
// without a full Gin setup. These are covered via handler integration tests.