Files
EvolioHealth/server/cmd/evoliohealth/main_test.go
T
tony b96edf0406
Android development APK / apk (push) Has been cancelled
Checks / go (push) Failing after 6s
Container images / publish (., deploy/pocketbase/Dockerfile, evoliohealth-pocketbase) (push) Has been cancelled
Container images / publish (., server/Dockerfile, evoliohealth-server) (push) Has been cancelled
Checks / compose (push) Has been cancelled
Checks / flutter (push) Has been cancelled
test: first build
2026-07-21 21:30:06 +02:00

40 lines
1.0 KiB
Go

package main
import (
"net/http"
"net/http/httptest"
"testing"
)
func TestLiveDoesNotDiscloseInternals(t *testing.T) {
app := application{}
request := httptest.NewRequest(http.MethodGet, "/health/live", nil)
response := httptest.NewRecorder()
app.live(response, request)
if response.Code != http.StatusOK {
t.Fatalf("expected status %d, got %d", http.StatusOK, response.Code)
}
if response.Body.String() != `{"status":"ok"}` {
t.Fatalf("unexpected response: %s", response.Body.String())
}
}
func TestSecurityHeaders(t *testing.T) {
handler := securityHeaders(http.HandlerFunc(func(response http.ResponseWriter, _ *http.Request) {
response.WriteHeader(http.StatusNoContent)
}))
request := httptest.NewRequest(http.MethodGet, "/", nil)
response := httptest.NewRecorder()
handler.ServeHTTP(response, request)
for _, header := range []string{"Content-Security-Policy", "Referrer-Policy", "X-Content-Type-Options", "X-Frame-Options"} {
if response.Header().Get(header) == "" {
t.Errorf("expected %s header", header)
}
}
}