Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sandushi committed Nov 1, 2024
1 parent 7620e99 commit 70a2459
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions components/org.wso2.carbon.identity.oauth/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<relativePath>../../pom.xml</relativePath>
<version>7.0.178-SNAPSHOT</version>
</parent>
<version>7.0.177</version>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.identity.oauth</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ private String replaceFromTokenId(String keyValue) {
JWT parsedJwtToken = JWTParser.parse(keyValue);
keyValue = parsedJwtToken.getJWTClaimsSet().getJWTID();
} catch (ParseException e) {
if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(
IdentityConstants.IdentityTokens.ACCESS_TOKEN)) {
log.debug("Error while getting JWTID from token: " + keyValue, e);
if (log.isDebugEnabled()) {
if (IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.ACCESS_TOKEN)) {
log.debug("Error while getting JWTID from token: " + keyValue, e);
} else {
log.debug("Error while getting JWTID from token");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ public void testReplaceFromTokenId(String accessToken, String jwtId, String toke
when(accessTokenDAO.getTokenIdByAccessToken(jwtId != null ? jwtId : accessToken)).thenReturn(tokenId);
}

// Mock SessionDataStore static instance and return a mock session data store
// Mock SessionDataStore static instance and return a mock session data store.
mockedSessionDataStore.when(SessionDataStore::getInstance).thenReturn(sessionDataStore);

// Mock SessionDataStore return for session data (from getFromSessionStore)
AuthorizationGrantCacheEntry mockCacheEntry = new AuthorizationGrantCacheEntry();
mockCacheEntry.setTokenId(tokenId);

Expand All @@ -94,10 +93,10 @@ public void testReplaceFromTokenId(String accessToken, String jwtId, String toke
AuthorizationGrantCacheKey key = new AuthorizationGrantCacheKey(accessToken);
AuthorizationGrantCacheEntry result = cache.getValueFromCacheByToken(key);

// Verify the token ID returned from the DAO is as expected
// Verify the token ID returned from the DAO is as expected.
assertEquals(tokenId, result.getTokenId());

// Verify that the JWT token was parsed and the correct claim was retrieved if it was a JWT
// Verify that the JWT token was parsed and the correct claim was retrieved if it was a JWT.
if (isJwtToken && !isInvalidJWTToken) {
verify(accessTokenDAO).getTokenIdByAccessToken(jwtId);
} else {
Expand All @@ -108,6 +107,7 @@ public void testReplaceFromTokenId(String accessToken, String jwtId, String toke

@DataProvider(name = "replaceFromTokenIdDataProvider")
public Object[][] getReplaceFromTokenIdData() {

return new Object[][]{
{"jwt.Access.Token", "jwtId", "jwtTokenId", true, false, false},
{"nonJWTAccessToken", null, "nonJWTTokenId", false, false, false},
Expand All @@ -118,6 +118,7 @@ public Object[][] getReplaceFromTokenIdData() {

@Test
public void testGetValueFromCacheByCode() throws IdentityOAuth2Exception {

String authCode = "authCode";
String codeId = "codeId";
AuthorizationGrantCacheKey key = new AuthorizationGrantCacheKey(authCode);
Expand Down

0 comments on commit 70a2459

Please sign in to comment.