Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix null value on delegations roles #415

Merged
merged 2 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cmd/tuf/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,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 @@ -262,6 +257,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")
}
}