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);
}
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;
}
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);
}
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);
}
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());
}
Aggregations