@@ -114,7 +114,7 @@ func TestNewPiholeClientV6(t *testing.T) {
114
114
115
115
// Create a test server
116
116
srvr := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
117
- if r .URL .Path == "/api/auth" && r .Method == "POST" {
117
+ if r .URL .Path == "/api/auth" && r .Method == http . MethodPost {
118
118
var requestData map [string ]string
119
119
json .NewDecoder (r .Body ).Decode (& requestData )
120
120
defer r .Body .Close ()
@@ -178,7 +178,7 @@ func TestNewPiholeClientV6(t *testing.T) {
178
178
func TestListRecordsV6 (t * testing.T ) {
179
179
// Create a test server
180
180
srvr := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
181
- if r .URL .Path == "/api/config/dns/hosts" && r .Method == "GET" {
181
+ if r .URL .Path == "/api/config/dns/hosts" && r .Method == http . MethodGet {
182
182
183
183
w .WriteHeader (http .StatusOK )
184
184
w .Header ().Set ("Content-Type" , "application/json" )
@@ -201,7 +201,7 @@ func TestListRecordsV6(t *testing.T) {
201
201
},
202
202
"took": 5
203
203
}` ))
204
- } else if r .URL .Path == "/api/config/dns/cnameRecords" && r .Method == "GET" {
204
+ } else if r .URL .Path == "/api/config/dns/cnameRecords" && r .Method == http . MethodGet {
205
205
206
206
w .WriteHeader (http .StatusOK )
207
207
w .Header ().Set ("Content-Type" , "application/json" )
@@ -373,7 +373,7 @@ func TestErrorsV6(t *testing.T) {
373
373
374
374
// bad record format return by server
375
375
srvrErr := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
376
- if r .URL .Path == "/api/config/dns/hosts" && r .Method == "GET" {
376
+ if r .URL .Path == "/api/config/dns/hosts" && r .Method == http . MethodGet {
377
377
w .WriteHeader (http .StatusOK )
378
378
w .Header ().Set ("Content-Type" , "application/json" )
379
379
@@ -388,7 +388,7 @@ func TestErrorsV6(t *testing.T) {
388
388
},
389
389
"took": 5
390
390
}` ))
391
- } else if r .URL .Path == "/api/config/dns/cnameRecords" && r .Method == "GET" {
391
+ } else if r .URL .Path == "/api/config/dns/cnameRecords" && r .Method == http . MethodGet {
392
392
w .WriteHeader (http .StatusOK )
393
393
w .Header ().Set ("Content-Type" , "application/json" )
394
394
@@ -439,7 +439,7 @@ func TestErrorsV6(t *testing.T) {
439
439
440
440
func TestTokenValidity (t * testing.T ) {
441
441
srvok := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
442
- if r .URL .Path == "/api/auth" && r .Method == "GET" {
442
+ if r .URL .Path == "/api/auth" && r .Method == http . MethodGet {
443
443
w .WriteHeader (http .StatusOK )
444
444
w .Header ().Set ("Content-Type" , "application/json" )
445
445
@@ -475,7 +475,7 @@ func TestTokenValidity(t *testing.T) {
475
475
// Create a test server
476
476
srvr := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
477
477
478
- if r .URL .Path == "/api/auth" && r .Method == "GET" {
478
+ if r .URL .Path == "/api/auth" && r .Method == http . MethodGet {
479
479
w .WriteHeader (http .StatusOK )
480
480
w .Header ().Set ("Content-Type" , "application/json" )
481
481
@@ -527,7 +527,7 @@ func TestTokenValidity(t *testing.T) {
527
527
func TestDo (t * testing.T ) {
528
528
529
529
srvDo := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
530
- if r .URL .Path == "/api/auth/ok" && r .Method == "GET" {
530
+ if r .URL .Path == "/api/auth/ok" && r .Method == http . MethodGet {
531
531
w .Header ().Set ("Content-Type" , "application/json" )
532
532
w .WriteHeader (http .StatusOK )
533
533
// Return bad content
@@ -542,7 +542,7 @@ func TestDo(t *testing.T) {
542
542
},
543
543
"took": 0.16
544
544
}` ))
545
- } else if r .URL .Path == "/api/auth" && r .Method == "POST" {
545
+ } else if r .URL .Path == "/api/auth" && r .Method == http . MethodPost {
546
546
w .Header ().Set ("Content-Type" , "application/json" )
547
547
w .WriteHeader (http .StatusOK )
548
548
// Return bad content
@@ -557,7 +557,7 @@ func TestDo(t *testing.T) {
557
557
},
558
558
"took": 0.15
559
559
}` ))
560
- } else if r .URL .Path == "/api/auth" && r .Method == "GET" {
560
+ } else if r .URL .Path == "/api/auth" && r .Method == http . MethodGet {
561
561
w .WriteHeader (http .StatusUnauthorized )
562
562
// Return bad content
563
563
w .Write ([]byte (`{
@@ -568,7 +568,7 @@ func TestDo(t *testing.T) {
568
568
},
569
569
"took": 0.14
570
570
}` ))
571
- } else if r .URL .Path == "/api/auth/418" && r .Method == "GET" {
571
+ } else if r .URL .Path == "/api/auth/418" && r .Method == http . MethodGet {
572
572
w .WriteHeader (http .StatusTeapot )
573
573
// Return bad content
574
574
w .Write ([]byte (`{
@@ -579,11 +579,11 @@ func TestDo(t *testing.T) {
579
579
},
580
580
"took": 0.13
581
581
}` ))
582
- } else if r .URL .Path == "/api/auth/nojson" && r .Method == "GET" {
582
+ } else if r .URL .Path == "/api/auth/nojson" && r .Method == http . MethodGet {
583
583
// Return bad content
584
584
w .WriteHeader (http .StatusTeapot )
585
585
w .Write ([]byte (`Not a JSON` ))
586
- } else if r .URL .Path == "/api/auth/401" && r .Method == "GET" {
586
+ } else if r .URL .Path == "/api/auth/401" && r .Method == http . MethodGet {
587
587
w .WriteHeader (http .StatusUnauthorized )
588
588
// Return bad content
589
589
w .Write ([]byte (`{
@@ -655,7 +655,7 @@ func TestDo(t *testing.T) {
655
655
func TestDoRetryOne (t * testing.T ) {
656
656
nbCall := 0
657
657
srvRetry := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
658
- if r .URL .Path == "/api/auth" && r .Method == "GET" {
658
+ if r .URL .Path == "/api/auth" && r .Method == http . MethodGet {
659
659
w .Header ().Set ("Content-Type" , "application/json" )
660
660
w .WriteHeader (http .StatusOK )
661
661
// Return bad content
@@ -670,7 +670,7 @@ func TestDoRetryOne(t *testing.T) {
670
670
},
671
671
"took": 0.24
672
672
}` ))
673
- } else if r .URL .Path == "/api/auth/401" && r .Method == "GET" {
673
+ } else if r .URL .Path == "/api/auth/401" && r .Method == http . MethodGet {
674
674
if nbCall == 0 {
675
675
w .WriteHeader (http .StatusUnauthorized )
676
676
// Return bad content
@@ -713,7 +713,7 @@ func TestDoRetryOne(t *testing.T) {
713
713
func TestCreateRecordV6 (t * testing.T ) {
714
714
var ep * endpoint.Endpoint
715
715
srvr := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
716
- if r .Method == "PUT" && (r .URL .Path == "/api/config/dns/hosts/192.168.1.1 test.example.com" ||
716
+ if r .Method == http . MethodPut && (r .URL .Path == "/api/config/dns/hosts/192.168.1.1 test.example.com" ||
717
717
r .URL .Path == "/api/config/dns/hosts/fc00::1:192:168:1:1 test.example.com" ||
718
718
r .URL .Path == "/api/config/dns/cnameRecords/source1.example.com,target1.domain.com" ||
719
719
r .URL .Path == "/api/config/dns/cnameRecords/source2.example.com,target2.domain.com,500" ) {
@@ -846,7 +846,7 @@ func TestCreateRecordV6(t *testing.T) {
846
846
func TestDeleteRecordV6 (t * testing.T ) {
847
847
var ep * endpoint.Endpoint
848
848
srvr := newTestServerV6 (t , func (w http.ResponseWriter , r * http.Request ) {
849
- if r .Method == "DELETE" && (r .URL .Path == "/api/config/dns/hosts/192.168.1.1 test.example.com" ||
849
+ if r .Method == http . MethodDelete && (r .URL .Path == "/api/config/dns/hosts/192.168.1.1 test.example.com" ||
850
850
r .URL .Path == "/api/config/dns/hosts/fc00::1:192:168:1:1 test.example.com" ||
851
851
r .URL .Path == "/api/config/dns/cnameRecords/source1.example.com,target1.domain.com" ||
852
852
r .URL .Path == "/api/config/dns/cnameRecords/source2.example.com,target2.domain.com,500" ) {
0 commit comments