Fix record owner management logic and tests

* The service improperly checked record value errors causing
  invalid owner update attempts to pass.
* Fixed invalid tests due to RBAC internal logic corrections and
  missing initial record ownership.
This commit is contained in:
Tomaž Jerman
2022-07-27 16:53:04 +02:00
parent 76b99bd0ed
commit 1ddb770f39
3 changed files with 5 additions and 2 deletions
+1 -1
View File
@@ -1042,7 +1042,7 @@ func (svc record) procUpdate(ctx context.Context, invokerID uint64, m *types.Mod
upd.DeletedAt = old.DeletedAt
upd.DeletedBy = old.DeletedBy
if err := SetRecordOwner(ctx, svc.ac, svc.store, old, upd, invokerID); err != nil {
if rve = SetRecordOwner(ctx, svc.ac, svc.store, old, upd, invokerID); !rve.IsValid() {
return
}
+1 -1
View File
@@ -914,7 +914,7 @@ func TestSetRecordOwner(t *testing.T) {
role = &sysTypes.Role{Name: "role-with-ownership-change-permission", ID: 3000}
mod = &types.Module{ID: 3}
mod = &types.Module{ID: 3, NamespaceID: 71624}
old, upd *types.Record
)
+3
View File
@@ -151,6 +151,9 @@ func (h helper) makeRecord(module *types.Module, rvs ...*types.RecordValue) *typ
CreatedAt: time.Now(),
ModuleID: module.ID,
NamespaceID: module.NamespaceID,
// Passing the current owner in here since the tests (who care about this)
// rely on it being set to something valid.
OwnedBy: h.cUser.ID,
// We are directly storing the record values here, so ensure
// everything is formatted in the same manner as it would be