Skip to content

Commit

Permalink
api: Remove unused getAllowRecord func
Browse files Browse the repository at this point in the history
Signed-off-by: Evgenii Baidakov <[email protected]>
  • Loading branch information
smallhive committed Aug 13, 2024
1 parent 165f9bf commit cb9212d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 19 deletions.
15 changes: 0 additions & 15 deletions api/handler/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1568,21 +1568,6 @@ func isValidGrant(grant *Grant) bool {
(grant.Grantee.Type == granteeCanonicalUser || (grant.Grantee.Type == granteeGroup && grant.Grantee.URI == allUsersGroup))
}

func getAllowRecord(op eacl.Operation, pk *keys.PublicKey) *eacl.Record {
record := eacl.NewRecord()
record.SetOperation(op)
record.SetAction(eacl.ActionAllow)

t := eacl.NewTarget()
// Unknown role is used, because it is ignored when keys are set
t.SetRole(eacl.RoleUnknown)
t.SetAccounts([]user.ID{user.NewFromScriptHash(pk.GetScriptHash())})

record.SetTargets(*t)

return record
}

func getAllowRecordWithUser(op eacl.Operation, acc user.ID) *eacl.Record {
record := eacl.NewRecord()
record.SetOperation(op)
Expand Down
8 changes: 4 additions & 4 deletions api/handler/acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -931,14 +931,14 @@ func allowedTableForPrivateObject(t *testing.T, key *keys.PrivateKey, resInfo *r
// Order of these loops is important for test.
for i := len(writeOps) - 1; i >= 0; i-- {
op := writeOps[i]
record := getAllowRecord(op, key.PublicKey())
record := getAllowRecordWithUser(op, user.NewFromScriptHash(key.GetScriptHash()))

applyFilters(record)
expectedTable.AddRecord(record)
}
for i := len(readOps) - 1; i >= 0; i-- {
op := readOps[i]
record := getAllowRecord(op, key.PublicKey())
record := getAllowRecordWithUser(op, user.NewFromScriptHash(key.GetScriptHash()))

applyFilters(record)
expectedTable.AddRecord(record)
Expand Down Expand Up @@ -1175,10 +1175,10 @@ func TestBucketAclToTable(t *testing.T) {
expectedTable.AddRecord(getOthersRecord(op, eacl.ActionAllow))
}
for _, op := range writeOps {
expectedTable.AddRecord(getAllowRecord(op, key2.PublicKey()))
expectedTable.AddRecord(getAllowRecordWithUser(op, user.NewFromScriptHash(key2.GetScriptHash())))
}
for _, op := range fullOps {
expectedTable.AddRecord(getAllowRecord(op, key.PublicKey()))
expectedTable.AddRecord(getAllowRecordWithUser(op, user.NewFromScriptHash(key.GetScriptHash())))
}
for _, op := range fullOps {
expectedTable.AddRecord(getOthersRecord(op, eacl.ActionDeny))
Expand Down

0 comments on commit cb9212d

Please sign in to comment.