1
0
Fork 0
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:
Henrik Hautakoski 2026-08-27 23:13:50 +02:00
parent 4d93cc6379
commit 09284231ed
2 changed files with 17 additions and 1 deletions

View file

@ -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)
}

View file

@ -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"))
}