From 9cb79f0ca4cf6ba52bbb573c22778c005edf1ee7 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 17 Apr 2023 11:31:52 +0200 Subject: OAuth Token: Set previous refresh token if new refresh token is empty This is for 2.x servers that return an empty refresh token after refreshing --- internal/oauth/oauth_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/oauth/oauth_test.go b/internal/oauth/oauth_test.go index 60ce5c7..1f2a29e 100644 --- a/internal/oauth/oauth_test.go +++ b/internal/oauth/oauth_test.go @@ -81,7 +81,7 @@ func Test_accessToken(t *testing.T) { // Set the tokens as expired o.SetTokenExpired() - // We should not get an error because expired and no refresh token + // We should get an error because expired and no refresh token _, err = o.AccessToken(context.Background()) if err == nil { t.Fatal("Got no error when getting access token on non-empty structure and expired") @@ -116,7 +116,7 @@ func Test_accessToken(t *testing.T) { // Now let's act like a 2.x server, we give no refresh token back. When we refresh the previous refresh token should be gotten o.token.t.Refresh = refresh prevRefresh := refresh - o.token.t.Refresher = func(refreshToken string) (*TokenResponse, time.Time, error) { + o.token.t.Refresher = func(ctx context.Context, refreshToken string) (*TokenResponse, time.Time, error) { if refreshToken != refresh { t.Fatalf("Passed refresh token to refresher not equal to updated refresh token, got: %v, want: %v", refreshToken, refresh) } @@ -125,7 +125,7 @@ func Test_accessToken(t *testing.T) { return r, expired, nil } - got, err = o.AccessToken() + got, err = o.AccessToken(context.Background()) if err != nil { t.Fatalf("Got error when getting access token on non-empty expired structure and with an empty refresh response: %v", err) } -- cgit v1.2.3