forked from deis/deis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth_test.go
65 lines (53 loc) · 1.75 KB
/
auth_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
// +build integration
package tests
import (
"testing"
"github.com/deis/deis/tests/utils"
)
var (
authLoginCmd = "auth:login http://deis.{{.Domain}} --username={{.UserName}} --password={{.Password}}"
authLogoutCmd = "auth:logout"
authRegisterCmd = "auth:register http://deis.{{.Domain}} --username={{.UserName}} --password={{.Password}} --email={{.Email}}"
)
func TestAuth(t *testing.T) {
params := authSetup(t)
authRegisterTest(t, params)
authLogoutTest(t, params)
authLoginTest(t, params)
authWhoamiTest(t, params)
authPasswdTest(t, params)
authCancel(t, params)
}
func authSetup(t *testing.T) *utils.DeisTestConfig {
user := utils.GetGlobalConfig()
user.UserName, user.Password = utils.NewID(), utils.NewID()
return user
}
func authCancel(t *testing.T, params *utils.DeisTestConfig) {
utils.AuthCancel(t, params)
}
func authLoginTest(t *testing.T, params *utils.DeisTestConfig) {
cmd := authLoginCmd
utils.Execute(t, cmd, params, false, "")
params = authSetup(t)
utils.Execute(t, cmd, params, true, "400 BAD REQUEST")
}
func authLogoutTest(t *testing.T, params *utils.DeisTestConfig) {
utils.Execute(t, authLogoutCmd, params, false, "")
}
func authPasswdTest(t *testing.T, params *utils.DeisTestConfig) {
password := "aNewPassword"
utils.AuthPasswd(t, params, password)
cmd := authLoginCmd
utils.Execute(t, cmd, params, true, "400 BAD REQUEST")
params.Password = password
utils.Execute(t, cmd, params, false, "")
}
func authRegisterTest(t *testing.T, params *utils.DeisTestConfig) {
cmd := authRegisterCmd
utils.Execute(t, cmd, params, false, "")
utils.Execute(t, cmd, params, true, "Registration failed")
}
func authWhoamiTest(t *testing.T, params *utils.DeisTestConfig) {
utils.Execute(t, "auth:whoami", params, true, params.UserName)
}