黄梓健
5 years ago
15 changed files with 23 additions and 111 deletions
-
5controllers/author.go
-
4controllers/client/activity.go
-
2controllers/client/auction.go
-
2controllers/client/barrage.go
-
4controllers/client/bully_screen.go
-
4controllers/client/invite_envelope.go
-
5controllers/client/login.go
-
82controllers/client/login_test.go
-
2controllers/client/order_entry.go
-
2controllers/client/reward.go
-
5controllers/client/shake_red_envelope.go
-
4controllers/client/upper_wall.go
-
2controllers/client/vote.go
-
4controllers/pc/sign.go
-
7utils/define/define.go
@ -1,82 +0,0 @@ |
|||
package client |
|||
|
|||
import ( |
|||
"github.com/ouxuanserver/osmanthuswine/src/core" |
|||
. "github.com/smartystreets/goconvey/convey" |
|||
"hudongzhuanjia/libs/jwt" |
|||
"hudongzhuanjia/models" |
|||
"hudongzhuanjia/test" |
|||
"hudongzhuanjia/utils/code" |
|||
"hudongzhuanjia/utils/define" |
|||
"net/http" |
|||
"testing" |
|||
) |
|||
|
|||
func TestEntryLogin(t *testing.T) { |
|||
type Data struct { |
|||
People *models.OrderEntryPerson `json:"people"` |
|||
} |
|||
|
|||
type Result struct { |
|||
core.ResponseData |
|||
Data Data `json:"data"` |
|||
} |
|||
|
|||
conf := test.GetConfig() |
|||
Convey("测试录入人员登录", t, func() { |
|||
path := test.ApiUrl("PcClient/Client/UserCtl/entryLogin") |
|||
// 正确登录
|
|||
param := map[string]interface{}{ |
|||
"account": conf.EntryAccount, |
|||
"password": conf.EntryPwd, |
|||
"activity_id": conf.ActivityId, |
|||
} |
|||
resp, err := test.Api("").Get(path, param) // 并不需要token
|
|||
So(err, ShouldBeNil) // 检测是否请求出错
|
|||
So(resp.StatusCode(), ShouldEqual, http.StatusOK) // 检测请求连接是否正确
|
|||
res := new(Result) |
|||
err = resp.Json(res) |
|||
So(err, ShouldBeNil) // 检测json 解析是否正确
|
|||
So(res.Code, ShouldEqual, 0) // 返回code是否为0
|
|||
So(res.Data.People, ShouldNotBeNil, nil) // 检测返回数据是否为空
|
|||
So(res.Data.People.ActivityId, ShouldEqual, conf.ActivityId) |
|||
So(res.Data.People.Account, ShouldEqual, conf.EntryAccount) |
|||
So(res.Data.People.Password, ShouldEqual, conf.EntryPwd) |
|||
So(res.Data.People.Token, ShouldNotBeEmpty) |
|||
// 校验token
|
|||
claims, err := jwt.ParseAccessToken(res.Data.People.Token) |
|||
So(err, ShouldNotBeNil) |
|||
So(claims.ActivityId, ShouldEqual, conf.ActivityId) |
|||
So(claims.AccountType, ShouldEqual, define.TYPE_ENTRY) |
|||
|
|||
// 登录失败的场景
|
|||
// 录入人员不存在
|
|||
param = map[string]interface{}{ |
|||
"account": "tommy", |
|||
"password": conf.EntryPwd, |
|||
"activity_id": conf.ActivityId, |
|||
} |
|||
resp, err = test.Api("").Get(path) |
|||
So(err, ShouldBeNil) |
|||
So(resp.StatusCode(), ShouldEqual, http.StatusOK) |
|||
res = new(Result) |
|||
err = resp.Json(res) |
|||
So(err, ShouldBeNil) |
|||
So(res.Code, ShouldEqual, code.MSG_ENTRYPEOPLE_NOT_EXIST) |
|||
|
|||
// 互动不存在
|
|||
param = map[string]interface{}{ |
|||
"account": conf.EntryAccount, |
|||
"password": conf.EntryPwd, |
|||
"activity_id": 0, |
|||
} |
|||
resp, err = test.Api("").Get(path) |
|||
So(err, ShouldBeNil) |
|||
So(resp.StatusCode(), ShouldEqual, http.StatusOK) |
|||
res = new(Result) |
|||
err = resp.Json(res) |
|||
So(err, ShouldBeNil) |
|||
So(res.Code, ShouldEqual, code.MSG_ACTIVITY_NOT_EXIST) |
|||
// done
|
|||
}) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue