Files
CollabTable/backend/routes_test.go
T
Gabriel20xx 937f51b4fb
Lint / Lint (push) Successful in 26s
Tests / Go backend (push) Failing after 1m14s
Tests / Dashboard checks (push) Successful in 52s
Docker / Docker Build & Push (push) Successful in 3m41s
fix: address performance and security findings
- Add PostgreSQL-backed backend and frontend tests to CI
- Harden Android API logging and disable app backups
- Update the performance report with resolved findings
2026-10-19 21:16:08 +00:00

37 lines
1.2 KiB
Go

package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestRegisterRoutes(t *testing.T) {
// Auth is disabled and there is no database, so these checks only touch
// routes that answer before any query runs.
server := &Server{auth: newAuthService(nil, "", false, true)}
mux := http.NewServeMux()
server.registerRoutes(mux, webFS)
cases := []struct {
name string
method string
path string
want int
}{
{name: "health is public", method: http.MethodGet, path: "/health", want: http.StatusOK},
{name: "sync needs a bearer token", method: http.MethodPost, path: "/api/sync", want: http.StatusUnauthorized},
{name: "lists need a bearer token", method: http.MethodGet, path: "/api/lists", want: http.StatusUnauthorized},
{name: "managed users pass the role gate when auth is disabled", method: http.MethodGet, path: "/api/auth/users", want: http.StatusOK},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
recorder := httptest.NewRecorder()
mux.ServeHTTP(recorder, httptest.NewRequest(tc.method, tc.path, nil))
if recorder.Code != tc.want {
t.Fatalf("%s %s status = %d, want %d", tc.method, tc.path, recorder.Code, tc.want)
}
})
}
}