From 99329176dc4d4e1c91e4623aa7fbc44dce6386a2 Mon Sep 17 00:00:00 2001 From: Nilesh Choudhary Date: Wed, 14 Aug 2024 15:13:20 +0100 Subject: [PATCH] Added "IsFromCache" into the unit test for testing Formatted some AuthResponse for more clearity --- apps/internal/base/base.go | 10 ++++++++-- apps/internal/base/base_test.go | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/internal/base/base.go b/apps/internal/base/base.go index 69d67330..082e3147 100644 --- a/apps/internal/base/base.go +++ b/apps/internal/base/base.go @@ -110,7 +110,14 @@ func AuthResultFromStorage(storageTokenResponse storage.TokenResponse) (AuthResu return AuthResult{}, fmt.Errorf("problem decoding JWT token: %w", err) } } - return AuthResult{account, idToken, accessToken, storageTokenResponse.AccessToken.ExpiresOn.T, grantedScopes, nil, true}, nil + return AuthResult{ + Account: account, + IDToken: idToken, + AccessToken: accessToken, + ExpiresOn: storageTokenResponse.AccessToken.ExpiresOn.T, + GrantedScopes: grantedScopes, + DeclinedScopes: nil, + IsFromCache: true}, nil } // NewAuthResult creates an AuthResult. @@ -124,7 +131,6 @@ func NewAuthResult(tokenResponse accesstokens.TokenResponse, account shared.Acco AccessToken: tokenResponse.AccessToken, ExpiresOn: tokenResponse.ExpiresOn.T, GrantedScopes: tokenResponse.GrantedScopes.Slice, - IsFromCache: false, }, nil } diff --git a/apps/internal/base/base_test.go b/apps/internal/base/base_test.go index 6ae5ba0f..9b0bbfd5 100644 --- a/apps/internal/base/base_test.go +++ b/apps/internal/base/base_test.go @@ -344,6 +344,7 @@ func TestCreateAuthenticationResult(t *testing.T) { ExpiresOn: future, GrantedScopes: []string{"user.read"}, DeclinedScopes: nil, + IsFromCache: false, }, }, { @@ -416,6 +417,7 @@ func TestAuthResultFromStorage(t *testing.T) { }, ExpiresOn: future, GrantedScopes: []string{"profile", "openid", "user.read"}, + IsFromCache: true, }, }, }