From 6af964c9a867dfb329d4e1ddedf2520e8f4b6eeb Mon Sep 17 00:00:00 2001 From: dlorenc Date: Wed, 5 Jan 2022 08:39:34 -0600 Subject: [PATCH] Fix the unit tests with expired TUF metadata. (#1270) 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)