mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
add method not allowed check for health endpoint
This commit is contained in:
parent
3953b116c7
commit
6fb150ba73
1 changed files with 20 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue