diff --git a/src/caduceus/caduceus_test.go b/src/caduceus/caduceus_test.go index 32c3f87e..9216eb69 100644 --- a/src/caduceus/caduceus_test.go +++ b/src/caduceus/caduceus_test.go @@ -138,6 +138,7 @@ func TestServerHandler(t *testing.T) { } req := httptest.NewRequest("POST", "localhost:8080", strings.NewReader("Test payload.")) + badReq := httptest.NewRequest("GET", "localhost:8080", strings.NewReader("Test payload.")) t.Run("TestServeHTTPHappyPath", func(t *testing.T) { req.Header.Set("Content-Type", "application/json") @@ -151,6 +152,18 @@ func TestServerHandler(t *testing.T) { fakeHealth.AssertExpectations(t) }) + t.Run("TestServeHTTPBadMethod", func(t *testing.T) { + badReq.Header.Set("Content-Type", "application/json") + + w := httptest.NewRecorder() + serverWrapper.ServeHTTP(w, badReq) + resp := w.Result() + + assert.Equal(400, resp.StatusCode) + fakeHandler.AssertExpectations(t) + fakeHealth.AssertExpectations(t) + }) + t.Run("TestServeHTTPTooManyHeaders", func(t *testing.T) { req.Header.Add("Content-Type", "too/many/headers")