Skip to content

Commit

Permalink
fix(secrets): actually set updated_at and updated_by fields (#578)
Browse files Browse the repository at this point in the history
* bug fix for secret metadata updated by field

* make sure updated at gets same treatment
  • Loading branch information
ecrupper authored Jan 27, 2022
1 parent f40a1c9 commit eb7f283
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions secret/native/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,11 @@ func (c *client) Update(sType, org, name string, s *library.Secret) error {
sec.SetAllowCommand(s.GetAllowCommand())
}

// update updated_at if set
sec.SetUpdatedAt(s.GetUpdatedAt())

// update updated_by if set
sec.SetUpdatedBy(s.GetUpdatedBy())

return c.Database.UpdateSecret(sec)
}
18 changes: 17 additions & 1 deletion secret/native/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ import (

func TestNative_Update(t *testing.T) {
// setup types
original := new(library.Secret)
original.SetID(1)
original.SetOrg("foo")
original.SetRepo("bar")
original.SetTeam("")
original.SetName("baz")
original.SetValue("secretValue")
original.SetType("repo")
original.SetImages([]string{"foo", "baz"})
original.SetEvents([]string{"foob", "bar"})
original.SetAllowCommand(true)
original.SetCreatedAt(1)
original.SetCreatedBy("user")
original.SetUpdatedAt(1)
original.SetUpdatedBy("user")

want := new(library.Secret)
want.SetID(1)
want.SetOrg("foo")
Expand All @@ -40,7 +56,7 @@ func TestNative_Update(t *testing.T) {
_sql.Close()
}()

_ = db.CreateSecret(want)
_ = db.CreateSecret(original)

// run test
s, err := New(
Expand Down

0 comments on commit eb7f283

Please sign in to comment.