@@ -34,6 +34,14 @@ var _ = Describe("HealthCheck suite", func() {
3434 Expect(rw.Code).To(Equal(in.expectedStatus))
3535 Expect(rw.Body.String()).To(Equal(in.expectedBody))
3636 },
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{},
42+ expectedStatus: 404,
43+ expectedBody: "404 page not found\n",
44+ }),
3745 Entry("when requesting the healthcheck path", &requestTableInput{
3846 healthCheckPaths: []string{"/ping"},
3947 healthCheckUserAgents: []string{"hc/1.0"},
@@ -50,15 +58,23 @@ var _ = Describe("HealthCheck suite", func() {
5058 expectedStatus: 404,
5159 expectedBody: "404 page not found\n",
5260 }),
53− Entry("with a request from the health check user agent", &requestTableInput{
54− healthCheckPaths: []string{"/ping"},
61+ Entry("when a blank string is configured as a health check path and the request has no specific path", &requestTableInput{
62+ healthCheckPaths: []string{""},
5563 healthCheckUserAgents: []string{"hc/1.0"},
64+ requestString: "http://example.com",
65+ headers: map[string]string{},
66+ expectedStatus: 404,
67+ expectedBody: "404 page not found\n",
68+ }),
69+ Entry("with no health check user agents configured", &requestTableInput{
70+ healthCheckPaths: []string{"/ping"},
71+ healthCheckUserAgents: []string{},
5672 requestString: "http://example.com/abc",
5773 headers: map[string]string{
58− "User-Agent": "hc/1.0",
74+ "User-Agent": "user",
5975 },
60− expectedStatus: 200,
61− expectedBody: "OK",
76+ expectedStatus: 404,
77+ expectedBody: "404 page not found\n",
6278 }),
6379 Entry("with a request from a different user agent", &requestTableInput{
6480 healthCheckPaths: []string{"/ping"},
@@ -70,6 +86,24 @@ var _ = Describe("HealthCheck suite", func() {
7086 expectedStatus: 404,
7187 expectedBody: "404 page not found\n",
7288 }),
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",
95+ },
96+ expectedStatus: 200,
97+ expectedBody: "OK",
98+ }),
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",
106+ }),
73107 Entry("with multiple paths, request one of the healthcheck paths", &requestTableInput{
74108 healthCheckPaths: []string{"/ping", "/liveness_check", "/readiness_check"},
75109 healthCheckUserAgents: []string{"hc/1.0"},