Skip to content

Commit

Permalink
Add test to verify that adding a delegation to an existing role doesn…
Browse files Browse the repository at this point in the history
…'t change signed targets
  • Loading branch information
ethan-lowman-dd committed Apr 14, 2022
1 parent ca452c5 commit be25f93
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,30 @@ func (rs *RepoSuite) TestDelegations(c *C) {
checkTargets("targets", "potato.txt")
checkTargets("role1", "A/apple.txt", "B/banana.txt", "A/allium.txt")
checkTargets("role2", "C/clementine.txt", "D/durian.txt")

// Add back the role1 -> role2 delegation, and verify that it doesn't change
// existing targets in role2.json.
err = r.AddDelegatedRole("role1", role1To2, []*data.PublicKey{
role1To2Key.PublicData(),
})
c.Assert(err, IsNil)
c.Assert(r.Snapshot(), IsNil)
c.Assert(r.Timestamp(), IsNil)
c.Assert(r.Commit(), IsNil)

snapshot, err = r.snapshot()
c.Assert(err, IsNil)
c.Assert(snapshot.Meta, HasLen, 3)
// Both role1 and role2 should have a bumped version.
// role1 is bumped because the delegations changed.
// role2 is only bumped because its expiration is bumped.
c.Assert(snapshot.Meta["targets.json"].Version, Equals, int64(3))
c.Assert(snapshot.Meta["role1.json"].Version, Equals, int64(5))
c.Assert(snapshot.Meta["role2.json"].Version, Equals, int64(5))

checkTargets("targets", "potato.txt")
checkTargets("role1", "A/apple.txt", "B/banana.txt", "A/allium.txt")
checkTargets("role2", "C/clementine.txt", "D/durian.txt")
}

func (rs *RepoSuite) TestHashBinDelegations(c *C) {
Expand Down

0 comments on commit be25f93

Please sign in to comment.