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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user