-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathroot_test.go
More file actions
79 lines (75 loc) · 1.56 KB
/
root_test.go
File metadata and controls
79 lines (75 loc) · 1.56 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
75
76
77
78
79
package cmd
import (
"testing"
"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
)
func TestIsAuthExempt(t *testing.T) {
tests := []struct {
name string
cmd *cobra.Command
expected bool
}{
{
name: "root command is exempt",
cmd: rootCmd,
expected: true,
},
{
name: "login command is exempt",
cmd: loginCmd,
expected: true,
},
{
name: "logout command is exempt",
cmd: logoutCmd,
expected: true,
},
{
name: "top-level create command is exempt",
cmd: createCmd,
expected: true,
},
{
name: "browser-pools create subcommand requires auth",
cmd: browserPoolsCreateCmd,
expected: false,
},
{
name: "browsers create subcommand requires auth",
cmd: browsersCreateCmd,
expected: false,
},
{
name: "profiles create subcommand requires auth",
cmd: profilesCreateCmd,
expected: false,
},
{
name: "browser-pools list requires auth",
cmd: browserPoolsListCmd,
expected: false,
},
{
name: "browsers list requires auth",
cmd: browsersListCmd,
expected: false,
},
{
name: "deploy command requires auth",
cmd: deployCmd,
expected: false,
},
{
name: "invoke command requires auth",
cmd: invokeCmd,
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := isAuthExempt(tt.cmd)
assert.Equal(t, tt.expected, result, "isAuthExempt(%s) = %v, want %v", tt.cmd.Name(), result, tt.expected)
})
}
}