Search in sources :

Example 6 with UserFieldDTO

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.");
}
Also used : UserFieldDTO(org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO) UserProfileDTO(org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 7 with UserFieldDTO

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);
}
Also used : UserFieldDTO(org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO) UserProfileDTO(org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO)

Example 8 with UserFieldDTO

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");
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) ClaimValue(org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue) UserFieldDTO(org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO) UserProfileDTO(org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 9 with UserFieldDTO

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();
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) UserFieldDTO(org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO) UserProfileDTO(org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 10 with UserFieldDTO

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.");
}
Also used : UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) UserFieldDTO(org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO) UserProfileDTO(org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

UserFieldDTO (org.wso2.carbon.identity.user.profile.stub.types.UserFieldDTO)9 UserProfileDTO (org.wso2.carbon.identity.user.profile.stub.types.UserProfileDTO)9 Test (org.testng.annotations.Test)7 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)7 UserRealm (org.wso2.carbon.user.core.UserRealm)6 CarbonException (org.wso2.carbon.CarbonException)4 FederatedAssociationManagerException (org.wso2.carbon.identity.user.profile.mgt.association.federation.exception.FederatedAssociationManagerException)4 IdentityProviderManagementException (org.wso2.carbon.idp.mgt.IdentityProviderManagementException)4 UserStoreException (org.wso2.carbon.user.api.UserStoreException)4 UserProfileMgtServiceClient (org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient)4 UserFieldDTO (org.wso2.carbon.identity.user.registration.dto.UserFieldDTO)3 Claim (org.wso2.carbon.user.api.Claim)3 UserStoreManager (org.wso2.carbon.user.api.UserStoreManager)3 AbstractUserStoreManager (org.wso2.carbon.user.core.common.AbstractUserStoreManager)3 ProfileConfigurationManager (org.wso2.carbon.user.core.profile.ProfileConfigurationManager)3 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 MessageContext (org.apache.axis2.context.MessageContext)2 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)2 UserDTO (org.wso2.carbon.identity.user.registration.stub.dto.UserDTO)2