mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-21 23:29:38 +00:00
Merge pull request #3544 from nspcc-dev/fix-permission-extension
This commit is contained in:
commit
39e0d60221
2 changed files with 17 additions and 2 deletions
|
@ -64,8 +64,12 @@ func (c *WildPermissionDescs) Restrict() {
|
|||
// Add adds v to the container.
|
||||
func (c *WildStrings) Add(v string) { c.Value = append(c.Value, v) }
|
||||
|
||||
// Add adds v to the container.
|
||||
func (c *WildPermissionDescs) Add(v PermissionDesc) { c.Value = append(c.Value, v) }
|
||||
// Add adds v to the container and converts container to non-wildcard (if it's still
|
||||
// wildcard).
|
||||
func (c *WildPermissionDescs) Add(v PermissionDesc) {
|
||||
c.Value = append(c.Value, v)
|
||||
c.Wildcard = false
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json.Marshaler interface.
|
||||
func (c WildStrings) MarshalJSON() ([]byte, error) {
|
||||
|
|
|
@ -81,6 +81,17 @@ func TestContainer_Add(t *testing.T) {
|
|||
require.False(t, c.Contains(PermissionDesc{Type: PermissionHash, Value: random.Uint160()}))
|
||||
require.False(t, c.Contains(PermissionDesc{Type: PermissionGroup, Value: pkRand.PublicKey()}))
|
||||
})
|
||||
|
||||
t.Run("from wildcard", func(t *testing.T) {
|
||||
c := &WildPermissionDescs{
|
||||
Value: nil,
|
||||
Wildcard: true,
|
||||
}
|
||||
require.True(t, c.IsWildcard())
|
||||
|
||||
c.Add(PermissionDesc{Type: PermissionHash, Value: random.Uint160()})
|
||||
require.False(t, c.IsWildcard())
|
||||
})
|
||||
}
|
||||
|
||||
func TestContainer_MarshalJSON(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue