@@ -34,6 +34,14 @@ var _ = Describe("HealthCheck suite", func() {
34 Expect(rw.Code).To(Equal(in.expectedStatus))
34 Expect(rw.Code).To(Equal(in.expectedStatus))
35 Expect(rw.Body.String()).To(Equal(in.expectedBody))
35 Expect(rw.Body.String()).To(Equal(in.expectedBody))
37+ Entry("when no health check paths are configured", &requestTableInput{
38+ healthCheckPaths: []string{},
39+ healthCheckUserAgents: []string{"hc/1.0"},
40+ requestString: "http://example.com/ping",
41+ headers: map[string]string{},
43+ expectedBody: "404 page not found\n",
37 Entry("when requesting the healthcheck path", &requestTableInput{
45 Entry("when requesting the healthcheck path", &requestTableInput{
38 healthCheckPaths: []string{"/ping"},
46 healthCheckPaths: []string{"/ping"},
39 healthCheckUserAgents: []string{"hc/1.0"},
47 healthCheckUserAgents: []string{"hc/1.0"},
@@ -50,15 +58,23 @@ var _ = Describe("HealthCheck suite", func() {
50 expectedStatus: 404,
58 expectedStatus: 404,
51 expectedBody: "404 page not found\n",
59 expectedBody: "404 page not found\n",
53− Entry("with a request from the health check user agent", &requestTableInput{
61+ Entry("when a blank string is configured as a health check path and the request has no specific path", &requestTableInput{
54− healthCheckPaths: []string{"/ping"},
62+ healthCheckPaths: []string{""},
55 healthCheckUserAgents: []string{"hc/1.0"},
63 healthCheckUserAgents: []string{"hc/1.0"},
64+ requestString: "http://example.com",
65+ headers: map[string]string{},
67+ expectedBody: "404 page not found\n",
69+ Entry("with no health check user agents configured", &requestTableInput{
70+ healthCheckPaths: []string{"/ping"},
71+ healthCheckUserAgents: []string{},
56 requestString: "http://example.com/abc",
72 requestString: "http://example.com/abc",
57 headers: map[string]string{
73 headers: map[string]string{
58− "User-Agent": "hc/1.0",
74+ "User-Agent": "user",
60− expectedStatus: 200,
76+ expectedStatus: 404,
61− expectedBody: "OK",
77+ expectedBody: "404 page not found\n",
63 Entry("with a request from a different user agent", &requestTableInput{
79 Entry("with a request from a different user agent", &requestTableInput{
64 healthCheckPaths: []string{"/ping"},
80 healthCheckPaths: []string{"/ping"},
@@ -70,6 +86,24 @@ var _ = Describe("HealthCheck suite", func() {
70 expectedStatus: 404,
86 expectedStatus: 404,
71 expectedBody: "404 page not found\n",
87 expectedBody: "404 page not found\n",
89+ Entry("with a request from the health check user agent", &requestTableInput{
90+ healthCheckPaths: []string{"/ping"},
91+ healthCheckUserAgents: []string{"hc/1.0"},
92+ requestString: "http://example.com/abc",
93+ headers: map[string]string{
94+ "User-Agent": "hc/1.0",
99+ Entry("when a blank string is configured as a health check agent and a request has no user agent", &requestTableInput{
100+ healthCheckPaths: []string{"/ping"},
101+ healthCheckUserAgents: []string{""},
102+ requestString: "http://example.com/abc",
103+ headers: map[string]string{},
104+ expectedStatus: 404,
105+ expectedBody: "404 page not found\n",
73 Entry("with multiple paths, request one of the healthcheck paths", &requestTableInput{
107 Entry("with multiple paths, request one of the healthcheck paths", &requestTableInput{
74 healthCheckPaths: []string{"/ping", "/liveness_check", "/readiness_check"},
108 healthCheckPaths: []string{"/ping", "/liveness_check", "/readiness_check"},
75 healthCheckUserAgents: []string{"hc/1.0"},
109 healthCheckUserAgents: []string{"hc/1.0"},