Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON array claims to backend JWT test cases #13080

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ public void testEnableJWTAndClaimsForJWTApp() throws Exception {
assertTrue("JWT claim givenname not received" + claim, claim.contains("first name".concat(endUser)));
claim = jsonObject.getString("http://wso2.org/claims/lastname");
assertTrue("JWT claim lastname not received" + claim, claim.contains("last name".concat(endUser)));
claim = jsonObject.getString("http://wso2.org/claims/region");
assertTrue("JWT claim region not received" + claim,
claim.contains("[{\"areaId\":\"71224\",\"areaName\":\"20-NYU\"}]"));
claim = jsonObject.getString("mobile");
assertTrue("JWT claim mobile not received" + claim, claim.contains("94123456987"));
claim = jsonObject.getString("organization");
Expand Down Expand Up @@ -531,6 +534,8 @@ private void createUser() throws RemoteException,
"http://wso2.org/claims/givenname", "first name".concat(user), DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
"http://wso2.org/claims/lastname", "last name".concat(user), DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
"http://wso2.org/claims/region", "[{'areaId':'71224','areaName':'20-NYU'}]", DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
"http://wso2.org/claims/organization", "ABC".concat(user), DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
Expand Down Expand Up @@ -660,7 +665,7 @@ private void updateServiceProviderWithRequiredClaims(String consumerKey)
throws OAuthAdminServiceIdentityOAuthAdminException, RemoteException,
IdentityApplicationManagementServiceIdentityApplicationManagementException {
String[] requestedClaims = { "http://wso2.org/claims/givenname", "http://wso2.org/claims/lastname",
"http://wso2.org/claims/mobile", "http://wso2.org/claims/organization",
"http://wso2.org/claims/region", "http://wso2.org/claims/mobile", "http://wso2.org/claims/organization",
"http://wso2.org/claims/telephone", "http://wso2.org/claims/emailaddress" };
OAuthConsumerAppDTO oAuthApplicationData = oAuthAdminServiceClient.getOAuthApplicationData(consumerKey);
String applicationName = oAuthApplicationData.getApplicationName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ public void testEnableJWTAndClaimsForJWTApp() throws Exception {
assertTrue("JWT claim givenname not received" + claim, claim.contains("first name".concat(endUser)));
claim = jsonObject.getString("http://wso2.org/claims/lastname");
assertTrue("JWT claim lastname not received" + claim, claim.contains("last name".concat(endUser)));
claim = jsonObject.getString("http://wso2.org/claims/region");
assertTrue("JWT claim region not received" + claim,
claim.contains("[{\"areaId\":\"71224\",\"areaName\":\"20-NYU\"}]"));
claim = jsonObject.getString("mobile");
assertTrue("JWT claim mobile not received" + claim, claim.contains("94123456987"));
claim = jsonObject.getString("organization");
Expand Down Expand Up @@ -523,6 +526,8 @@ private void createUser() throws RemoteException,
"http://wso2.org/claims/givenname", "first name".concat(user), DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
"http://wso2.org/claims/lastname", "last name".concat(user), DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
"http://wso2.org/claims/region", "[{'areaId':'71224','areaName':'20-NYU'}]", DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
"http://wso2.org/claims/organization", "ABC".concat(user), DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(user,
Expand All @@ -545,8 +550,8 @@ private void createClaimMapping() throws RemoteException, ClaimMetadataManagemen
private void updateServiceProviderWithRequiredClaims(String consumerKey)
throws OAuthAdminServiceIdentityOAuthAdminException, RemoteException,
IdentityApplicationManagementServiceIdentityApplicationManagementException {
String[] requestedClaims = {"http://wso2.org/claims/givenname","http://wso2.org/claims/lastname","http://wso2" +
".org/claims/organization","http://wso2.org/claims/mobile"};
String[] requestedClaims = {"http://wso2.org/claims/givenname","http://wso2.org/claims/lastname",
"http://wso2.org/claims/region","http://wso2.org/claims/organization","http://wso2.org/claims/mobile"};
OAuthConsumerAppDTO oAuthApplicationData = oAuthAdminServiceClient.getOAuthApplicationData(consumerKey);
String applicationName = oAuthApplicationData.getApplicationName();
ServiceProvider application = applicationManagementClient.getApplication(applicationName);
Expand Down Expand Up @@ -707,6 +712,9 @@ private void verifyUserProfileInfoClaims(JSONObject decodedJWTJSONObject, String
assertTrue("JWT claim givenname not received" + claim, claim.contains("first name".concat(endUser)));
claim = decodedJWTJSONObject.getString("http://wso2.org/claims/lastname");
assertTrue("JWT claim lastname not received" + claim, claim.contains("last name".concat(endUser)));
claim = decodedJWTJSONObject.getString("http://wso2.org/claims/region");
assertTrue("JWT claim region not received" + claim,
claim.contains("[{\"areaId\":\"71224\",\"areaName\":\"20-NYU\"}]"));
claim = decodedJWTJSONObject.getString("http://wso2.org/claims/mobile");
assertTrue("JWT claim mobile not received" + claim, claim.contains("94123456987"));
claim = decodedJWTJSONObject.getString("http://wso2.org/claims/organization");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public void testEnableJWTAndClaimsForOauthApp() throws Exception {
assertTrue("JWT claim givenname not received" + claim, claim.contains("first name"));
claim = jsonObject.getString("http://wso2.org/claims/lastname");
assertTrue("JWT claim lastname not received" + claim, claim.contains("last name"));
claim = jsonObject.getString("http://wso2.org/claims/region");
assertTrue("JWT claim region not received" + claim,
claim.contains("[{\"areaId\":\"71224\",\"areaName\":\"20-NYU\"}]"));
boolean bExceptionOccured = false;
try {
jsonObject.getString("http://wso2.org/claims/wrongclaim");
Expand Down Expand Up @@ -276,6 +279,8 @@ private void createUser() throws RemoteException,
"http://wso2.org/claims/givenname", "first name", DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(enduserName,
"http://wso2.org/claims/lastname", "last name", DEFAULT_PROFILE);
remoteUserStoreManagerServiceClient.setUserClaimValue(enduserName,
"http://wso2.org/claims/region", "[{'areaId':'71224','areaName':'20-NYU'}]", DEFAULT_PROFILE);

}

Expand Down
Loading