use of org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO in project product-is by wso2.
the class EntitlementServiceTestCase method testGetDecisionDenyState.
@Test(groups = "wso2.is", dependsOnMethods = { "testGetDecisionByAttributes" }, description = "Check get decision deny state")
public void testGetDecisionDenyState() throws Exception {
UserProfileDTO profile = userProfileMgtClient.getUserProfile("admin", "default");
UserFieldDTO country = new UserFieldDTO();
country.setClaimUri("http://wso2.org/claims/country");
country.setFieldValue("USA");
UserFieldDTO[] fields = profile.getFieldValues();
UserFieldDTO[] newfields = new UserFieldDTO[fields.length];
for (int i = 0; i < fields.length; i++) {
if (fields[i].getDisplayName().toString().equals("Country")) {
newfields[i] = country;
} else {
newfields[i] = fields[i];
}
}
profile.setFieldValues(newfields);
userProfileMgtClient.setUserProfile("admin", profile);
Thread.sleep(5000);
String decision = entitlementServiceClient.getDecisionByAttributes("admin", "http://localhost:8280/services/echo/", "read", null);
log.info(decision);
Assert.assertTrue(decision.contains("Deny"), "Entitlement service get decision failed.");
}
use of org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO in project product-is by wso2.
the class OAuth2ServiceJWTGrantTestCase method addNewUserWithClaims.
/**
* Add a new with 3 user claims.
*
* @throws RemoteException Remote Exception.
* @throws UserAdminUserAdminException User Admin User Admin Exception.
* @throws UserProfileMgtServiceUserProfileExceptionException User Profile Mgt Service User Profile Exception.
*/
private void addNewUserWithClaims() throws RemoteException, UserAdminUserAdminException, UserProfileMgtServiceUserProfileExceptionException {
String profileName = "default";
String adminRoleName = "admin";
String countryLocalClaimUri = "http://wso2.org/claims/country";
String givenNameLocalClaimUri = "http://wso2.org/claims/givenname";
userManagementClient.addUser(JWT_USER, JWT_USER, new String[] { adminRoleName }, profileName);
UserProfileDTO profile = new UserProfileDTO();
profile.setProfileName(profileName);
UserFieldDTO country = new UserFieldDTO();
country.setClaimUri(countryLocalClaimUri);
country.setFieldValue(COUNTRY_CLAIM_VALUE);
UserFieldDTO givenname = new UserFieldDTO();
givenname.setClaimUri(givenNameLocalClaimUri);
givenname.setFieldValue(JWT_USER);
UserFieldDTO email = new UserFieldDTO();
email.setClaimUri(EMAIL_LOCAL_CLAIM_URI);
email.setFieldValue(EMAIL_CLAIM_VALUE);
UserFieldDTO[] fields = new UserFieldDTO[3];
fields[0] = country;
fields[1] = givenname;
fields[2] = email;
profile.setFieldValues(fields);
userProfileMgtServiceClient.setUserProfile(JWT_USER, profile);
}
use of org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO in project product-is by wso2.
the class UserManagementServiceAbstractTest method testListUserByClaim.
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check list users by claim value", dependsOnMethods = "testGetRolesOfCurrentUser")
public void testListUserByClaim() throws Exception {
UserProfileMgtServiceClient userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, getSessionCookie());
UserProfileDTO profile = userProfileMgtServiceClient.getUserProfile(newUserName, "default");
UserFieldDTO[] fields = userProfileMgtServiceClient.getProfileFieldsForInternalStore().getFieldValues();
String profileConfigs = profile.getProfileName();
for (UserFieldDTO field : fields) {
if (field.getDisplayName().equalsIgnoreCase("Last Name")) {
field.setFieldValue(newUserName + "LastName");
continue;
}
if (field.getRequired()) {
if (field.getDisplayName().equalsIgnoreCase("Email")) {
field.setFieldValue(newUserName + "@wso2.com");
} else {
field.setFieldValue(newUserName);
}
continue;
}
if (field.getFieldValue() == null) {
field.setFieldValue("");
}
}
// creating a new profile with updated values
UserProfileDTO newProfile = new UserProfileDTO();
newProfile.setProfileName(profile.getProfileName());
newProfile.setFieldValues(fields);
newProfile.setProfileConifuration(profileConfigs);
userProfileMgtServiceClient.setUserProfile(newUserName, newProfile);
ClaimValue claimValue = new ClaimValue();
claimValue.setClaimURI("http://wso2.org/claims/lastname");
claimValue.setValue(newUserName + "LastName");
FlaggedName[] allNames = userMgtClient.listUserByClaim(claimValue, newUserName, 10);
Assert.assertTrue(nameExists(allNames, newUserName), "List user with claim value has failed");
}
use of org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO in project product-is by wso2.
the class UserProfileAdminTestCase method testSetUserProfile.
/**
* Setting a user profile updates the user claim values of the existing user profile of the user.
* This test method tests the above behavior.
*
* @throws Exception
*/
@Test(priority = 3, groups = "wso2.is", description = "Check set user profiles")
public void testSetUserProfile() throws Exception {
super.init();
logManger = new AuthenticatorClient(backendURL);
userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
logManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
UserProfileDTO profile = new UserProfileDTO();
profile.setProfileName("default");
UserFieldDTO lastName = new UserFieldDTO();
lastName.setClaimUri("http://wso2.org/claims/lastname");
lastName.setFieldValue("lastname");
UserFieldDTO givenname = new UserFieldDTO();
givenname.setClaimUri("http://wso2.org/claims/givenname");
givenname.setFieldValue("firstname");
UserFieldDTO email = new UserFieldDTO();
email.setClaimUri("http://wso2.org/claims/emailaddress");
email.setFieldValue("email@email.com");
UserFieldDTO[] fields = new UserFieldDTO[3];
fields[0] = lastName;
fields[1] = givenname;
fields[2] = email;
profile.setFieldValues(fields);
userProfileMgtClient.setUserProfile(userId1, profile);
UserProfileDTO getProfile = userProfileMgtClient.getUserProfile(userId1, "default");
UserFieldDTO[] updatedFields = getProfile.getFieldValues();
for (UserFieldDTO updatedField : updatedFields) {
if (updatedField.getClaimUri().equals("http://wso2.org/claims/lastname")) {
Assert.assertEquals(updatedField.getFieldValue(), "lastname");
} else if (updatedField.getClaimUri().equals("http://wso2.org/claims/givenname")) {
Assert.assertEquals(updatedField.getFieldValue(), "firstname");
} else if (updatedField.getClaimUri().equals("http://wso2.org/claims/emailaddress")) {
Assert.assertEquals(updatedField.getFieldValue(), "email@email.com");
}
}
logManger.logOut();
}
use of org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO in project product-is by wso2.
the class UserProfileAdminTestCase method testGetUserProfile.
@Test(priority = 2, groups = "wso2.is", description = "Check get user profile")
public void testGetUserProfile() throws Exception {
super.init();
userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
UserProfileDTO profile = userProfileMgtClient.getUserProfile(userId1, "default");
UserFieldDTO[] fields = profile.getFieldValues();
String displayValue = null;
for (UserFieldDTO field : fields) {
if ("Last Name".equals(field.getDisplayName())) {
displayValue = field.getFieldValue();
break;
}
}
Assert.assertTrue(userId1.equals(displayValue), "Getting user profile has failed.");
}
Aggregations