Skip to content

Commit

Permalink
Added "IsFromCache" into the unit test for testing
Browse files Browse the repository at this point in the history
Formatted some AuthResponse for more clearity
  • Loading branch information
4gust committed Aug 14, 2024
1 parent 13b262d commit 9932917
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/internal/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down
2 changes: 2 additions & 0 deletions apps/internal/base/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func TestCreateAuthenticationResult(t *testing.T) {
ExpiresOn: future,
GrantedScopes: []string{"user.read"},
DeclinedScopes: nil,
IsFromCache: false,
},
},
{
Expand Down Expand Up @@ -416,6 +417,7 @@ func TestAuthResultFromStorage(t *testing.T) {
},
ExpiresOn: future,
GrantedScopes: []string{"profile", "openid", "user.read"},
IsFromCache: true,
},
},
}
Expand Down

0 comments on commit 9932917

Please sign in to comment.