@@ -14,11 +14,13 @@ import (
1414)
1515
1616const (
17- testDeviceID = "test-device"
18- testAllowPath = "/v1/data/keep/allow"
19- testClientRemoteIP = "100.65.1.1:12345"
20- resultKey = "result"
21- decisionKey = "decision"
17+ testDeviceID = "test-device"
18+ testAllowPath = "/v1/data/keep/allow"
19+ testClientRemoteIP = "100.65.1.1:12345"
20+ resultKey = "result"
21+ decisionKey = "decision"
22+ testRejectsNonPOST = testRejectsNonPOST
23+ testRejectsInvalidJSON = testRejectsInvalidJSON
2224)
2325
2426// TestServer_healthHandler tests the health endpoint
@@ -52,7 +54,7 @@ func TestServer_healthHandler(t *testing.T) {
5254func TestServer_verifyHandler (t * testing.T ) {
5355 server := createTestServer (t )
5456
55- t .Run ("rejects non-POST methods" , func (t * testing.T ) {
57+ t .Run (testRejectsNonPOST , func (t * testing.T ) {
5658 req := httptest .NewRequest (http .MethodGet , "/v1/auth/verify" , nil )
5759 rr := httptest .NewRecorder ()
5860
@@ -63,7 +65,7 @@ func TestServer_verifyHandler(t *testing.T) {
6365 }
6466 })
6567
66- t .Run ("rejects invalid JSON" , func (t * testing.T ) {
68+ t .Run (testRejectsInvalidJSON , func (t * testing.T ) {
6769 req := httptest .NewRequest (http .MethodPost , "/v1/auth/verify" , bytes .NewReader ([]byte ("invalid json" )))
6870 rr := httptest .NewRecorder ()
6971
@@ -187,7 +189,7 @@ func TestServer_envoyAuthHandler(t *testing.T) {
187189
188190 server := createTestServerWithMocks (t , mockOPA .URL , mockInventory .URL )
189191
190- t .Run ("rejects non-POST methods" , func (t * testing.T ) {
192+ t .Run (testRejectsNonPOST , func (t * testing.T ) {
191193 req := httptest .NewRequest (http .MethodGet , "/v1/auth/check" , nil )
192194 rr := httptest .NewRecorder ()
193195
@@ -198,7 +200,7 @@ func TestServer_envoyAuthHandler(t *testing.T) {
198200 }
199201 })
200202
201- t .Run ("rejects invalid JSON" , func (t * testing.T ) {
203+ t .Run (testRejectsInvalidJSON , func (t * testing.T ) {
202204 req := httptest .NewRequest (http .MethodPost , "/v1/auth/check" , bytes .NewReader ([]byte ("invalid json" )))
203205 rr := httptest .NewRecorder ()
204206
@@ -513,7 +515,7 @@ func TestServer_lookupDevice(t *testing.T) {
513515func TestServer_deviceCertHandler (t * testing.T ) {
514516 server := createTestServer (t )
515517
516- t .Run ("rejects non-POST methods" , func (t * testing.T ) {
518+ t .Run (testRejectsNonPOST , func (t * testing.T ) {
517519 req := httptest .NewRequest (http .MethodGet , "/v1/certs/device" , nil )
518520 rr := httptest .NewRecorder ()
519521
@@ -524,7 +526,7 @@ func TestServer_deviceCertHandler(t *testing.T) {
524526 }
525527 })
526528
527- t .Run ("rejects invalid JSON" , func (t * testing.T ) {
529+ t .Run (testRejectsInvalidJSON , func (t * testing.T ) {
528530 req := httptest .NewRequest (http .MethodPost , "/v1/certs/device" , bytes .NewReader ([]byte ("invalid json" )))
529531 rr := httptest .NewRecorder ()
530532
0 commit comments