@@ -4,11 +4,12 @@ import (
4
4
"testing"
5
5
6
6
"github.com/coder/coder/coderd/authz"
7
- crand "github.com/coder/coder/cryptorand"
8
7
"github.com/stretchr/testify/require"
9
8
)
10
9
11
10
func Test_PermissionString (t * testing.T ) {
11
+ t .Parallel ()
12
+
12
13
testCases := []struct {
13
14
Name string
14
15
Permission authz.Permission
@@ -59,41 +60,3 @@ func Test_PermissionString(t *testing.T) {
59
60
}
60
61
61
62
}
62
-
63
- func BenchmarkPermissionString (b * testing.B ) {
64
- total := 10000
65
- if b .N < total {
66
- total = b .N
67
- }
68
- perms := make ([]authz.Permission , b .N )
69
- for n := 0 ; n < total ; n ++ {
70
- perms [n ] = RandomPermission ()
71
- }
72
-
73
- b .ResetTimer ()
74
- for n := 0 ; n < b .N ; n ++ {
75
- var _ = perms [n % total ].String ()
76
- }
77
- }
78
-
79
- var resourceTypes = []authz.ResourceType {
80
- "project" , "config" , "user" , "user_role" ,
81
- "workspace" , "dev-url" , "metric" , "*" ,
82
- }
83
-
84
- var actions = []authz.Action {
85
- "read" , "create" , "delete" , "modify" , "*" ,
86
- }
87
-
88
- func RandomPermission () authz.Permission {
89
- n , _ := crand .Intn (len (authz .PermissionLevels ))
90
- m , _ := crand .Intn (len (resourceTypes ))
91
- a , _ := crand .Intn (len (actions ))
92
- return authz.Permission {
93
- Sign : n % 2 == 0 ,
94
- Level : authz .PermissionLevels [n ],
95
- ResourceType : resourceTypes [m ],
96
- ResourceID : "*" ,
97
- Action : actions [a ],
98
- }
99
- }
0 commit comments