use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class HostListModel method updateConfigureLocalStorageCommandAvailability.
public void updateConfigureLocalStorageCommandAvailability() {
if (hasAdminSystemPermission == null) {
DbUser dbUser = Frontend.getInstance().getLoggedInUser();
if (dbUser == null) {
hasAdminSystemPermission = false;
updateConfigureLocalStorageCommandAvailability1();
return;
}
Frontend.getInstance().runQuery(QueryType.GetPermissionsByAdElementId, new IdQueryParameters(dbUser.getId()), new AsyncQuery<QueryReturnValue>(response -> {
if (response == null || !response.getSucceeded()) {
hasAdminSystemPermission = false;
updateConfigureLocalStorageCommandAvailability1();
} else {
ArrayList<Permission> permissions = response.getReturnValue();
for (Permission permission : permissions) {
if (permission.getObjectType() == VdcObjectType.System && permission.getRoleType() == RoleType.ADMIN) {
hasAdminSystemPermission = true;
break;
}
}
updateConfigureLocalStorageCommandAvailability1();
}
}, true));
} else {
updateConfigureLocalStorageCommandAvailability1();
}
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class DbUserDaoTest method testGetWithInvalidId.
/**
* Ensures that trying to get a user using an invalid id fails.
*/
@Test
public void testGetWithInvalidId() {
DbUser result = dao.get(Guid.newGuid());
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class DbUserDaoTest method testGetWithInvalidExternalId.
/**
* Ensures that trying to get an user with an invalid external id fails.
*/
@Test
public void testGetWithInvalidExternalId() {
DbUser result = dao.getByExternalId("testportal.redhat.com", "0");
assertNull(result);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class DbUserDaoTest method testUpdate.
/**
* Ensures that updating a user works as expected.
*/
@Test
public void testUpdate() {
existingUser.setFirstName("changedname");
existingUser.setLastName("changedsurname");
dao.update(existingUser);
DbUser result = dao.get(existingUser.getId());
assertEquals(existingUser, result);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class DbUserDaoTest method testUpdateLastAdminCheckStatus.
@Test
public void testUpdateLastAdminCheckStatus() {
// Getting a nonAdmin user that is defined in the fixtures
DbUser nonAdminUser = dbFacade.getDbUserDao().getByUsernameAndDomain("userportal2@testportal.redhat.com", "testportal.redhat.com");
assertNotNull(nonAdminUser);
assertFalse(nonAdminUser.isAdmin());
// execute and validate when not admin
dao.updateLastAdminCheckStatus(nonAdminUser.getId());
nonAdminUser = dbFacade.getDbUserDao().get(nonAdminUser.getId());
assertFalse(nonAdminUser.isAdmin());
Permission perms = new Permission();
perms.setRoleType(RoleType.ADMIN);
// An available role from the fixtures
perms.setRoleId(ADMIN_ROLE_TYPE_FROM_FIXTURE_ID);
perms.setAdElementId(nonAdminUser.getId());
perms.setObjectId(SYSTEM_OBJECT_ID);
perms.setObjectType(VdcObjectType.System);
// Save the permission to the DB and make sure it has been saved
dbFacade.getPermissionDao().save(perms);
assertNotNull(dbFacade.getPermissionDao().get(perms.getId()));
// execute and validate when admin
dao.updateLastAdminCheckStatus(nonAdminUser.getId());
nonAdminUser = dbFacade.getDbUserDao().get(nonAdminUser.getId());
assertTrue(nonAdminUser.isAdmin());
}
Aggregations