@@ -35,15 +35,14 @@ import (
35
35
"github.com/google/go-cmp/cmp"
36
36
"github.com/google/go-cmp/cmp/cmpopts"
37
37
"github.com/transparency-dev/static-ct/internal/testdata"
38
+ "github.com/transparency-dev/static-ct/internal/types"
38
39
"github.com/transparency-dev/static-ct/mockstorage"
39
40
"github.com/transparency-dev/static-ct/modules/dedup"
40
41
"github.com/transparency-dev/trillian-tessera/ctonly"
41
42
"google.golang.org/grpc/codes"
42
43
"google.golang.org/grpc/status"
43
44
"google.golang.org/protobuf/proto"
44
45
"k8s.io/klog/v2"
45
-
46
- ct "github.com/google/certificate-transparency-go"
47
46
)
48
47
49
48
// Arbitrary time for use in tests
@@ -57,7 +56,7 @@ var origin = "example.com"
57
56
var fakeDeadlineTime = time .Date (2016 , 7 , 22 , 11 , 01 , 13 , 500 * 1000 * 1000 , time .UTC )
58
57
var fakeTimeSource = newFixedTimeSource (fakeTime )
59
58
60
- var entrypaths = []string {origin + ct .AddChainPath , origin + ct .AddPreChainPath , origin + ct .GetRootsPath }
59
+ var entrypaths = []string {origin + types .AddChainPath , origin + types .AddPreChainPath , origin + types .GetRootsPath }
61
60
62
61
type handlerTestInfo struct {
63
62
mockCtrl * gomock.Controller
@@ -99,7 +98,7 @@ func setupTest(t *testing.T, pemRoots []string, signer crypto.Signer) handlerTes
99
98
RequestLog : new (DefaultRequestLog ),
100
99
TimeSource : fakeTimeSource ,
101
100
}
102
- signSCT := func (leaf * ct .MerkleTreeLeaf ) (* ct .SignedCertificateTimestamp , error ) {
101
+ signSCT := func (leaf * types .MerkleTreeLeaf ) (* types .SignedCertificateTimestamp , error ) {
103
102
return buildV1SCT (signer , leaf )
104
103
}
105
104
log := log {
@@ -121,27 +120,27 @@ func setupTest(t *testing.T, pemRoots []string, signer crypto.Signer) handlerTes
121
120
122
121
func (info handlerTestInfo ) getHandlers (t * testing.T ) pathHandlers {
123
122
t .Helper ()
124
- handler , ok := info .handlers [origin + ct .GetRootsPath ]
123
+ handler , ok := info .handlers [origin + types .GetRootsPath ]
125
124
if ! ok {
126
- t .Fatalf ("%q path not registered" , ct .GetRootsPath )
125
+ t .Fatalf ("%q path not registered" , types .GetRootsPath )
127
126
}
128
- return pathHandlers {origin + ct .GetRootsPath : handler }
127
+ return pathHandlers {origin + types .GetRootsPath : handler }
129
128
}
130
129
131
130
func (info handlerTestInfo ) postHandlers (t * testing.T ) pathHandlers {
132
131
t .Helper ()
133
- addChainHandler , ok := info .handlers [origin + ct .AddChainPath ]
132
+ addChainHandler , ok := info .handlers [origin + types .AddChainPath ]
134
133
if ! ok {
135
- t .Fatalf ("%q path not registered" , ct .AddPreChainStr )
134
+ t .Fatalf ("%q path not registered" , types .AddPreChainStr )
136
135
}
137
- addPreChainHandler , ok := info .handlers [origin + ct .AddPreChainPath ]
136
+ addPreChainHandler , ok := info .handlers [origin + types .AddPreChainPath ]
138
137
if ! ok {
139
- t .Fatalf ("%q path not registered" , ct .AddPreChainStr )
138
+ t .Fatalf ("%q path not registered" , types .AddPreChainStr )
140
139
}
141
140
142
141
return map [string ]appHandler {
143
- origin + ct .AddChainPath : addChainHandler ,
144
- origin + ct .AddPreChainPath : addPreChainHandler ,
142
+ origin + types .AddChainPath : addChainHandler ,
143
+ origin + types .AddPreChainPath : addPreChainHandler ,
145
144
}
146
145
}
147
146
@@ -339,7 +338,7 @@ func TestAddChainWhitespace(t *testing.T) {
339
338
recorder := httptest .NewRecorder ()
340
339
handler , ok := info .handlers ["example.com/ct/v1/add-chain" ]
341
340
if ! ok {
342
- t .Fatalf ("%q path not registered" , ct .AddChainStr )
341
+ t .Fatalf ("%q path not registered" , types .AddChainStr )
343
342
}
344
343
req , err := http .NewRequest (http .MethodPost , "http://example.com/ct/v1/add-chain" , strings .NewReader (test .body ))
345
344
if err != nil {
@@ -422,12 +421,12 @@ func TestAddChain(t *testing.T) {
422
421
t .Fatalf ("addChain()=%d (body:%v); want %dv" , recorder .Code , recorder .Body , test .want )
423
422
}
424
423
if test .want == http .StatusOK {
425
- var resp ct .AddChainResponse
424
+ var resp types .AddChainResponse
426
425
if err := json .NewDecoder (recorder .Body ).Decode (& resp ); err != nil {
427
426
t .Fatalf ("json.Decode(%s)=%v; want nil" , recorder .Body .Bytes (), err )
428
427
}
429
428
430
- if got , want := ct .Version (resp .SCTVersion ), ct .V1 ; got != want {
429
+ if got , want := types .Version (resp .SCTVersion ), types .V1 ; got != want {
431
430
t .Errorf ("resp.SCTVersion=%v; want %v" , got , want )
432
431
}
433
432
if got , want := resp .ID , demoLogID [:]; ! bytes .Equal (got , want ) {
@@ -519,12 +518,12 @@ func TestAddPrechain(t *testing.T) {
519
518
t .Fatalf ("addPrechain()=%d (body:%v); want %d" , recorder .Code , recorder .Body , test .want )
520
519
}
521
520
if test .want == http .StatusOK {
522
- var resp ct .AddChainResponse
521
+ var resp types .AddChainResponse
523
522
if err := json .NewDecoder (recorder .Body ).Decode (& resp ); err != nil {
524
523
t .Fatalf ("json.Decode(%s)=%v; want nil" , recorder .Body .Bytes (), err )
525
524
}
526
525
527
- if got , want := ct .Version (resp .SCTVersion ), ct .V1 ; got != want {
526
+ if got , want := types .Version (resp .SCTVersion ), types .V1 ; got != want {
528
527
t .Errorf ("resp.SCTVersion=%v; want %v" , got , want )
529
528
}
530
529
if got , want := resp .ID , demoLogID [:]; ! bytes .Equal (got , want ) {
@@ -543,7 +542,7 @@ func TestAddPrechain(t *testing.T) {
543
542
544
543
func createJSONChain (t * testing.T , p x509util.PEMCertPool ) io.Reader {
545
544
t .Helper ()
546
- var req ct .AddChainRequest
545
+ var req types .AddChainRequest
547
546
for _ , rawCert := range p .RawCertificates () {
548
547
req .Chain = append (req .Chain , rawCert .Raw )
549
548
}
@@ -590,18 +589,18 @@ func (d dlMatcher) String() string {
590
589
591
590
func makeAddPrechainRequest (t * testing.T , handlers pathHandlers , body io.Reader ) * httptest.ResponseRecorder {
592
591
t .Helper ()
593
- handler , ok := handlers [origin + ct .AddPreChainPath ]
592
+ handler , ok := handlers [origin + types .AddPreChainPath ]
594
593
if ! ok {
595
- t .Fatalf ("%q path not registered" , ct .AddPreChainStr )
594
+ t .Fatalf ("%q path not registered" , types .AddPreChainStr )
596
595
}
597
596
return makeAddChainRequestInternal (t , handler , "add-pre-chain" , body )
598
597
}
599
598
600
599
func makeAddChainRequest (t * testing.T , handlers pathHandlers , body io.Reader ) * httptest.ResponseRecorder {
601
600
t .Helper ()
602
- handler , ok := handlers [origin + ct .AddChainPath ]
601
+ handler , ok := handlers [origin + types .AddChainPath ]
603
602
if ! ok {
604
- t .Fatalf ("%q path not registered" , ct .AddChainStr )
603
+ t .Fatalf ("%q path not registered" , types .AddChainStr )
605
604
}
606
605
return makeAddChainRequestInternal (t , handler , "add-chain" , body )
607
606
}
0 commit comments