Feat: add preshared key check

This commit is contained in:
2025-12-07 19:14:06 +08:00
parent f4c92504e8
commit cada4d25fa
3 changed files with 49 additions and 1 deletions

View File

@@ -21,9 +21,22 @@ type loginPayload struct {
func Test_01_Login(t *testing.T) {
client = resty.New()
t.Run("check preshared key failed", func(t *testing.T) {
resp, err := client.R().
SetBody(`{"userId": "testuser1"}`).
Post("http://localhost:8080/auth/gen-login-url")
if err != nil {
t.Fatal("request failed")
}
if resp.StatusCode() != http.StatusUnauthorized {
t.Fatal("preshared key check should failed")
}
})
var payload genLoginUrlPayload
resp, err := client.R().
SetBody(`{"userId": "testuser1"}`).
SetAuthToken("poop").
SetResult(&payload).
Post("http://localhost:8080/auth/gen-login-url")