@@ -321,38 +321,36 @@ func TestNewPathHandlers(t *testing.T) {
321
321
322
322
func TestGetRoots (t * testing.T ) {
323
323
log := setupTestLog (t )
324
- server := setupTestServer (t , log , path .Join (prefix , "ct/v1/get-roots" ))
324
+ server := setupTestServer (t , log , path .Join (prefix , types . GetRootsPath ))
325
325
defer server .Close ()
326
326
327
- t .Run ("get-roots" , func (t * testing.T ) {
328
- resp , err := http .Get (server .URL + path .Join (prefix , "ct/v1/get-roots" ))
329
- if err != nil {
330
- t .Fatalf ("Failed to get roots: %v" , err )
331
- }
327
+ resp , err := http .Get (server .URL + path .Join (prefix , types .GetRootsPath ))
328
+ if err != nil {
329
+ t .Fatalf ("Failed to get roots: %v" , err )
330
+ }
332
331
333
- if resp .StatusCode != http .StatusOK {
334
- t .Errorf ("Unexpected status code: %v" , resp .StatusCode )
335
- }
332
+ if resp .StatusCode != http .StatusOK {
333
+ t .Errorf ("Unexpected status code: %v" , resp .StatusCode )
334
+ }
336
335
337
- var roots types.GetRootsResponse
338
- err = json .NewDecoder (resp .Body ).Decode (& roots )
339
- if err != nil {
340
- t .Errorf ("Failed to decode response: %v" , err )
341
- }
336
+ var roots types.GetRootsResponse
337
+ err = json .NewDecoder (resp .Body ).Decode (& roots )
338
+ if err != nil {
339
+ t .Errorf ("Failed to decode response: %v" , err )
340
+ }
342
341
343
- if got , want := len (roots .Certificates ), 1 ; got != want {
344
- t .Errorf ("Unexpected number of certificates: got %d, want %d" , got , want )
345
- }
342
+ if got , want := len (roots .Certificates ), 1 ; got != want {
343
+ t .Errorf ("Unexpected number of certificates: got %d, want %d" , got , want )
344
+ }
346
345
347
- got , err := base64 .StdEncoding .DecodeString (roots .Certificates [0 ])
348
- if err != nil {
349
- t .Errorf ("Failed to decode certificate: %v" , err )
350
- }
351
- want , _ := pem .Decode ([]byte (testdata .CACertPEM ))
352
- if ! bytes .Equal (got , want .Bytes ) {
353
- t .Errorf ("Unexpected root: got %s, want %s" , roots .Certificates [0 ], base64 .StdEncoding .EncodeToString (want .Bytes ))
354
- }
355
- })
346
+ got , err := base64 .StdEncoding .DecodeString (roots .Certificates [0 ])
347
+ if err != nil {
348
+ t .Errorf ("Failed to decode certificate: %v" , err )
349
+ }
350
+ want , _ := pem .Decode ([]byte (testdata .CACertPEM ))
351
+ if ! bytes .Equal (got , want .Bytes ) {
352
+ t .Errorf ("Unexpected root: got %s, want %s" , roots .Certificates [0 ], base64 .StdEncoding .EncodeToString (want .Bytes ))
353
+ }
356
354
}
357
355
358
356
// TODO(phboneff): this could just be a parseBodyJSONChain test
@@ -413,12 +411,12 @@ func TestAddChainWhitespace(t *testing.T) {
413
411
}
414
412
415
413
log := setupTestLog (t )
416
- server := setupTestServer (t , log , path .Join (prefix , "ct/v1/add-chain" ))
414
+ server := setupTestServer (t , log , path .Join (prefix , types . AddChainPath ))
417
415
defer server .Close ()
418
416
419
417
for _ , test := range tests {
420
418
t .Run (test .descr , func (t * testing.T ) {
421
- resp , err := http .Post (server .URL + "/ct/v1/add-chain" , "application/json" , strings .NewReader (test .body ))
419
+ resp , err := http .Post (server .URL + types . AddChainPath , "application/json" , strings .NewReader (test .body ))
422
420
if err != nil {
423
421
t .Fatalf ("http.Post(%s)=(_,%q); want (_,nil)" , types .AddChainPath , err )
424
422
}
@@ -459,15 +457,15 @@ func TestAddChain(t *testing.T) {
459
457
}
460
458
461
459
log := setupTestLog (t )
462
- server := setupTestServer (t , log , path .Join (prefix , "ct/v1/add-chain" ))
460
+ server := setupTestServer (t , log , path .Join (prefix , types . AddChainPath ))
463
461
defer server .Close ()
464
462
465
463
for _ , test := range tests {
466
464
t .Run (test .descr , func (t * testing.T ) {
467
465
pool := loadCertsIntoPoolOrDie (t , test .chain )
468
466
chain := createJSONChain (t , * pool )
469
467
470
- resp , err := http .Post (server .URL + "/ct/v1/add-chain" , "application/json" , chain )
468
+ resp , err := http .Post (server .URL + types . AddChainPath , "application/json" , chain )
471
469
if err != nil {
472
470
t .Fatalf ("http.Post(%s)=(_,%q); want (_,nil)" , types .AddChainPath , err )
473
471
}
@@ -535,15 +533,15 @@ func TestAddPreChain(t *testing.T) {
535
533
}
536
534
537
535
log := setupTestLog (t )
538
- server := setupTestServer (t , log , path .Join (prefix , "ct/v1/add-pre-chain" ))
536
+ server := setupTestServer (t , log , path .Join (prefix , types . AddPreChainPath ))
539
537
defer server .Close ()
540
538
541
539
for _ , test := range tests {
542
540
t .Run (test .descr , func (t * testing.T ) {
543
541
pool := loadCertsIntoPoolOrDie (t , test .chain )
544
542
chain := createJSONChain (t , * pool )
545
543
546
- resp , err := http .Post (server .URL + "/ct/v1/add-pre-chain" , "application/json" , chain )
544
+ resp , err := http .Post (server .URL + types . AddPreChainPath , "application/json" , chain )
547
545
if err != nil {
548
546
t .Fatalf ("http.Post(%s)=(_,%q); want (_,nil)" , types .AddPreChainPath , err )
549
547
}
0 commit comments