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
|
package auth
import (
"testing"
"github.com/superseriousbusiness/gotosocial/testrig"
)
func TestAdminGroup(t *testing.T) {
testrig.InitTestConfig()
for _, test := range []struct {
name string
groups []string
expected bool
}{
{name: "not in admin group", groups: []string{"group1", "group2", "allowedRole"}, expected: false},
{name: "in admin group", groups: []string{"group1", "group2", "adminRole"}, expected: true},
} {
test := test // loopvar capture
t.Run(test.name, func(t *testing.T) {
if got := adminGroup(test.groups); got != test.expected {
t.Fatalf("got: %t, wanted: %t", got, test.expected)
}
})
}
}
func TestAllowedGroup(t *testing.T) {
testrig.InitTestConfig()
for _, test := range []struct {
name string
groups []string
expected bool
}{
{name: "not in allowed group", groups: []string{"group1", "group2", "adminRole"}, expected: false},
{name: "in allowed group", groups: []string{"group1", "group2", "allowedRole"}, expected: true},
} {
test := test // loopvar capture
t.Run(test.name, func(t *testing.T) {
if got := allowedGroup(test.groups); got != test.expected {
t.Fatalf("got: %t, wanted: %t", got, test.expected)
}
})
}
}
|