fusenapi/server/home-user-auth/internal/logic/useraddresslistlogic_test.go

35 lines
778 B
Go
Raw Normal View History

2023-06-08 10:55:08 +00:00
package logic
import (
2023-06-12 07:17:42 +00:00
"log"
2023-06-08 10:55:08 +00:00
"testing"
2023-06-12 07:17:42 +00:00
"github.com/474420502/requests"
2023-06-08 10:55:08 +00:00
)
func TestCaseAddressList(t *testing.T) {
// http.NewRequest("POST", "http://localhost:8888/user/login", body io.Reader)
2023-06-12 07:17:42 +00:00
ses := requests.NewSession()
tp := ses.Post("http://localhost:8888/user/login")
resp, err := tp.SetBodyJson(map[string]interface{}{
"name": "devenv@sina.cn",
"pwd": "$2y$13$6UFDMZQMEfqFYiNLpiUCi.B3fpvGEamPAjIgzUqv/u7jT05nB3pOC",
}).Execute()
if err != nil {
panic(err)
}
result := resp.Json()
token := result.Get("data.token")
ses.Header.Add("Authorization", token.String())
log.Println(string(resp.Content()))
2023-06-08 10:55:08 +00:00
2023-06-12 07:17:42 +00:00
resp, err = ses.Get("http://localhost:8888/user/address-list").Execute()
if err != nil {
panic(err)
}
log.Println(string(resp.Content()))
2023-06-08 10:55:08 +00:00
}