-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathrbac_test.go
More file actions
74 lines (57 loc) · 1.68 KB
/
rbac_test.go
File metadata and controls
74 lines (57 loc) · 1.68 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package runscope
import (
"testing"
)
func TestListRoles(t *testing.T) {
testPreCheck(t)
client := clientConfigure()
listRoles, err := client.ListRoles(teamID)
if err != nil {
t.Error(err)
}
if listRoles[0].Name != "Administrators" {
t.Errorf("Expected to have role %s got %s", "Administrators", listRoles[0].Name)
}
}
func TestCreateReadRole(t *testing.T) {
testPreCheck(t)
client := clientConfigure()
newRole := &Role{Name: "test_role", Permissions: []string{"team:people:view"}}
newRole, err := client.CreateRole(newRole, teamID)
if err != nil {
t.Error(err)
}
defer client.DeleteRole(newRole, teamID) // nolint: errcheck
readRole, err := client.ReadRole(newRole, teamID)
if err != nil {
t.Error(err)
}
if readRole.Name != "test_role" {
t.Errorf("Expected role name %s, actual %s", "test_role", readRole.Name)
}
if readRole.Permissions[0] != "team:people:view" {
t.Errorf("Expected role permission %s, actual %s", "team:people:view", readRole.Permissions[0])
}
}
func TestUpdateRole(t *testing.T) {
testPreCheck(t)
client := clientConfigure()
newRole := &Role{Name: "test_role", Permissions: []string{"team:people:view"}}
newRole, err := client.CreateRole(newRole, teamID)
if err != nil {
t.Error(err)
}
defer client.DeleteRole(newRole, teamID) // nolint: errcheck
newRole.Permissions = []string{"team:billing:view"}
updatedRole, err := client.UpdateRole(newRole, teamID)
if err != nil {
t.Error(err)
}
readRole, err := client.ReadRole(updatedRole, teamID)
if err != nil {
t.Error(err)
}
if readRole.Permissions[0] != "team:billing:view" {
t.Errorf("Expected role permission %s, actual %s", "team:people:view", readRole.Permissions[0])
}
}