@@ -38,34 +38,33 @@ import (
3838 "testing"
3939
4040 "github.com/sigstore/rekor/pkg/sharding"
41-
42- "github.com/sigstore/rekor/pkg/util"
41+ e2eutil "github.com/sigstore/rekor/pkg/util/e2eutil"
4342)
4443
4544func TestDuplicates (t * testing.T ) {
4645 artifactPath := filepath .Join (t .TempDir (), "artifact" )
4746 sigPath := filepath .Join (t .TempDir (), "signature.asc" )
4847
49- util .CreatedPGPSignedArtifact (t , artifactPath , sigPath )
48+ e2eutil .CreatedPGPSignedArtifact (t , artifactPath , sigPath )
5049
5150 // Write the public key to a file
5251 pubPath := filepath .Join (t .TempDir (), "pubKey.asc" )
53- if err := ioutil .WriteFile (pubPath , []byte (util .PubKey ), 0644 ); err != nil {
52+ if err := ioutil .WriteFile (pubPath , []byte (e2eutil .PubKey ), 0644 ); err != nil {
5453 t .Fatal (err )
5554 }
5655
5756 // Now upload to rekor!
58- out := util .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
59- util .OutputContains (t , out , "Created entry at" )
57+ out := e2eutil .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
58+ e2eutil .OutputContains (t , out , "Created entry at" )
6059
6160 // Now upload the same one again, we should get a dupe entry.
62- out = util .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
63- util .OutputContains (t , out , "Entry already exists" )
61+ out = e2eutil .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
62+ e2eutil .OutputContains (t , out , "Entry already exists" )
6463
6564 // Now do a new one, we should get a new entry
66- util .CreatedPGPSignedArtifact (t , artifactPath , sigPath )
67- out = util .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
68- util .OutputContains (t , out , "Created entry at" )
65+ e2eutil .CreatedPGPSignedArtifact (t , artifactPath , sigPath )
66+ out = e2eutil .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
67+ e2eutil .OutputContains (t , out , "Created entry at" )
6968}
7069
7170// Smoke test to ensure we're publishing and recording metrics when an API is
@@ -143,7 +142,7 @@ func TestEnvVariableValidation(t *testing.T) {
143142 os .Setenv ("REKOR_FORMAT" , "bogus" )
144143 defer os .Unsetenv ("REKOR_FORMAT" )
145144
146- util .RunCliErr (t , "loginfo" )
145+ e2eutil .RunCliErr (t , "loginfo" )
147146}
148147func TestGetCLI (t * testing.T ) {
149148 // Create something and add it to the log
@@ -153,31 +152,31 @@ func TestGetCLI(t *testing.T) {
153152 os .Remove (artifactPath )
154153 os .Remove (sigPath )
155154 })
156- util .CreatedPGPSignedArtifact (t , artifactPath , sigPath )
155+ e2eutil .CreatedPGPSignedArtifact (t , artifactPath , sigPath )
157156
158157 // Write the public key to a file
159158 pubPath := filepath .Join (t .TempDir (), "pubKey.asc" )
160- if err := ioutil .WriteFile (pubPath , []byte (util .PubKey ), 0644 ); err != nil {
159+ if err := ioutil .WriteFile (pubPath , []byte (e2eutil .PubKey ), 0644 ); err != nil {
161160 t .Error (err )
162161 }
163162 t .Cleanup (func () {
164163 os .Remove (pubPath )
165164 })
166- out := util .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
167- util .OutputContains (t , out , "Created entry at" )
165+ out := e2eutil .RunCli (t , "upload" , "--artifact" , artifactPath , "--signature" , sigPath , "--public-key" , pubPath )
166+ e2eutil .OutputContains (t , out , "Created entry at" )
168167
169- uuid , err := sharding .GetUUIDFromIDString (util .GetUUIDFromUploadOutput (t , out ))
168+ uuid , err := sharding .GetUUIDFromIDString (e2eutil .GetUUIDFromUploadOutput (t , out ))
170169 if err != nil {
171170 t .Error (err )
172171 }
173172
174173 // since we at least have 1 valid entry, check the log at index 0
175- util .RunCli (t , "get" , "--log-index" , "0" )
174+ e2eutil .RunCli (t , "get" , "--log-index" , "0" )
176175
177- out = util .RunCli (t , "get" , "--format=json" , "--uuid" , uuid )
176+ out = e2eutil .RunCli (t , "get" , "--format=json" , "--uuid" , uuid )
178177
179178 // The output here should be in JSON with this structure:
180- g := util .GetOut {}
179+ g := e2eutil .GetOut {}
181180 if err := json .Unmarshal ([]byte (out ), & g ); err != nil {
182181 t .Error (err )
183182 }
@@ -186,35 +185,35 @@ func TestGetCLI(t *testing.T) {
186185 t .Errorf ("Expected IntegratedTime to be set. Got %s" , out )
187186 }
188187 // Get it with the logindex as well
189- util .RunCli (t , "get" , "--format=json" , "--log-index" , strconv .Itoa (g .LogIndex ))
188+ e2eutil .RunCli (t , "get" , "--format=json" , "--log-index" , strconv .Itoa (g .LogIndex ))
190189
191190 // check index via the file and public key to ensure that the index has updated correctly
192- out = util .RunCli (t , "search" , "--artifact" , artifactPath )
193- util .OutputContains (t , out , uuid )
191+ out = e2eutil .RunCli (t , "search" , "--artifact" , artifactPath )
192+ e2eutil .OutputContains (t , out , uuid )
194193
195- out = util .RunCli (t , "search" , "--public-key" , pubPath )
196- util .OutputContains (t , out , uuid )
194+ out = e2eutil .RunCli (t , "search" , "--public-key" , pubPath )
195+ e2eutil .OutputContains (t , out , uuid )
197196
198197 artifactBytes , err := ioutil .ReadFile (artifactPath )
199198 if err != nil {
200199 t .Error (err )
201200 }
202201 sha := sha256 .Sum256 (artifactBytes )
203202
204- out = util .RunCli (t , "search" , "--sha" , fmt .Sprintf ("sha256:%s" , hex .EncodeToString (sha [:])))
205- util .OutputContains (t , out , uuid )
203+ out = e2eutil .RunCli (t , "search" , "--sha" , fmt .Sprintf ("sha256:%s" , hex .EncodeToString (sha [:])))
204+ e2eutil .OutputContains (t , out , uuid )
206205
207206 // Exercise GET with the new EntryID (TreeID + UUID)
208207 tid := getTreeID (t )
209208 entryID , err := sharding .CreateEntryIDFromParts (fmt .Sprintf ("%x" , tid ), uuid )
210209 if err != nil {
211210 t .Error (err )
212211 }
213- out = util .RunCli (t , "get" , "--format=json" , "--uuid" , entryID .ReturnEntryIDString ())
212+ out = e2eutil .RunCli (t , "get" , "--format=json" , "--uuid" , entryID .ReturnEntryIDString ())
214213}
215214func getTreeID (t * testing.T ) int64 {
216215 t .Helper ()
217- out := util .RunCli (t , "loginfo" )
216+ out := e2eutil .RunCli (t , "loginfo" )
218217 tidStr := strings .TrimSpace (strings .Split (out , "TreeID: " )[1 ])
219218 tid , err := strconv .ParseInt (tidStr , 10 , 64 )
220219 if err != nil {
@@ -224,11 +223,11 @@ func getTreeID(t *testing.T) int64 {
224223 return tid
225224}
226225func TestSearchNoEntriesRC1 (t * testing.T ) {
227- util .
RunCliErr (
t ,
"search" ,
"--email" ,
"[email protected] " )
226+ e2eutil .
RunCliErr (
t ,
"search" ,
"--email" ,
"[email protected] " )
228227}
229228func TestHostnameInSTH (t * testing.T ) {
230229 // get ID of container
231- c := exec .Command ("docker" ,"ps" ,"-q" ,"-f" ,"name=rekor-server" )
230+ c := exec .Command ("docker" , "ps" , "-q" , "-f" , "name=rekor-server" )
232231 b , err := c .CombinedOutput ()
233232 if err != nil {
234233 t .Fatal (err )
@@ -261,19 +260,19 @@ func rekorServer() string {
261260func TestSearchSHA512 (t * testing.T ) {
262261 sha512 := "c7694a1112ea1404a3c5852bdda04c2cc224b3567ef6ceb8204dbf2b382daacfc6837ee2ed9d5b82c90b880a3c7289778dbd5a8c2c08193459bcf7bd44581ed0"
263262 var out string
264- out = util .RunCli (t , "upload" , "--type" , "intoto:0.0.2" ,
263+ out = e2eutil .RunCli (t , "upload" , "--type" , "intoto:0.0.2" ,
265264 "--artifact" , "tests/envelope.sha512" ,
266265 "--pki-format" , "x509" ,
267266 "--public-key" , "tests/test_sha512.pub" )
268- util .OutputContains (t , out , "Created entry at" )
269- uuid := util .GetUUIDFromTimestampOutput (t , out )
270- out = util .RunCli (t , "search" , "--sha" , fmt .Sprintf ("sha512:%s" , sha512 ))
271- util .OutputContains (t , out , uuid )
267+ e2eutil .OutputContains (t , out , "Created entry at" )
268+ uuid := e2eutil .GetUUIDFromTimestampOutput (t , out )
269+ out = e2eutil .RunCli (t , "search" , "--sha" , fmt .Sprintf ("sha512:%s" , sha512 ))
270+ e2eutil .OutputContains (t , out , uuid )
272271}
273272func TestVerifyNonExistentUUID (t * testing.T ) {
274273 // this uuid is extremely likely to not exist
275- out := util .RunCliErr (t , "verify" , "--uuid" , "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" )
276- util .OutputContains (t , out , "entry in log cannot be located" )
274+ out := e2eutil .RunCliErr (t , "verify" , "--uuid" , "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" )
275+ e2eutil .OutputContains (t , out , "entry in log cannot be located" )
277276
278277 // Check response code
279278 tid := getTreeID (t )
0 commit comments