(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestHealthz(t *testing.T) { |
| 60 | server := newTestServer(t) |
| 61 | |
| 62 | t.Run("GET", func(t *testing.T) { |
| 63 | req := httptest.NewRequest(http.MethodGet, "/healthz", nil) |
| 64 | rr := httptest.NewRecorder() |
| 65 | server.engine.ServeHTTP(rr, req) |
| 66 | |
| 67 | if rr.Code != http.StatusOK { |
| 68 | t.Fatalf("unexpected status code: got %d want %d; body=%s", rr.Code, http.StatusOK, rr.Body.String()) |
| 69 | } |
| 70 | |
| 71 | var resp struct { |
| 72 | Status string `json:"status"` |
| 73 | } |
| 74 | if err := json.Unmarshal(rr.Body.Bytes(), &resp); err != nil { |
| 75 | t.Fatalf("failed to parse response JSON: %v; body=%s", err, rr.Body.String()) |
| 76 | } |
| 77 | if resp.Status != "ok" { |
| 78 | t.Fatalf("unexpected response status: got %q want %q", resp.Status, "ok") |
| 79 | } |
| 80 | }) |
| 81 | |
| 82 | t.Run("HEAD", func(t *testing.T) { |
| 83 | req := httptest.NewRequest(http.MethodHead, "/healthz", nil) |
| 84 | rr := httptest.NewRecorder() |
| 85 | server.engine.ServeHTTP(rr, req) |
| 86 | |
| 87 | if rr.Code != http.StatusOK { |
| 88 | t.Fatalf("unexpected status code: got %d want %d; body=%s", rr.Code, http.StatusOK, rr.Body.String()) |
| 89 | } |
| 90 | if rr.Body.Len() != 0 { |
| 91 | t.Fatalf("expected empty body for HEAD request, got %q", rr.Body.String()) |
| 92 | } |
| 93 | }) |
| 94 | } |
| 95 | |
| 96 | func TestManagementResponseExposesPluginSupportHeaderForCORS(t *testing.T) { |
| 97 | t.Setenv("MANAGEMENT_PASSWORD", "test-management-key") |
nothing calls this directly
no test coverage detected