From bff2f0f8c9499d801fff00dfba224e95bf3be11b Mon Sep 17 00:00:00 2001 From: Madhavi Gayathri Date: Thu, 24 Oct 2024 12:25:14 +0530 Subject: [PATCH] Refactor. --- ...eGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java | 5 ++--- ...dGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServiceAuthCodeGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServiceAuthCodeGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java index 979f37a18c4..1327c122039 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServiceAuthCodeGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServiceAuthCodeGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java @@ -241,13 +241,12 @@ private void validateUserClaims(OIDCTokens oidcTokens) throws JSONException, Par // Check if user claims are present in access token. JSONObject jwtJsonObject = new JSONObject(new String(Base64.decodeBase64(accessToken.split("\\.")[1]))); - boolean assertion = false; try { Object emailClaim = jwtJsonObject.get(EMAIL_OIDC_CLAIM); + Assert.fail("Requested user claim (email) is present in the JWT access token."); } catch (JSONException e) { - assertion = true; + Assert.assertTrue(true, "Requested user claim (email) is present in the JWT access token."); } - Assert.assertTrue(assertion, "Requested user claim (email) 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, diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServicePasswordGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServicePasswordGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java index 4ae07542765..571ed18d46f 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServicePasswordGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/oauth2/consented/token/OAuth2ServicePasswordGrantJWTAccessTokenWithConsentedTokenColumnTestCase.java @@ -140,13 +140,12 @@ private void validateUserClaims(OIDCTokens oidcTokens) throws JSONException, jav "\\.")[1]))); // Check if user claims are present in access token. - boolean assertion = false; try { Object emailClaim = jwtJsonObject.get(EMAIL_OIDC_CLAIM); + Assert.fail("Requested user claim (email) is present in the JWT access token."); } catch (JSONException e) { - assertion = true; + Assert.assertTrue(true, "Requested user claim (email) is present in the JWT access token."); } - Assert.assertTrue(assertion, "Requested user claim (email) is 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.");