Search in sources :

Example 11 with DbGroup

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

the class DbGroupDaoTest method testGetByName.

/**
 * Ensures that finding by name works as expected.
 */
@Test
public void testGetByName() {
    DbGroup result = dao.getByName(existingGroup.getName());
    assertNotNull(result);
    assertEquals(existingGroup, result);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Test(org.junit.Test)

Example 12 with DbGroup

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

the class BackendGroupResourceTest method getEntity.

@Override
protected DbGroup getEntity(int index) {
    DbGroup entity = new DbGroup();
    entity.setId(GUIDS[index]);
    entity.setExternalId(EXTERNAL_IDS[index]);
    entity.setName(NAMES[index]);
    entity.setDomain(DOMAIN);
    return entity;
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup)

Example 13 with DbGroup

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

the class BackendGroupsResourceTest method testAddGroupWithImplicitDirectoryName.

/**
 * Test that a group can be added when the user doesn't explicitly provide the name of the directory, but provides
 * it as part of the group name.
 */
@Test
public void testAddGroupWithImplicitDirectoryName() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
    setUpGetEntityExpectations("ADGROUP@" + DOMAIN + ":: name=" + GROUP_NAMES_WITH_NO_DOMAIN[0], SearchType.DirectoryGroup, 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]);
    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 14 with DbGroup

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

the class BackendGroupsResourceTest method testAddGroupWithExplicitDirectoryName.

/**
 * Test that a group can be added when the user provides explicitly the name of the directory, so there is no need
 * to extract it from the name of the group.
 */
@Test
public void testAddGroupWithExplicitDirectoryName() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
    setUpGetEntityExpectations("ADGROUP@" + DOMAIN + ":: name=" + GROUP_NAMES_WITH_NO_DOMAIN[0], SearchType.DirectoryGroup, getDirectoryGroup(0));
    DbGroup dbGroup = new DbGroup(getDirectoryGroup(0));
    setUpCreationExpectations(ActionType.AddGroup, AddGroupParameters.class, new String[] { "GroupToAdd" }, new Object[] { dbGroup }, true, true, dbGroup.getId(), QueryType.GetDbGroupById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { dbGroup.getId() }, getEntity(0));
    Domain domain = new Domain();
    domain.setName(DOMAIN);
    domain.setId(DirectoryEntryIdUtils.encode(domain.getName()));
    Group model = new Group();
    model.setName(GROUP_NAMES_WITH_NO_DOMAIN[0]);
    model.setDomain(domain);
    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) Domain(org.ovirt.engine.api.model.Domain) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 15 with DbGroup

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

the class AddGroupCommand method executeCommand.

@Override
protected void executeCommand() {
    // First check if the group is already in the database, if it is we
    // need to update, if not we need to insert:
    DbGroup groupToAdd = getParameters().getGroupToAdd();
    DbGroup dbGroup = dbGroupDao.getByExternalId(groupToAdd.getDomain(), groupToAdd.getExternalId());
    if (dbGroup == null) {
        dbGroupDao.save(groupToAdd);
    } else {
        dbGroupDao.update(dbGroup);
        groupToAdd = dbGroup;
    }
    // Return the identifier of the created group:
    setActionReturnValue(groupToAdd.getId());
    setSucceeded(true);
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup)

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