add method not allowed check for health endpoint

This commit is contained in:
Ian Stewart 2026-02-26 19:30:15 -08:00
parent 3953b116c7
commit 6fb150ba73
No known key found for this signature in database

View file

@ -157,3 +157,23 @@ func TestHealthEndpointNoAuth(t *testing.T) {
assert.Equal(t, http.StatusOK, resp.StatusCode)
}
func TestHealthEndpointMethodNotAllowed(t *testing.T) {
client := &http.Client{
Timeout: 5 * time.Second,
}
url := fmt.Sprintf("%s/apis/web/v1/health", host())
methods := []string{http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch}
for _, method := range methods {
req, err := http.NewRequest(method, url, nil)
require.NoError(t, err)
resp, err := client.Do(req)
require.NoError(t, err)
defer resp.Body.Close()
assert.Equal(t, http.StatusMethodNotAllowed, resp.StatusCode, "method %s should return 405", method)
}
}