Skip to content

Commit ea26c5c

Browse files
committed
Skip harness tests if rekor-cli is incompatible with rekor-server version
Signed-off-by: Priya Wadhwa <priya@chainguard.dev>
1 parent f1bc29b commit ea26c5c

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

tests/harness_test.go

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ func TestHarnessAddEntry(t *testing.T) {
7777
uuid := getUUIDFromUploadOutput(t, out)
7878
logIndex := getLogIndexFromUploadOutput(t, out)
7979

80-
// Now we should be able to verify it.
81-
out = runCli(t, "verify", "--type=hashedrekord", "--pki-format=x509", "--artifact-hash", dataSHA, "--signature", sigPath, "--public-key", pubPath)
82-
outputContains(t, out, "Inclusion Proof:")
80+
if !rekorCLIIncompatible() {
81+
// Now we should be able to verify it.
82+
out = runCli(t, "verify", "--type=hashedrekord", "--pki-format=x509", "--artifact-hash", dataSHA, "--signature", sigPath, "--public-key", pubPath)
83+
outputContains(t, out, "Inclusion Proof:")
84+
}
85+
8386
saveEntry(t, logIndex, StoredEntry{UUID: uuid})
8487
}
8588

@@ -155,7 +158,7 @@ func TestHarnessAddIntoto(t *testing.T) {
155158
uuid := getUUIDFromUploadOutput(t, out)
156159
logIndex := getLogIndexFromUploadOutput(t, out)
157160

158-
out = runCli(t, "get", "--uuid", uuid, "--format=json")
161+
out = runCli(t, "get", "--log-index", fmt.Sprintf("%d", logIndex), "--format=json")
159162
g := getOut{}
160163
if err := json.Unmarshal([]byte(out), &g); err != nil {
161164
t.Fatal(err)
@@ -265,11 +268,16 @@ func TestHarnessGetAllEntriesLogIndex(t *testing.T) {
265268
}
266269

267270
func TestHarnessGetAllEntriesUUID(t *testing.T) {
271+
if rekorCLIIncompatible() {
272+
t.Skipf("Skipping getting entries by UUID, old rekor-cli version %s is incompatible with server version %s", os.Getenv("CLI_VERSION"), os.Getenv("SERVER_VERSION"))
273+
}
274+
268275
treeSize := activeTreeSize(t)
269276
if treeSize == 0 {
270277
t.Fatal("There are 0 entries in the log, there should be at least 2")
271278
}
272279
_, entries := getEntries(t)
280+
273281
for _, e := range entries {
274282
outUUID := runCli(t, "get", "--uuid", e.UUID, "--format", "json")
275283
outEntryID := runCli(t, "get", "--uuid", entryID(t, e.UUID), "--format", "json")
@@ -294,6 +302,9 @@ func TestHarnessGetAllEntriesUUID(t *testing.T) {
294302
}
295303

296304
func entryID(t *testing.T, uuid string) string {
305+
if sharding.ValidateEntryID(uuid) == nil {
306+
return uuid
307+
}
297308
treeID, err := strconv.Atoi(os.Getenv("TREE_ID"))
298309
if err != nil {
299310
t.Fatal(err)
@@ -317,3 +328,14 @@ func activeTreeSize(t *testing.T) int {
317328
}
318329
return s.ActiveTreeSize
319330
}
331+
332+
// Check if we have a new server version and an old CLI version
333+
// since the new server returns an EntryID but the old CLI version expects a UUID
334+
func rekorCLIIncompatible() bool {
335+
if sv := os.Getenv("SERVER_VERSION"); sv != "v0.10.0" && sv != "v0.11.0" {
336+
if cv := os.Getenv("CLI_VERSION"); cv == "v0.10.0" || cv == "v0.11.0" {
337+
return true
338+
}
339+
}
340+
return false
341+
}

tests/rekor-harness.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function run_tests () {
7575
trap "rm -rf $REKORTMPDIR" EXIT
7676

7777
go clean -testcache
78-
if ! REKORTMPDIR=$REKORTMPDIR go test -run TestHarness -v -tags=e2e ./tests/ ; then
78+
if ! REKORTMPDIR=$REKORTMPDIR SERVER_VERSION=$1 CLI_VERSION=$2 go test -run TestHarness -v -tags=e2e ./tests/ ; then
7979
docker-compose logs --no-color > /tmp/docker-compose.log
8080
exit 1
8181
fi
@@ -112,7 +112,7 @@ do
112112
echo "Running tests with server version $server_version and CLI version $cli_version"
113113

114114
build_cli $cli_version
115-
run_tests
115+
run_tests $server_version $cli_version
116116

117117
echo "Tests passed successfully."
118118
echo "======================================================="

0 commit comments

Comments
 (0)