-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathperms_test.go
More file actions
89 lines (78 loc) · 2.83 KB
/
perms_test.go
File metadata and controls
89 lines (78 loc) · 2.83 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
80
81
82
83
84
85
86
87
88
89
// +build integration
package tests
import (
_ "fmt"
"testing"
"github.com/deis/deis/tests/integration-utils"
"github.com/deis/deis/tests/utils"
)
func permsSetup(t *testing.T) *itutils.DeisTestConfig {
cfg := itutils.GetGlobalConfig()
cfg.AppName = "permssample"
cmd := itutils.GetCommand("auth", "login")
itutils.Execute(t, cmd, cfg, false, "")
cmd = itutils.GetCommand("git", "clone")
itutils.Execute(t, cmd, cfg, false, "")
cmd = itutils.GetCommand("apps", "create")
cmd1 := itutils.GetCommand("git", "push")
if err := utils.Chdir(cfg.ExampleApp); err != nil {
t.Fatalf("Failed:\n%v", err)
}
itutils.Execute(t, cmd, cfg, false, "")
itutils.Execute(t, cmd1, cfg, false, "")
if err := utils.Chdir(".."); err != nil {
t.Fatalf("Failed:\n%v", err)
}
return cfg
}
func permsCreateAppTest(t *testing.T, params, user *itutils.DeisTestConfig) {
var cmd string
cmd = itutils.GetCommand("auth", "login")
itutils.Execute(t, cmd, user, false, "")
cmd = itutils.GetCommand("perms", "create-app")
itutils.Execute(t, cmd, user, true, "403 FORBIDDEN")
cmd = itutils.GetCommand("auth", "login")
itutils.Execute(t, cmd, params, false, "")
cmd = itutils.GetCommand("perms", "create-app")
itutils.Execute(t, cmd, params, false, "")
cmd = itutils.GetCommand("perms", "list-app")
itutils.CheckList(t, params, cmd, "test1", false)
}
func permsDeleteAppTest(t *testing.T, params, user *itutils.DeisTestConfig) {
var cmd string
cmd = itutils.GetCommand("auth", "login")
itutils.Execute(t, cmd, user, false, "")
cmd = itutils.GetCommand("perms", "delete-app")
itutils.Execute(t, cmd, user, true, "403 FORBIDDEN")
cmd = itutils.GetCommand("auth", "login")
itutils.Execute(t, cmd, params, false, "")
cmd = itutils.GetCommand("perms", "delete-app")
itutils.Execute(t, cmd, params, false, "")
cmd = itutils.GetCommand("perms", "list-app")
itutils.CheckList(t, params, cmd, "test1", true)
}
func permsCreateAdminTest(t *testing.T, params *itutils.DeisTestConfig) {
cmd := itutils.GetCommand("perms", "create-admin")
itutils.Execute(t, cmd, params, false, "")
cmd = itutils.GetCommand("perms", "list-admin")
itutils.CheckList(t, params, cmd, "test1", false)
}
func permsDeleteAdminTest(t *testing.T, params *itutils.DeisTestConfig) {
cmd := itutils.GetCommand("perms", "delete-admin")
itutils.Execute(t, cmd, params, false, "")
cmd = itutils.GetCommand("perms", "list-admin")
itutils.CheckList(t, params, cmd, "test1", true)
}
func TestPerms(t *testing.T) {
params := permsSetup(t)
user := itutils.GetGlobalConfig()
user.UserName, user.Password = "test1", "test1"
user.AppName = params.AppName
cmd := itutils.GetCommand("auth", "register")
itutils.Execute(t, cmd, user, false, "")
permsCreateAppTest(t, params, user)
permsDeleteAppTest(t, params, user)
permsCreateAdminTest(t, params)
permsDeleteAdminTest(t, params)
itutils.AppsDestroyTest(t, params)
}