Skip to content

Commit

Permalink
Remove accessToken user claim validations.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmadhavig committed Oct 24, 2024
1 parent 38aa141 commit 5c54360
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,20 +317,6 @@ public void testValidateScopes() throws Exception {
}
}

@Test(groups = "wso2.is", description = "Validate additional user claims", dependsOnMethods = "testExtractJWTAccessTokenClaims")
public void testValidateAdditionalUserClaims() {

applicationConfig.getRequestedClaimList().forEach(claim -> {
if (authorizingUser.getUserClaims().get(claim) != null) {
assertNotNull(accessTokenClaims.getClaim(claim.getOidcClaimUri()),
"Claim " + claim.getOidcClaimUri() + " not found in the access token.");
assertEquals(accessTokenClaims.getClaim(claim.getOidcClaimUri()),
authorizingUser.getUserClaims().get(claim),
"Value for claim " + claim.getOidcClaimUri() + " is incorrect in the access token.");
}
});
}

@Test(groups = "wso2.is", description = "Validate additional user claims", dependsOnMethods = "testExtractJWTAccessTokenClaims")
public void testRefreshTokenGrant() throws Exception {

Expand All @@ -349,7 +335,6 @@ public void testRefreshTokenGrant() throws Exception {
refreshGrantJWTTokenTestCase.testValidateAudiences();
refreshGrantJWTTokenTestCase.testValidateExpiryTime();
refreshGrantJWTTokenTestCase.testValidateScopes();
refreshGrantJWTTokenTestCase.testValidateAdditionalUserClaims();
}

private String addUser(AuthorizingUser user) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,6 @@ public void testRefreshTokenFlow() throws Exception {
private void validateUserClaims(OIDCTokens oidcTokens) throws JSONException, ParseException {

Assert.assertNotNull(oidcTokens, "OIDC Tokens object is null in JWT token");
accessToken = oidcTokens.getAccessToken().getValue();
refreshToken = oidcTokens.getRefreshToken().getValue();

// Get the user info from the JWT access token.
JSONObject jwtJsonObject = new JSONObject(new String(Base64.decodeBase64(accessToken.split("\\.")[1])));
String email = jwtJsonObject.getString(EMAIL_OIDC_CLAIM);
Assert.assertEquals(USER_EMAIL, email, "Requested user claim (Email) is not present in the JWT access "
+ "token.");
Assert.assertTrue(jwtJsonObject.isNull(ADDRESS_OIDC_CLAIM), "Non-consented user claim (address) is"
+ " present in the JWT access token.");

// Get the user info from the ID token.
Assert.assertEquals(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(EMAIL_OIDC_CLAIM).toString(), USER_EMAIL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void testRegisterApplication() throws Exception {
registerApplication();
}


@Test(description = "This test case tests the JWT access token generation using password grant type.",
dependsOnMethods = "testRegisterApplication")
public void testPasswordGrantBasedAccessTokenGeneration() throws IOException, URISyntaxException, ParseException,
Expand Down Expand Up @@ -136,17 +135,6 @@ private void validateUserClaims(OIDCTokens oidcTokens) throws JSONException, jav
accessToken = oidcTokens.getAccessToken().getValue();
refreshToken = oidcTokens.getRefreshToken().getValue(); // Get the new refresh token.

// Get the user info from the JWT access token.
JSONObject jwtJsonObject = new JSONObject(new String(Base64.decodeBase64(accessToken.split(
"\\.")[1])));
String email = jwtJsonObject.get(EMAIL_OIDC_CLAIM).toString();
String country = ((JSONObject) jwtJsonObject.get(ADDRESS_OIDC_CLAIM)).get(COUNTRY_OIDC_CLAIM).toString();

// Check the user info of the JWT access token.
Assert.assertEquals(USER_EMAIL, email, "Requested user claim (email) is not present in the JWT access token.");
Assert.assertEquals(COUNTRY, country, "Requested user claim (country) is not present in the JWT "
+ "access token.");

Assert.assertEquals(oidcTokens.getIDToken().getJWTClaimsSet().getClaim(EMAIL_OIDC_CLAIM), USER_EMAIL,
"Requested user claims is not returned back with the ID token.");
Assert.assertEquals(((net.minidev.json.JSONObject) oidcTokens.getIDToken().getJWTClaimsSet()
Expand Down

0 comments on commit 5c54360

Please sign in to comment.