Skip to content

Commit

Permalink
Fix the unit tests with expired TUF metadata. (#1270)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dlorenc authored Jan 5, 2022
1 parent 242f586 commit 6af964c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions pkg/cosign/tuf/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6af964c

Please sign in to comment.