Fix: login flow

This commit is contained in:
2025-12-07 18:56:31 +08:00
parent 3970dd5ebd
commit f4c92504e8
9 changed files with 72 additions and 11 deletions

View File

@@ -8,6 +8,8 @@ import (
"github.com/go-resty/resty/v2"
)
var client *resty.Client
type genLoginUrlPayload struct {
LoginUrl string `json:"loginUrl"`
}
@@ -16,8 +18,8 @@ type loginPayload struct {
Token string `json:"token"`
}
func TestLogin(t *testing.T) {
client := resty.New()
func Test_01_Login(t *testing.T) {
client = resty.New()
var payload genLoginUrlPayload
resp, err := client.R().
@@ -37,7 +39,7 @@ func TestLogin(t *testing.T) {
resp, err = client.R().
SetBody(loginPayload{Token: loginUrl.Query().Get("token")}).
Post(loginUrl.Scheme + "://" + loginUrl.Host + loginUrl.Path)
Post(loginUrl.Scheme + "://" + loginUrl.Host + "/auth/login")
if err != nil || resp.StatusCode() != http.StatusOK {
t.Fatal("failed to login")
}

View File

@@ -0,0 +1,6 @@
package main
import "testing"
func Test_02_GetImages(t *testing.T) {
}