Search in sources :

Example 11 with FlaggedName

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

the class UserManagementClient method roleNameExists.

public boolean roleNameExists(String roleName) throws RemoteException, UserAdminUserAdminException {
    FlaggedName[] roles;
    roles = userAdminStub.getAllRolesNames(roleName, LIMIT);
    for (FlaggedName role : roles) {
        if (role.getItemName().equals(roleName)) {
            log.info("Role name " + roleName + " already exists");
            return true;
        }
    }
    return false;
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 12 with FlaggedName

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

the class UserManagementClient method addRoleWithUser.

private void addRoleWithUser(String roleName, String userName, String[] permission) throws RemoteException, UserAdminUserAdminException {
    userAdminStub.addRole(roleName, new String[] { userName }, null, false);
    FlaggedName[] roles = userAdminStub.getAllRolesNames(roleName, 100);
    for (FlaggedName role : roles) {
        if (!role.getItemName().equals(roleName)) {
            continue;
        } else {
            assert (role.getItemName().equals(roleName));
        }
        assert false : "Role: " + roleName + " was not added properly.";
    }
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 13 with FlaggedName

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

the class UserManagementClient method addRoleWithUser.

private void addRoleWithUser(String roleName, String userName, boolean isSharedRole) throws RemoteException, UserAdminUserAdminException {
    userAdminStub.addRole(roleName, new String[] { userName }, null, isSharedRole);
    FlaggedName[] roles = userAdminStub.getAllRolesNames(roleName, 100);
    for (FlaggedName role : roles) {
        if (!role.getItemName().equals(roleName)) {
            continue;
        } else {
            assert (role.getItemName().equals(roleName));
        }
        assert false : "Role: " + roleName + " was not added properly.";
    }
}
Also used : FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)

Example 14 with FlaggedName

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

the class SCIMServiceProviderGroupTestCase method listGroup.

@Test(alwaysRun = true, description = "list SCIM Groups", dependsOnMethods = { "getGroup" })
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
public void listGroup() throws Exception {
    SCIMResponseHandler responseHandler = new SCIMResponseHandler();
    responseHandler.setSCIMClient(scimClient);
    // set the handler in wink client config
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.handlers(new ClientHandler[] { responseHandler });
    // create a wink rest client with the above config
    RestClient restClient = new RestClient(clientConfig);
    BasicAuthInfo encodedBasicAuthInfo = SCIMUtils.getBasicAuthInfo(userInfo);
    // create resource endpoint to access a known user resource.
    Resource groupResource = restClient.resource(scim_url + "Groups/" + scimGroupId);
    String response = groupResource.header(SCIMConstants.AUTHORIZATION_HEADER, encodedBasicAuthInfo.getAuthorizationHeader()).contentType(SCIMConstants.APPLICATION_JSON).accept(SCIMConstants.APPLICATION_JSON).get(String.class);
    log.info(response.toString());
    FlaggedName[] roleNames = userMgtClient.listRoles("eng", 100);
    for (FlaggedName role : roleNames) {
        if (!role.getItemName().contains("false")) {
            Assert.assertTrue(response.contains(role.getItemName()));
        }
    }
}
Also used : RestClient(org.apache.wink.client.RestClient) Resource(org.apache.wink.client.Resource) FlaggedName(org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName) BasicAuthInfo(org.wso2.identity.integration.test.utils.BasicAuthInfo) SCIMResponseHandler(org.wso2.identity.integration.test.scim.utils.SCIMResponseHandler) ClientConfig(org.apache.wink.client.ClientConfig) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) Test(org.testng.annotations.Test)

Example 15 with FlaggedName

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

the class UserManagementServiceAbstractTest method testUpdateUsersOfRole.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check update users of role", dependsOnMethods = "testAddRemoveRolesOfUser")
public void testUpdateUsersOfRole() throws Exception {
    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;
    }
    userMgtClient.updateUsersOfRole(newUserRole, userFlagList);
    Assert.assertTrue(nameExists(userMgtClient.getUsersOfRole(newUserRole, newUserName, 0), newUserName), "Adding user to role has failed");
    // Calling with same user list should delete the users.
    for (int i = 0; i < userFlagList.length; i++) {
        userFlagList[i].setSelected(false);
    }
    userMgtClient.updateUsersOfRole(userRoleTmp, userFlagList);
    Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole(userRoleTmp, newUserName, 0), newUserName), "Deleting user from role has failed");
// Assert.assertFalse(nameExists(userMgtClient.getUsersOfRole("umRole1", "user2", 0), "user2"), "Deleting user2 from role has failed");
}
Also used : 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)

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