From d1fae69624cc6d89c4aaa73f023bcaf4fe4d0758 Mon Sep 17 00:00:00 2001 From: Ethan Lowman Date: Fri, 7 Jan 2022 11:45:28 -0500 Subject: [PATCH] stash --- client/delegations_test.go | 9 ++++++++- internal/targets/delegation.go | 10 +++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/client/delegations_test.go b/client/delegations_test.go index 13625d12..cb4e63d9 100644 --- a/client/delegations_test.go +++ b/client/delegations_test.go @@ -1,6 +1,7 @@ package client import ( + "crypto/sha256" "encoding/json" "fmt" "io" @@ -26,7 +27,13 @@ func TestGetTargetMeta(t *testing.T) { f, err := c.getTargetFileMeta("f.txt") assert.Nil(t, err) - assert.Equal(t, int64(15), f.Length) + hash := sha256.Sum256([]byte("Contents: f.txt")) + assert.Equal(t, data.HexBytes(hash[:]), f.Hashes["sha256"]) + + f, err = c.getTargetFileMeta("targets.txt") + assert.Nil(t, err) + hash = sha256.Sum256([]byte("Contents: targets.txt")) + assert.Equal(t, data.HexBytes(hash[:]), f.Hashes["sha256"]) } func TestMaxDelegations(t *testing.T) { diff --git a/internal/targets/delegation.go b/internal/targets/delegation.go index 3823df4e..48dcef4f 100644 --- a/internal/targets/delegation.go +++ b/internal/targets/delegation.go @@ -2,7 +2,6 @@ package targets import ( "github.com/theupdateframework/go-tuf/data" - "github.com/theupdateframework/go-tuf/internal/sets" "github.com/theupdateframework/go-tuf/verify" ) @@ -21,11 +20,12 @@ type delegationsIterator struct { // NewDelegationsIterator initialises an iterator with a first step // on top level targets. func NewDelegationsIterator(target string, topLevelKeysDB *verify.DB) *delegationsIterator { - role := topLevelKeysDB.GetRole("targets") + // role := topLevelKeysDB.GetRole("targets") keyIDs := []string{} - if role != nil { - keyIDs = sets.StringSetToSlice(role.KeyIDs) - } + + // if role != nil { + // keyIDs = sets.StringSetToSlice(role.KeyIDs) + // } i := &delegationsIterator{ target: target,