Skip to content

Commit

Permalink
update cache logic + UT
Browse files Browse the repository at this point in the history
  • Loading branch information
julienstroheker authored and bgavrilMS committed Aug 29, 2023
1 parent cd92d59 commit 0b07e1c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/internal/base/internal/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (m *Manager) readAccessToken(homeID string, envAliases []string, realm, cli
// an issue, however if it does become a problem then we know where to look.
for _, at := range m.contract.AccessTokens {
if at.HomeAccountID == homeID && at.Realm == realm && at.ClientID == clientID {
if at.TokenType == tokenType && at.AuthnSchemeKeyID == authnSchemeKeyID || at.TokenType == "" {
if (at.TokenType == tokenType && at.AuthnSchemeKeyID == authnSchemeKeyID) || (at.TokenType == "" && (tokenType == "" || tokenType == "Bearer")) {
if checkAlias(at.Environment, envAliases) {
if isMatchingScopes(scopes, at.Scopes) {
return at
Expand Down
4 changes: 2 additions & 2 deletions apps/internal/base/internal/storage/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ func TestReadAccessToken(t *testing.T) {
if diff := pretty.Compare(testAccessTokenWithoutTokenType, retAccessToken2); diff != "" {
t.Fatalf("Returned access token is not the same as expected access token: -want/+got:\n%s", diff)
}
// Test that we can find fallback to an empty token type in the cache when the token type is not provided
// Test that we can find fallback to an empty token type in the cache when the token type is Bearer (defaulted)
retAccessToken2 = storageManager.readAccessToken(
"hid2",
[]string{"hello", "env2", "test"},
"realm2",
"cid2",
[]string{"user.read", "openid"},
"tokenType",
"Bearer",
"",
)
if diff := pretty.Compare(testAccessTokenWithoutTokenType, retAccessToken2); diff != "" {
Expand Down

0 comments on commit 0b07e1c

Please sign in to comment.