use of org.wso2.carbon.identity.user.rename.core.dto.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);
}
use of org.wso2.carbon.identity.user.rename.core.dto.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);
}
use of org.wso2.carbon.identity.user.rename.core.dto.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);
}
use of org.wso2.carbon.identity.user.rename.core.dto.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");
}
use of org.wso2.carbon.identity.user.rename.core.dto.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");
}
Aggregations