Search in sources :

Example 26 with UserDTO

use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project identity-governance by wso2-extensions.

the class UsernameUpdateServiceImplTest method testExceptionWhileUpdatingAccountDisableClaim.

@Test(expectedExceptions = UsernameUpdateException.class)
public void testExceptionWhileUpdatingAccountDisableClaim() throws Exception {
    UserDTO userDTO = buildUserDTO("testuser1", "testuser11", UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    RealmService realmService = mock(RealmService.class);
    TenantManager tenantManager = mock(TenantManager.class);
    UserRealm userRealm = mock(UserRealm.class);
    UserStoreManager userStoreManager = mock(UserStoreManager.class);
    when(realmService.getTenantManager()).thenReturn(tenantManager);
    when(tenantManager.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)).thenReturn(MultitenantConstants.SUPER_TENANT_ID);
    when(realmService.getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    when(userStoreManager.isExistingUser(UserCoreUtil.addDomainToName(userDTO.getExistingUsername(), userDTO.getUserStoreDomain()))).thenReturn(true);
    doThrow(new UserStoreException("Error while setting account disable claim")).when(userStoreManager).setUserClaimValues(anyString(), anyMap(), anyString());
    UsernameUpdateServiceImpl usernameUpdateServiceImpl = new UsernameUpdateServiceImpl();
    usernameUpdateServiceImpl.setRealmService(realmService);
    usernameUpdateServiceImpl.updateUsername(userDTO);
}
Also used : UserRealm(org.wso2.carbon.user.api.UserRealm) RealmService(org.wso2.carbon.user.core.service.RealmService) UserDTO(org.wso2.carbon.identity.user.rename.core.dto.UserDTO) UserStoreException(org.wso2.carbon.user.api.UserStoreException) UserStoreManager(org.wso2.carbon.user.api.UserStoreManager) TenantManager(org.wso2.carbon.user.core.tenant.TenantManager) Test(org.testng.annotations.Test)

Example 27 with UserDTO

use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project identity-governance by wso2-extensions.

the class UsernameUpdateServiceImplTest method testExceptionWhileVerifyingExistingUser.

@Test(expectedExceptions = UsernameUpdateException.class)
public void testExceptionWhileVerifyingExistingUser() throws Exception {
    UserDTO userDTO = buildUserDTO("testuser1", "testuser11", UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    RealmService realmService = mock(RealmService.class);
    TenantManager tenantManager = mock(TenantManager.class);
    UserRealm userRealm = mock(UserRealm.class);
    UserStoreManager userStoreManager = mock(UserStoreManager.class);
    when(realmService.getTenantManager()).thenReturn(tenantManager);
    when(tenantManager.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)).thenReturn(MultitenantConstants.SUPER_TENANT_ID);
    when(realmService.getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    when(userStoreManager.isExistingUser(UserCoreUtil.addDomainToName(userDTO.getExistingUsername(), userDTO.getUserStoreDomain()))).thenThrow(new UserStoreException("Error while checking for existing user"));
    UsernameUpdateServiceImpl usernameUpdateServiceImpl = new UsernameUpdateServiceImpl();
    usernameUpdateServiceImpl.setRealmService(realmService);
    usernameUpdateServiceImpl.updateUsername(userDTO);
}
Also used : UserRealm(org.wso2.carbon.user.api.UserRealm) RealmService(org.wso2.carbon.user.core.service.RealmService) UserDTO(org.wso2.carbon.identity.user.rename.core.dto.UserDTO) UserStoreException(org.wso2.carbon.user.api.UserStoreException) UserStoreManager(org.wso2.carbon.user.api.UserStoreManager) TenantManager(org.wso2.carbon.user.core.tenant.TenantManager) Test(org.testng.annotations.Test)

Example 28 with UserDTO

use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project identity-governance by wso2-extensions.

the class UsernameUpdateServiceImplTest method testExceptionAtNonExistingUser.

@Test(expectedExceptions = UsernameUpdateException.class)
public void testExceptionAtNonExistingUser() throws Exception {
    UserDTO userDTO = buildUserDTO("testuser1", "testuser11", UserCoreConstants.PRIMARY_DEFAULT_DOMAIN_NAME, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
    RealmService realmService = mock(RealmService.class);
    TenantManager tenantManager = mock(TenantManager.class);
    UserRealm userRealm = mock(UserRealm.class);
    UserStoreManager userStoreManager = mock(UserStoreManager.class);
    when(realmService.getTenantManager()).thenReturn(tenantManager);
    when(tenantManager.getTenantId(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)).thenReturn(MultitenantConstants.SUPER_TENANT_ID);
    when(realmService.getTenantUserRealm(MultitenantConstants.SUPER_TENANT_ID)).thenReturn(userRealm);
    when(userRealm.getUserStoreManager()).thenReturn(userStoreManager);
    when(userStoreManager.isExistingUser(UserCoreUtil.addDomainToName(userDTO.getExistingUsername(), userDTO.getUserStoreDomain()))).thenReturn(false);
    UsernameUpdateServiceImpl usernameUpdateServiceImpl = new UsernameUpdateServiceImpl();
    usernameUpdateServiceImpl.setRealmService(realmService);
    usernameUpdateServiceImpl.updateUsername(userDTO);
}
Also used : UserRealm(org.wso2.carbon.user.api.UserRealm) RealmService(org.wso2.carbon.user.core.service.RealmService) UserDTO(org.wso2.carbon.identity.user.rename.core.dto.UserDTO) UserStoreManager(org.wso2.carbon.user.api.UserStoreManager) TenantManager(org.wso2.carbon.user.core.tenant.TenantManager) Test(org.testng.annotations.Test)

Example 29 with UserDTO

use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project product-is by wso2.

the class AbstractUUIDUMTestCase method testUpdateUsersOfRole.

public void testUpdateUsersOfRole() throws Exception {
    userMgtClient.addRoleWithID(role4name, new String[] { userId }, new PermissionDTO[] {}, false);
    UserDTO userDTO = userMgtClient.addUserWithID(user3Username, credential2, new String[0], new ClaimValue[0], defaultProfile);
    String[] userList = new String[] { userDTO.getUserID() };
    userMgtClient.updateUserListOfRoleWithID(role4name, null, userList);
    Assert.assertTrue(userNameExists(userMgtClient.getUserListOfRoleWithID(role4name, user1Username, 1), user1Username), "Adding user1 to role has failed");
    Assert.assertTrue(userNameExists(userMgtClient.getUserListOfRoleWithID(role4name, user3Username, 1), user3Username), "Adding user3 to role has failed");
    userMgtClient.updateUserListOfRoleWithID(role4name, new String[] { userDTO.getUserID() }, null);
    Assert.assertFalse(userNameExists(userMgtClient.getUserListOfRoleWithID(role4name, user3Username, 1), user3Username), "Removing user3 from role has failed");
}
Also used : UserDTO(org.wso2.carbon.identity.test.integration.service.stub.UserDTO)

Example 30 with UserDTO

use of org.wso2.carbon.identity.test.integration.service.stub.UserDTO in project product-is by wso2.

the class AbstractUUIDUMTestCase method testListUsers.

public void testListUsers() throws Exception {
    boolean exists = false;
    UserDTO[] usersList = userMgtClient.listUsersWithID(user1Username, 100);
    for (UserDTO user : usersList) {
        if (this.userId.equals(user.getUserID())) {
            exists = true;
            break;
        }
    }
    Assert.assertTrue(exists, "List users has failed");
}
Also used : UserDTO(org.wso2.carbon.identity.test.integration.service.stub.UserDTO)

Aggregations

IdentityException (org.wso2.carbon.identity.base.IdentityException)23 UserDTO (org.wso2.carbon.identity.mgt.dto.UserDTO)22 VerificationBean (org.wso2.carbon.identity.mgt.beans.VerificationBean)19 RecoveryProcessor (org.wso2.carbon.identity.mgt.RecoveryProcessor)17 UserStoreException (org.wso2.carbon.user.api.UserStoreException)17 IdentityMgtServiceException (org.wso2.carbon.identity.mgt.IdentityMgtServiceException)14 PrivilegedCarbonContext (org.wso2.carbon.context.PrivilegedCarbonContext)12 Test (org.testng.annotations.Test)10 UserDTO (org.wso2.carbon.identity.user.rename.core.dto.UserDTO)10 UserRecoveryDTO (org.wso2.carbon.identity.mgt.dto.UserRecoveryDTO)9 UserStoreManager (org.wso2.carbon.user.api.UserStoreManager)9 RealmService (org.wso2.carbon.user.core.service.RealmService)9 TenantManager (org.wso2.carbon.user.core.tenant.TenantManager)8 UserDTO (org.wso2.carbon.identity.test.integration.service.stub.UserDTO)7 UserDTO (org.wso2.carbon.identity.user.endpoint.dto.UserDTO)6 NotificationDataDTO (org.wso2.carbon.identity.mgt.dto.NotificationDataDTO)5 UserChallengesDTO (org.wso2.carbon.identity.mgt.dto.UserChallengesDTO)4 User (org.wso2.carbon.apimgt.core.models.User)3 User (org.wso2.carbon.identity.application.common.model.User)3 ChallengeQuestionProcessor (org.wso2.carbon.identity.mgt.ChallengeQuestionProcessor)3