mirror of
https://github.com/eosswedenorg/thalos
synced 2026-10-18 03:46:45 +02:00
internal/types/blacklist: fix IsDenied semantics
This commit is contained in:
parent
4d93cc6379
commit
09284231ed
2 changed files with 17 additions and 1 deletions
|
|
@ -55,5 +55,5 @@ func (bl Blacklist) IsAllowed(contract string, action string) bool {
|
|||
}
|
||||
|
||||
func (bl Blacklist) IsDenied(contract string, action string) bool {
|
||||
return bl.IsAllowed(contract, action)
|
||||
return !bl.IsAllowed(contract, action)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,3 +93,19 @@ func TestBlacklist_Whitelist(t *testing.T) {
|
|||
require.False(t, bl.IsAllowed("mycontract", "xxx"))
|
||||
require.False(t, bl.IsAllowed("xxx", "yyy"))
|
||||
}
|
||||
|
||||
func TestBlacklist_IsDenied(t *testing.T) {
|
||||
bl := Blacklist{
|
||||
table: map[string][]string{
|
||||
"mycontract": {"myaction", "noop"},
|
||||
},
|
||||
}
|
||||
|
||||
require.True(t, bl.IsDenied("mycontract", "myaction"))
|
||||
require.False(t, bl.IsDenied("mycontract", "randomaction"))
|
||||
|
||||
bl.SetWhitelist(true)
|
||||
|
||||
require.False(t, bl.IsDenied("mycontract", "myaction"))
|
||||
require.True(t, bl.IsDenied("mycontract", "randomaction"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue