Search in sources :

Example 21 with DbGroup

use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.

the class DbGroupDaoTest method testGetByNameWithInvalidName.

/**
 * Ensures that, if the supplied name is invalid, then no group is returned.
 */
@Test
public void testGetByNameWithInvalidName() {
    DbGroup result = dao.getByName("thisnameisinvalid");
    assertNull(result);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Test(org.junit.Test)

Example 22 with DbGroup

use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.

the class DbGroupDaoTest method testGetWithInvalidExternalId.

/**
 * Ensures that trying to get a group with an invalid external id fails.
 */
@Test
public void testGetWithInvalidExternalId() {
    DbGroup result = dao.getByExternalId("rhel", "0");
    assertNull(result);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Test(org.junit.Test)

Example 23 with DbGroup

use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.

the class BackendGroupsResourceTest method testAddGroupById.

/**
 * Test that if the group identifier is provided it is used to search in the directory instead of the name.
 */
@Test
public void testAddGroupById() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
    setUpGetEntityExpectations(QueryType.GetDirectoryGroupById, DirectoryIdQueryParameters.class, new String[] { "Domain", "Id" }, new Object[] { DOMAIN, DirectoryEntryIdUtils.decode(EXTERNAL_IDS[0]) }, getDirectoryGroup(0));
    setUpCreationExpectations(ActionType.AddGroup, AddGroupParameters.class, new String[] { "GroupToAdd" }, new Object[] { new DbGroup(getDirectoryGroup(0)) }, true, true, GUIDS[0], QueryType.GetDbGroupById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Group model = new Group();
    model.setName(GROUP_NAMES[0]);
    model.setId(EXTERNAL_IDS[0]);
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Group);
    verifyModel((Group) response.getEntity(), 0);
}
Also used : Response(javax.ws.rs.core.Response) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Group(org.ovirt.engine.api.model.Group) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 24 with DbGroup

use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.

the class BackendGroupsResourceTest method verifyModel.

@Override
protected void verifyModel(Group model, int index) {
    DbGroup entity = getEntity(index);
    assertEquals(entity.getId().toString(), model.getId());
    assertEquals(entity.getName(), model.getName());
    assertNotNull(model.getDomain());
    assertEquals(DirectoryEntryIdUtils.encode(entity.getDomain()), model.getDomain().getId());
    verifyLinks(model);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup)

Example 25 with DbGroup

use of org.ovirt.engine.core.common.businessentities.aaa.DbGroup in project ovirt-engine by oVirt.

the class PermissionListModel method onAdd.

private void onAdd() {
    AdElementListModel model = (AdElementListModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (model.getSearchType() != AdSearchType.EVERYONE && model.getSelectedItems() == null) {
        cancel();
        return;
    }
    ArrayList<DbUser> items = new ArrayList<>();
    if (model.getSearchType() == AdSearchType.EVERYONE) {
        DbUser tempVar = new DbUser();
        tempVar.setId(ApplicationGuids.everyone.asGuid());
        items.add(tempVar);
    } else {
        for (Object item : model.getItems()) {
            EntityModel entityModel = (EntityModel) item;
            if (entityModel.getIsSelected()) {
                items.add((DbUser) entityModel.getEntity());
            }
        }
    }
    Role role = model.getRole().getSelectedItem();
    // adGroup/user
    ArrayList<ActionParametersBase> list = new ArrayList<>();
    for (DbUser user : items) {
        Permission perm = new Permission(user.getId(), role.getId(), getEntityGuid(), getObjectType());
        if (user.isGroup()) {
            DbGroup group = new DbGroup();
            group.setId(user.getId());
            group.setExternalId(user.getExternalId());
            group.setName(user.getFirstName());
            group.setDomain(user.getDomain());
            group.setNamespace(user.getNamespace());
            PermissionsOperationsParameters tempVar3 = new PermissionsOperationsParameters();
            tempVar3.setPermission(perm);
            tempVar3.setGroup(group);
            list.add(tempVar3);
        } else {
            PermissionsOperationsParameters tempVar4 = new PermissionsOperationsParameters();
            tempVar4.setPermission(perm);
            tempVar4.setUser(user);
            list.add(tempVar4);
        }
    }
    model.startProgress();
    Frontend.getInstance().runMultipleAction(ActionType.AddPermission, list, result -> {
        AdElementListModel localModel = (AdElementListModel) result.getState();
        localModel.stopProgress();
        cancel();
    }, model);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) PermissionsOperationsParameters(org.ovirt.engine.core.common.action.PermissionsOperationsParameters) ArrayList(java.util.ArrayList) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Permission(org.ovirt.engine.core.common.businessentities.Permission) AdElementListModel(org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Aggregations

DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)34 Test (org.junit.Test)13 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)10 Guid (org.ovirt.engine.core.compat.Guid)9 ArrayList (java.util.ArrayList)6 Group (org.ovirt.engine.api.model.Group)6 DirectoryGroup (org.ovirt.engine.core.aaa.DirectoryGroup)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)5 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)5 Permission (org.ovirt.engine.core.common.businessentities.Permission)5 Response (javax.ws.rs.core.Response)3 Domain (org.ovirt.engine.api.model.Domain)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Role (org.ovirt.engine.core.common.businessentities.Role)3 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)3 AdElementListModel (org.ovirt.engine.ui.uicommonweb.models.users.AdElementListModel)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExtMap (org.ovirt.engine.api.extensions.ExtMap)2