2023-12-15 13:16:32 +01:00
|
|
|
package acl
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGrant_Allow(t *testing.T) {
|
2024-02-14 19:33:19 +01:00
|
|
|
t.Run("GrantFullAccessAll", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantFullAccess.Allow(AccessAll))
|
|
|
|
})
|
|
|
|
t.Run("GrantFullAccessDownload", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantFullAccess.Allow(ActionDownload))
|
|
|
|
})
|
|
|
|
t.Run("GrantFullAccessDelete", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantFullAccess.Allow(ActionDelete))
|
|
|
|
})
|
|
|
|
t.Run("GrantFullAccessLibrary", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantFullAccess.Allow(AccessLibrary))
|
|
|
|
})
|
|
|
|
t.Run("UnknownAction", func(t *testing.T) {
|
|
|
|
assert.False(t, GrantViewAll.Allow("lovecats"))
|
|
|
|
})
|
|
|
|
t.Run("ViewAllView", func(t *testing.T) {
|
2023-12-15 13:16:32 +01:00
|
|
|
assert.True(t, GrantViewAll.Allow(ActionView))
|
|
|
|
})
|
2024-02-14 19:33:19 +01:00
|
|
|
t.Run("ViewAllAccessAll", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantViewAll.Allow(AccessAll))
|
|
|
|
})
|
|
|
|
t.Run("ViewAllDownload", func(t *testing.T) {
|
|
|
|
assert.False(t, GrantViewAll.Allow(ActionDownload))
|
|
|
|
})
|
2023-12-15 13:16:32 +01:00
|
|
|
t.Run("ViewAllShare", func(t *testing.T) {
|
|
|
|
assert.False(t, GrantViewAll.Allow(ActionShare))
|
|
|
|
})
|
2024-02-14 19:33:19 +01:00
|
|
|
t.Run("ViewOwnShare", func(t *testing.T) {
|
|
|
|
assert.False(t, GrantViewOwn.Allow(ActionShare))
|
|
|
|
})
|
|
|
|
t.Run("ViewOwnView", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantViewOwn.Allow(ActionView))
|
|
|
|
})
|
|
|
|
t.Run("ViewOwnAccessAll", func(t *testing.T) {
|
|
|
|
assert.False(t, GrantViewOwn.Allow(AccessAll))
|
|
|
|
})
|
|
|
|
t.Run("ViewOwnAccessOwn", func(t *testing.T) {
|
|
|
|
assert.True(t, GrantViewOwn.Allow(AccessOwn))
|
2023-12-15 13:16:32 +01:00
|
|
|
})
|
|
|
|
}
|