-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperms_test.go
72 lines (62 loc) · 2.3 KB
/
perms_test.go
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
// +build integration
package tests
import (
"testing"
"github.com/deis/deis/tests/utils"
)
var (
permsListAppCmd = "perms:list --app={{.AppName}}"
permsListAdminCmd = "perms:list --admin"
permsCreateAppCmd = "perms:create {{.AppUser}} --app={{.AppName}}"
permsCreateAdminCmd = "perms:create {{.AppUser}} --admin"
permsDeleteAppCmd = "perms:delete {{.AppUser}} --app={{.AppName}}"
permsDeleteAdminCmd = "perms:delete {{.AppUser}} --admin"
)
func TestPerms(t *testing.T) {
params := permsSetup(t)
user := utils.GetGlobalConfig()
user.UserName, user.Password = "test1", "test1"
user.AppName = params.AppName
utils.Execute(t, authRegisterCmd, user, false, "")
permsCreateAppTest(t, params, user)
permsDeleteAppTest(t, params, user)
permsCreateAdminTest(t, params)
permsDeleteAdminTest(t, params)
utils.AppsDestroyTest(t, params)
}
func permsSetup(t *testing.T) *utils.DeisTestConfig {
cfg := utils.GetGlobalConfig()
cfg.AppName = "permssample"
utils.Execute(t, authLoginCmd, cfg, false, "")
utils.Execute(t, gitCloneCmd, cfg, false, "")
if err := utils.Chdir(cfg.ExampleApp); err != nil {
t.Fatal(err)
}
utils.Execute(t, appsCreateCmd, cfg, false, "")
utils.Execute(t, gitPushCmd, cfg, false, "")
if err := utils.Chdir(".."); err != nil {
t.Fatal(err)
}
return cfg
}
func permsCreateAdminTest(t *testing.T, params *utils.DeisTestConfig) {
utils.Execute(t, permsCreateAdminCmd, params, false, "")
utils.CheckList(t, permsListAdminCmd, params, "test1", false)
}
func permsCreateAppTest(t *testing.T, params, user *utils.DeisTestConfig) {
utils.Execute(t, authLoginCmd, user, false, "")
utils.Execute(t, permsCreateAppCmd, user, true, "403 FORBIDDEN")
utils.Execute(t, authLoginCmd, params, false, "")
utils.Execute(t, permsCreateAppCmd, params, false, "")
utils.CheckList(t, permsListAppCmd, params, "test1", false)
}
func permsDeleteAdminTest(t *testing.T, params *utils.DeisTestConfig) {
utils.Execute(t, permsDeleteAdminCmd, params, false, "")
utils.CheckList(t, permsListAdminCmd, params, "test1", true)
}
func permsDeleteAppTest(t *testing.T, params, user *utils.DeisTestConfig) {
utils.Execute(t, authLoginCmd, user, false, "")
utils.Execute(t, permsDeleteAppCmd, user, false, "")
utils.Execute(t, authLoginCmd, params, false, "")
utils.CheckList(t, permsListAppCmd, params, "test1", true)
}