Skip to content

Commit

Permalink
fix: fix null value on delegations roles (#415)
Browse files Browse the repository at this point in the history
* fix: fix null value on delegations roles

Signed-off-by: Asra Ali <asraa@google.com>
  • Loading branch information
asraa authored Sep 28, 2022
1 parent 9be8aa3 commit 701f334
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
9 changes: 4 additions & 5 deletions cmd/tuf/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ func InitCmd(ctx context.Context, directory, previous string,
}
}

// Reset and delegations: they will be updated in DelegationCmd.
if err := repo.ResetTargetsDelegationsWithExpires("targets", GetExpiration("targets")); err != nil {
return err
}

if err := repo.SetThreshold("targets", threshold); err != nil {
return err
}
Expand All @@ -254,6 +249,10 @@ func InitCmd(ctx context.Context, directory, previous string,
if err != nil {
return err
}
// We reset and delegations: they will be updated in DelegationCmd.
// TODO(https://github.com/theupdateframework/go-tuf/issues/402): replace
// with `repo.ResetTargetsDelegationsWithExpires` when this issue is resolved.
t.Delegations = nil
targetKeys, err := prepo.GetSigningKeyIDsForRole("targets", store)
if err != nil {
return err
Expand Down
7 changes: 2 additions & 5 deletions tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1056,10 +1056,7 @@ func TestDelegationsClearedOnInit(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(targets.Delegations.Roles) != 0 {
t.Errorf("Expected top-level targets delegation roles to be cleared")
}
if len(targets.Delegations.Keys) != 0 {
t.Errorf("Expected top-level targets delegation keys to be cleared")
if targets.Delegations != nil {
t.Errorf("Expected top-level targets delegations to be cleared")
}
}

0 comments on commit 701f334

Please sign in to comment.