添加s3
This commit is contained in:
@@ -13,6 +13,10 @@ var (
|
||||
CodeServiceErr = &StatusResponse{510, "server logic error"} // 服务逻辑错误
|
||||
CodeUnAuth = &StatusResponse{401, "unauthorized"} // 未授权
|
||||
|
||||
CodeS3PutObjectRequestErr = &StatusResponse{5060, "s3 PutObjectRequest error"} // s3 PutObjectRequest 错误
|
||||
CodeS3PutSizeLimitErr = &StatusResponse{5060, "s3 over limit size error"} // s3 超过文件大小限制 错误
|
||||
CodeS3CategoryErr = &StatusResponse{5060, "s3 category not exists error"} // s3 类别不存在 错误
|
||||
|
||||
CodeEmailNotFoundErr = &StatusResponse{5050, "email not found"} // 未找到email
|
||||
CodeUserIdNotFoundErr = &StatusResponse{5051, "user not found"} // 未找到用户
|
||||
CodePasswordErr = &StatusResponse{5052, "invalid password"} // 无效密码
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
package fstests
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/474420502/requests"
|
||||
)
|
||||
|
||||
func GetSesssion() *requests.Session {
|
||||
ses := requests.NewSession()
|
||||
return ses
|
||||
}
|
||||
|
||||
func GetSessionWithUserToken(t *testing.T, server requests.ITestServer, Host string, Port int) *requests.Session {
|
||||
ses := requests.NewSession()
|
||||
tp := ses.Post(fmt.Sprintf("http://%s:%d/user/login", Host, Port))
|
||||
tp.SetBodyJson(map[string]interface{}{
|
||||
"name": "9107058@qq.com",
|
||||
"pwd": "$2y$13$2y4O4OIz/zcK5C0vlSc9LuSpjWySjInLBSe49yDkE.iURb.R1hDsy",
|
||||
})
|
||||
resp, err := tp.TestExecute(server)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
result := resp.Json()
|
||||
code := result.Get("code").Int()
|
||||
if code != 200 {
|
||||
t.Error("code is not 200")
|
||||
}
|
||||
|
||||
token := result.Get("data.token")
|
||||
if !token.Exists() {
|
||||
t.Error("data.token is not exists")
|
||||
}
|
||||
ses.Header.Add("Authorization", token.String())
|
||||
|
||||
return ses
|
||||
}
|
||||
|
||||
func GetBackendSessionWithUserToken(t *testing.T, server requests.ITestServer, Host string, Port int) *requests.Session {
|
||||
ses := requests.NewSession()
|
||||
tp := ses.Post(fmt.Sprintf("http://%s:%d/backend-user/login", Host, Port))
|
||||
tp.SetBodyJson(map[string]interface{}{
|
||||
"name": "admin@admin.com",
|
||||
"pwd": "ZnVzZW5fYmFja2VuZF8yMDIz47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU=",
|
||||
})
|
||||
resp, err := tp.TestExecute(server)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
result := resp.Json()
|
||||
code := result.Get("code").Int()
|
||||
if code != 200 {
|
||||
t.Error("code is not 200")
|
||||
}
|
||||
|
||||
token := result.Get("data.token")
|
||||
if !token.Exists() {
|
||||
t.Error("data.token is not exists")
|
||||
}
|
||||
ses.Header.Add("Authorization", token.String())
|
||||
|
||||
return ses
|
||||
}
|
||||
|
||||
func GetSesssionWithGuestToken(t *testing.T, server requests.ITestServer, Host string, Port int) *requests.Session {
|
||||
ses := requests.NewSession()
|
||||
tp := ses.Post(fmt.Sprintf("http://%s:%d/accept/cookie", Host, Port))
|
||||
|
||||
resp, err := tp.TestExecute(server)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
result := resp.Json()
|
||||
token := result.Get("data.token")
|
||||
if !token.Exists() {
|
||||
t.Error("data.token is not exists")
|
||||
}
|
||||
ses.Header.Add("Authorization", token.String())
|
||||
|
||||
return ses
|
||||
}
|
||||
Reference in New Issue
Block a user