Search in sources :

Example 6 with Group

use of org.ovirt.engine.api.model.Group 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 7 with Group

use of org.ovirt.engine.api.model.Group in project ovirt-engine by oVirt.

the class BackendGroupsResource method mapDbGroupCollection.

private Groups mapDbGroupCollection(List<DbGroup> entities) {
    Groups collection = new Groups();
    for (DbGroup entity : entities) {
        Group group = map(entity);
        group = populate(group, entity);
        group = addLinks(group, BaseResource.class);
        collection.getGroups().add(group);
    }
    return collection;
}
Also used : 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) Groups(org.ovirt.engine.api.model.Groups) BaseResource(org.ovirt.engine.api.model.BaseResource)

Example 8 with Group

use of org.ovirt.engine.api.model.Group in project ovirt-engine by oVirt.

the class BackendEntityAssignedPermissionsResourceTest method testAddGroupPermission.

@Test
public void testAddGroupPermission() throws Exception {
    setUriInfo(setUpBasicUriExpectations());
    setUpCreationExpectations(ActionType.AddPermission, PermissionsOperationsParameters.class, new String[] { "Group.Id", "Permission.AdElementId", "Permission.ObjectId", "Permission.RoleId" }, new Object[] { GUIDS[1], GUIDS[1], targetId, GUIDS[3] }, true, true, GUIDS[0], QueryType.GetPermissionById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
    Permission model = new Permission();
    model.setRole(new Role());
    model.getRole().setId(GUIDS[3].toString());
    model.setGroup(new Group());
    model.getGroup().setId(GUIDS[1].toString());
    Response response = collection.add(model);
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof Permission);
    verifyModel((Permission) response.getEntity(), 0);
}
Also used : Role(org.ovirt.engine.api.model.Role) Response(javax.ws.rs.core.Response) Group(org.ovirt.engine.api.model.Group) Permission(org.ovirt.engine.api.model.Permission) Test(org.junit.Test)

Example 9 with Group

use of org.ovirt.engine.api.model.Group 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 10 with Group

use of org.ovirt.engine.api.model.Group in project ovirt-engine by oVirt.

the class LinkHelperTest method testGroupLinks.

@Test
public void testGroupLinks() throws Exception {
    Group group = new Group();
    group.setId(GROUP_ID);
    LinkHelper.addLinks(group);
    assertEquals(GROUP_HREF, group.getHref());
}
Also used : Group(org.ovirt.engine.api.model.Group) Test(org.junit.Test)

Aggregations

Group (org.ovirt.engine.api.model.Group)19 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)12 DirectoryGroup (org.ovirt.engine.core.aaa.DirectoryGroup)11 Test (org.junit.Test)8 Domain (org.ovirt.engine.api.model.Domain)5 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)5 Response (javax.ws.rs.core.Response)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Groups (org.ovirt.engine.api.model.Groups)3 Permission (org.ovirt.engine.api.model.Permission)3 User (org.ovirt.engine.api.model.User)3 AuthzGroup (org.ovirt.engine.core.common.businessentities.aaa.AuthzGroup)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 Role (org.ovirt.engine.api.model.Role)2 BaseResource (org.ovirt.engine.api.model.BaseResource)1 Roles (org.ovirt.engine.api.model.Roles)1 V3Group (org.ovirt.engine.api.v3.types.V3Group)1 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)1