Skip to content

Commit 0b07e1c

Browse files
julienstrohekerbgavrilMS
authored andcommitted
update cache logic + UT
1 parent cd92d59 commit 0b07e1c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

apps/internal/base/internal/storage/storage.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func (m *Manager) readAccessToken(homeID string, envAliases []string, realm, cli
261261
// an issue, however if it does become a problem then we know where to look.
262262
for _, at := range m.contract.AccessTokens {
263263
if at.HomeAccountID == homeID && at.Realm == realm && at.ClientID == clientID {
264-
if at.TokenType == tokenType && at.AuthnSchemeKeyID == authnSchemeKeyID || at.TokenType == "" {
264+
if (at.TokenType == tokenType && at.AuthnSchemeKeyID == authnSchemeKeyID) || (at.TokenType == "" && (tokenType == "" || tokenType == "Bearer")) {
265265
if checkAlias(at.Environment, envAliases) {
266266
if isMatchingScopes(scopes, at.Scopes) {
267267
return at

apps/internal/base/internal/storage/storage_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ func TestReadAccessToken(t *testing.T) {
180180
if diff := pretty.Compare(testAccessTokenWithoutTokenType, retAccessToken2); diff != "" {
181181
t.Fatalf("Returned access token is not the same as expected access token: -want/+got:\n%s", diff)
182182
}
183-
// Test that we can find fallback to an empty token type in the cache when the token type is not provided
183+
// Test that we can find fallback to an empty token type in the cache when the token type is Bearer (defaulted)
184184
retAccessToken2 = storageManager.readAccessToken(
185185
"hid2",
186186
[]string{"hello", "env2", "test"},
187187
"realm2",
188188
"cid2",
189189
[]string{"user.read", "openid"},
190-
"tokenType",
190+
"Bearer",
191191
"",
192192
)
193193
if diff := pretty.Compare(testAccessTokenWithoutTokenType, retAccessToken2); diff != "" {

0 commit comments

Comments
 (0)