Search in sources :

Example 31 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class ReadOnlyLDAPUserStoreManagerTestCase method testUpdateUsersOfRole.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check update users of role")
public void testUpdateUsersOfRole() {
    String[] userList = new String[] { newUserName };
    FlaggedName[] userFlagList = new FlaggedName[userList.length];
    for (int i = 0; i < userFlagList.length; i++) {
        FlaggedName flaggedName = new FlaggedName();
        flaggedName.setItemName(userList[i]);
        flaggedName.setSelected(true);
        userFlagList[i] = flaggedName;
    }
    try {
        userMgtClient.updateUsersOfRole("admin", userFlagList);
    } catch (Exception e) {
        Assert.assertEquals(e.getMessage(), "UserAdminUserAdminException", "Error Message mismatched");
    }
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) RemoteException(java.rmi.RemoteException) UserAdminUserAdminException(org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 32 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class ReadOnlyLDAPUserStoreManagerTestCase method testListByClaimUsers.

@Test(groups = "wso2.is", description = "Check delete role")
public void testListByClaimUsers() throws Exception {
    ClaimValue claimValue = new ClaimValue();
    claimValue.setClaimURI("http://wso2.org/claims/lastname");
    claimValue.setValue("*");
    FlaggedName[] flaggedNames = userMgtClient.listUserByClaim(claimValue, "*", 1000);
    for (FlaggedName name : flaggedNames) {
        if (name.getItemName().equals("krbtgt") || name.getItemName().equals("ldap")) {
            Assert.fail("invalid user retrieved with claim : " + name.getItemName());
        }
    }
}
Also used : ClaimValue(org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 33 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class UserMgtServiceAbstractTestCase method testUpdateRolesOfUser.

public void testUpdateRolesOfUser() throws Exception {
    List<String> newRoleList = new ArrayList<String>();
    FlaggedName[] currentRoleList = userMgtClient.getRolesOfUser("user3", null, 0);
    if (currentRoleList != null) {
        for (FlaggedName role : currentRoleList) {
            if (role.getSelected()) {
                newRoleList.add(role.getItemName());
            }
        }
    }
    if (!newRoleList.contains("umRole1")) {
        newRoleList.add("umRole1");
    }
    userMgtClient.updateRolesOfUser("user3", newRoleList.toArray(new String[newRoleList.size()]));
    Assert.assertTrue(nameExists(userMgtClient.getRolesOfUser("user3", "umRole1", 10), "umRole1"), "Adding umRole1 to user has failed");
    newRoleList.remove("umRole1");
    userMgtClient.updateRolesOfUser("user3", newRoleList.toArray(new String[newRoleList.size()]));
    Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole("user3", "umRole1", 10), "umRole1"), "Deleting umRole1 from user has failed");
}
Also used : ArrayList(java.util.ArrayList) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 34 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class UserMgtServiceAbstractTestCase method testListUsers.

public void testListUsers() throws Exception {
    boolean exists = false;
    FlaggedName[] usersList = userMgtClient.listAllUsers("user1", 100);
    for (FlaggedName user : usersList) {
        if ("user1".equals(user.getItemName())) {
            exists = true;
            break;
        }
    }
    Assert.assertTrue(exists, "List users has failed");
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 35 with FlaggedName

use of org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName in project product-is by wso2.

the class UserMgtServiceAbstractTestCase method testListUserByClaim.

public void testListUserByClaim() throws Exception {
    ClaimValue claimValue = new ClaimValue();
    claimValue.setClaimURI("http://wso2.org/claims/lastname");
    claimValue.setValue("user3");
    loginManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    FlaggedName[] allNames = userMgtClient.listUserByClaim(claimValue, "user3", 10);
    Assert.assertTrue(nameExists(allNames, "user3"), "List user with claim value has failed");
    loginManger.logOut();
}
Also used : ClaimValue(org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Aggregations

FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)31 ArrayList (java.util.ArrayList)14 FlaggedName (org.wso2.carbon.user.mgt.common.FlaggedName)13 Test (org.testng.annotations.Test)12 UserAdminException (org.wso2.carbon.user.mgt.common.UserAdminException)10 AbstractUserStoreManager (org.wso2.carbon.user.core.common.AbstractUserStoreManager)9 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)8 HashMap (java.util.HashMap)7 RegistryException (org.wso2.carbon.registry.api.RegistryException)7 UserStoreException (org.wso2.carbon.user.core.UserStoreException)7 UserStoreManager (org.wso2.carbon.user.core.UserStoreManager)7 JDBCUserStoreManager (org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager)7 ClaimValue (org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue)7 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)4 Mockito.anyString (org.mockito.Mockito.anyString)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 BeforeTest (org.testng.annotations.BeforeTest)3 AuthorizationManager (org.wso2.carbon.user.api.AuthorizationManager)3 UserAdminUserAdminException (org.wso2.carbon.user.mgt.stub.UserAdminUserAdminException)3 Field (java.lang.reflect.Field)2