-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthz_test.go
51 lines (42 loc) · 911 Bytes
/
authz_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package authz
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestUnimplemented(t *testing.T) {
t.Parallel()
checker := &Unimplemented{}
require.NotNil(t, checker)
allowed, err := checker.Allowed(context.TODO(), "principal", "object", "action")
require.NoError(t, err)
require.False(t, allowed)
}
func TestFakeChecker(t *testing.T) {
t.Parallel()
tests := []struct {
name string
allowed bool
expected bool
}{
{
name: "allowed",
allowed: true,
expected: true,
},
{
name: "not allowed",
allowed: false,
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
checker := NewFake(tt.allowed)
require.NotNil(t, checker)
allowed, err := checker.Allowed(context.TODO(), "principal", "object", "action")
require.NoError(t, err)
require.Equal(t, tt.expected, allowed)
})
}
}