Skip to content

Commit

Permalink
Merge pull request #92 from flynn/fix-local-expired-root
Browse files Browse the repository at this point in the history
client: Always initialize keys DB from local storage
  • Loading branch information
lmars committed Feb 11, 2016
2 parents 69ec51c + ada2115 commit 6093a53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 4 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,22 +267,21 @@ func (c *Client) getLocalMeta() error {
if err := json.Unmarshal(s.Signed, root); err != nil {
return err
}
db := keys.NewDB()
c.db = keys.NewDB()
for id, k := range root.Keys {
if err := db.AddKey(id, k); err != nil {
if err := c.db.AddKey(id, k); err != nil {
return err
}
}
for name, role := range root.Roles {
if err := db.AddRole(name, role); err != nil {
if err := c.db.AddRole(name, role); err != nil {
return err
}
}
if err := signed.Verify(s, "root", 0, db); err != nil {
if err := signed.Verify(s, "root", 0, c.db); err != nil {
return err
}
c.consistentSnapshot = root.ConsistentSnapshot
c.db = db
} else {
return ErrNoRootKeys
}
Expand Down
2 changes: 2 additions & 0 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ func (s *ClientSuite) TestUpdateLocalRootExpired(c *C) {
if _, ok := err.(signed.ErrExpired); !ok {
c.Fatalf("expected err to have type signed.ErrExpired, got %T", err)
}

client := NewClient(s.local, s.remote)
_, err = client.Update()
c.Assert(err, IsNil)
})
Expand Down

0 comments on commit 6093a53

Please sign in to comment.