Skip to content

Commit

Permalink
fix get token service as string
Browse files Browse the repository at this point in the history
  • Loading branch information
erfandiakoo committed Nov 14, 2024
1 parent 98274fa commit 5a69bb5
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ func FailRequest(client *goarpa.GoArpa, err error, failN, skipN int) *goarpa.GoA
return client
}

func GetToken(t testing.TB, client *goarpa.GoArpa) *goarpa.JWT {
func GetToken(t testing.TB, client *goarpa.GoArpa) string {
cfg := GetConfig(t)
token, err := client.AdminAuthenticate(
context.Background(),
cfg.Admin.UserName,
cfg.Admin.Password,
)
require.NoError(t, err, "Login failed")
require.NotEmpty(t, token, "Got an empty token")
return token
}

Expand All @@ -176,13 +177,17 @@ func Test_AdminAuthenticate(t *testing.T) {
t.Parallel()
cfg := GetConfig(t)
client := NewClientWithDebug(t)

// Obtain the token from AdminAuthenticate
newToken, err := client.AdminAuthenticate(
context.Background(),
cfg.Admin.UserName,
cfg.Admin.Password,
)

require.NoError(t, err, "Login failed")
t.Logf("New token: %+v", *newToken)
//require.Equal(t, newToken.ExpiresAt, 0, "Got a refresh token instead of offline")
require.NotEmpty(t, newToken.AccessToken, "Got an empty if token")
require.NotEmpty(t, newToken, "Got an empty token")

// Log the new token and response body for debugging purposes
t.Logf("New token: %s", newToken)
}

0 comments on commit 5a69bb5

Please sign in to comment.