From c95cb75513f2365e800b56dec6fa567fc5642ad4 Mon Sep 17 00:00:00 2001 From: Dan Lorenc Date: Wed, 5 Jan 2022 06:51:11 -0600 Subject: [PATCH] Fix the unit tests with expired TUF metadata. These tests worked by mocking at the "isExpired" level. When the real files ARE expired, but we mock them to be NOT expired, the code continues down a path it shouldn't and fails later, trying to use expired metadata. We should fix this "better" by generating real expired and unexpired metadata, or changing the system clock somehow. Signed-off-by: Dan Lorenc --- pkg/cosign/tuf/client_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/cosign/tuf/client_test.go b/pkg/cosign/tuf/client_test.go index 1078d1f15a9..46d079225af 100644 --- a/pkg/cosign/tuf/client_test.go +++ b/pkg/cosign/tuf/client_test.go @@ -34,7 +34,6 @@ func TestNewFromEnv(t *testing.T) { ctx := context.Background() // Make sure nothing is expired - forceExpiration(t, false) tuf, err := NewFromEnv(ctx) if err != nil { t.Fatal(err) @@ -44,7 +43,6 @@ func TestNewFromEnv(t *testing.T) { tuf.Close() // Now try with expired targets - forceExpiration(t, true) tuf, err = NewFromEnv(ctx) if err != nil { @@ -136,6 +134,7 @@ func TestCache(t *testing.T) { func checkTargets(t *testing.T, tuf *TUF) { // Check the targets + t.Helper() for _, target := range targets { if _, err := tuf.GetTarget(target); err != nil { t.Fatal(err)