diff --git a/gandalftest/server.go b/gandalftest/server.go index 1d2442b..c27b9ee 100644 --- a/gandalftest/server.go +++ b/gandalftest/server.go @@ -194,6 +194,7 @@ func (s *GandalfServer) buildMuxer() { s.muxer.Post("/repository", http.HandlerFunc(s.createRepository)) s.muxer.Delete("/repository/{name}", http.HandlerFunc(s.removeRepository)) s.muxer.Get("/repository/{name}", http.HandlerFunc(s.getRepository)) + s.muxer.Get("/healthcheck", http.HandlerFunc(s.healthcheck)) } func (s *GandalfServer) createUser(w http.ResponseWriter, r *http.Request) { @@ -456,6 +457,10 @@ func (s *GandalfServer) listKeys(w http.ResponseWriter, r *http.Request) { } } +func (s *GandalfServer) healthcheck(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("WORKING")) +} + func (s *GandalfServer) findUser(name string) (userName string, index int) { s.usersLock.RLock() defer s.usersLock.RUnlock() diff --git a/gandalftest/server_test.go b/gandalftest/server_test.go index e6ecb2c..8ab2a1d 100644 --- a/gandalftest/server_test.go +++ b/gandalftest/server_test.go @@ -624,6 +624,17 @@ func (s *S) TestRevokeAccessMissingRepositories(c *check.C) { c.Assert(recorder.Body.String(), check.Equals, "missing repositories\n") } +func (s *S) TestHealthCheck(c *check.C) { + server, err := NewServer("127.0.0.1:0") + c.Assert(err, check.IsNil) + defer server.Stop() + recorder := httptest.NewRecorder() + request, _ := http.NewRequest("GET", "/healthcheck", nil) + server.ServeHTTP(recorder, request) + c.Assert(recorder.Code, check.Equals, http.StatusOK) + c.Assert(recorder.Body.String(), check.Equals, "WORKING") +} + func (s *S) TestPrepareFailure(c *check.C) { server, err := NewServer("127.0.0.1:0") c.Assert(err, check.IsNil)