forked from snowlyg/iris-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
access_test.go
62 lines (46 loc) · 1.45 KB
/
access_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
package main
import (
"testing"
"IrisApiProject/config"
"github.com/kataras/iris/v12"
)
// 登陆成功
func TestUserLoginSuccess(t *testing.T) {
oj := map[string]string{
"username": config.Conf.Get("test.LoginUserName").(string),
"password": config.Conf.Get("test.LoginPwd").(string),
}
login(t, "/v1/admin/login", oj, iris.StatusOK, true, "登陆成功", nil)
}
// 输入不存在的用户名登陆
func TestUserLoginWithErrorName(t *testing.T) {
oj := map[string]string{
"username": "err_user",
"password": config.Conf.Get("test.LoginPwd").(string),
}
login(t, "/v1/admin/login", oj, iris.StatusOK, false, "用户不存在", nil)
}
// 输入错误的登陆密码
func TestUserLoginWithErrorPwd(t *testing.T) {
oj := map[string]string{
"username": config.Conf.Get("test.LoginUserName").(string),
"password": "admin",
}
login(t, "/v1/admin/login", oj, iris.StatusOK, false, "用户名或密码错误", nil)
}
// 输入登陆密码格式错误
func TestUserLoginWithErrorFormtPwd(t *testing.T) {
oj := map[string]string{
"username": config.Conf.Get("test.LoginUserName").(string),
"password": "123",
}
login(t, "/v1/admin/login", oj, iris.StatusOK, false, "密码格式错误", nil)
}
// 输入登陆密码格式错误
func TestUserLoginWithErrorFormtUserName(t *testing.T) {
oj := map[string]string{
"username": "df",
"password": "123",
}
login(t, "/v1/admin/login", oj, iris.StatusOK, false, "用户名格式错误", nil)
}