Search in sources :

Example 61 with DbUser

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();
    }
}
Also used : SearchType(org.ovirt.engine.core.common.interfaces.SearchType) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) RpmVersion(org.ovirt.engine.core.compat.RpmVersion) Arrays(java.util.Arrays) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) SearchObjects(org.ovirt.engine.core.searchbackend.SearchObjects) SetHaMaintenanceParameters(org.ovirt.engine.core.common.action.SetHaMaintenanceParameters) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Event(org.ovirt.engine.ui.uicompat.Event) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) Map(java.util.Map) Tags(org.ovirt.engine.core.common.businessentities.Tags) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HasEntity(org.ovirt.engine.ui.uicommonweb.models.HasEntity) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) SearchParameters(org.ovirt.engine.core.common.queries.SearchParameters) ActionUtils(org.ovirt.engine.core.common.ActionUtils) RoleType(org.ovirt.engine.core.common.businessentities.RoleType) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) VdsPowerDownParameters(org.ovirt.engine.core.common.action.VdsPowerDownParameters) Collection(java.util.Collection) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) Set(java.util.Set) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) StringHelper(org.ovirt.engine.core.compat.StringHelper) FrontendUrlUtils(org.ovirt.engine.ui.frontend.utils.FrontendUrlUtils) VdsSpmStatus(org.ovirt.engine.core.common.businessentities.VdsSpmStatus) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) List(java.util.List) VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) Cloner(org.ovirt.engine.ui.uicommonweb.Cloner) HostGeneralModel.createUpgradeModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostGeneralModel.createUpgradeModel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) HostErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.HostErrataCountModel) FenceAgent(org.ovirt.engine.core.common.businessentities.pm.FenceAgent) Uri(org.ovirt.engine.ui.uicommonweb.Uri) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) HostedEngineDeployConfiguration(org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration) UpdateVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.UpdateVdsActionParameters) AddVdsActionParameters(org.ovirt.engine.core.common.action.hostdeploy.AddVdsActionParameters) QueryType(org.ovirt.engine.core.common.queries.QueryType) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) Guid(org.ovirt.engine.core.compat.Guid) HostGlusterSwiftListModel(org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterSwiftListModel) HelpTag(org.ovirt.engine.ui.uicommonweb.help.HelpTag) ExternalDiscoveredHost(org.ovirt.engine.core.common.businessentities.ExternalDiscoveredHost) HashMap(java.util.HashMap) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) HostGlusterStorageDevicesListModel(org.ovirt.engine.ui.uicommonweb.models.gluster.HostGlusterStorageDevicesListModel) HashSet(java.util.HashSet) FenceVdsManualyParameters(org.ovirt.engine.core.common.action.FenceVdsManualyParameters) Frontend(org.ovirt.engine.ui.frontend.Frontend) ChangeVDSClusterParameters(org.ovirt.engine.core.common.action.ChangeVDSClusterParameters) HostMaintenanceConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.HostMaintenanceConfirmationModel) NumaSupportModel(org.ovirt.engine.ui.uicommonweb.models.hosts.numa.NumaSupportModel) Permission(org.ovirt.engine.core.common.businessentities.Permission) Window(com.google.gwt.user.client.Window) ForceSelectSPMParameters(org.ovirt.engine.core.common.action.ForceSelectSPMParameters) UIMessages(org.ovirt.engine.ui.uicompat.UIMessages) ReversibleFlow(org.ovirt.engine.ui.uicompat.ReversibleFlow) RemoveVdsParameters(org.ovirt.engine.core.common.action.RemoveVdsParameters) ExternalComputeResource(org.ovirt.engine.core.common.businessentities.ExternalComputeResource) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) SearchStringMapping(org.ovirt.engine.ui.uicommonweb.models.SearchStringMapping) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) ApproveVdsParameters(org.ovirt.engine.core.common.action.hostdeploy.ApproveVdsParameters) HaMaintenanceMode(org.ovirt.engine.core.common.businessentities.HaMaintenanceMode) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) TaskListModel(org.ovirt.engine.ui.uicommonweb.models.events.TaskListModel) FenceVdsActionParameters(org.ovirt.engine.core.common.action.FenceVdsActionParameters) FenceProxySourceTypeHelper(org.ovirt.engine.core.common.utils.pm.FenceProxySourceTypeHelper) ListWithSimpleDetailsModel(org.ovirt.engine.ui.uicommonweb.models.ListWithSimpleDetailsModel) HostAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.HostAffinityLabelListModel) UIConstants(org.ovirt.engine.ui.uicompat.UIConstants) TagAssigningModel(org.ovirt.engine.ui.uicommonweb.TagAssigningModel) HostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.HostDeviceListModel) WebAdminApplicationPlaces(org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces) Comparator(java.util.Comparator) Collections(java.util.Collections) VDS(org.ovirt.engine.core.common.businessentities.VDS) MaintenanceNumberOfVdssParameters(org.ovirt.engine.core.common.action.MaintenanceNumberOfVdssParameters) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ArrayList(java.util.ArrayList) Permission(org.ovirt.engine.core.common.businessentities.Permission) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 62 with DbUser

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);
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Example 63 with DbUser

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);
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Example 64 with DbUser

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);
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Example 65 with DbUser

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());
}
Also used : Permission(org.ovirt.engine.core.common.businessentities.Permission) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Test(org.junit.Test)

Aggregations

DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)109 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)18 Guid (org.ovirt.engine.core.compat.Guid)18 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)13 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)10 HashSet (java.util.HashSet)9 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)9 HashMap (java.util.HashMap)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 Collection (java.util.Collection)7 Before (org.junit.Before)7 Permission (org.ovirt.engine.core.common.businessentities.Permission)7 List (java.util.List)5 Map (java.util.Map)5 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)5 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)5