use of org.ovirt.engine.api.model.Permission in project ovirt-engine by oVirt.
the class BackendAssignedPermissionsResource method mapCollection.
protected Permissions mapCollection(Set<org.ovirt.engine.core.common.businessentities.Permission> entities) {
Permissions collection = new Permissions();
for (org.ovirt.engine.core.common.businessentities.Permission entity : entities) {
castEveryonePermissionsToUser(entity);
Permission permission = map(entity, getUserById(entity.getAdElementId()));
collection.getPermissions().add(addLinks(permission, permission.getUser() != null ? suggestedParentType : Group.class));
}
return collection;
}
use of org.ovirt.engine.api.model.Permission in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testMissingBothAlternatives.
@Test
public void testMissingBothAlternatives() throws Exception {
Permission permission = new Permission();
permission.setVm(new Vm());
try {
CompletenessAssertor.validateParameters(permission, "user|vm.name|id");
fail("expected WebApplicationException on incomplete model");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Permission", "user|vm.name|id");
}
}
use of org.ovirt.engine.api.model.Permission in project ovirt-engine by oVirt.
the class BackendUserAssignedPermissionsResourceTest method testAddIncompletePermission.
@Test
public void testAddIncompletePermission() throws Exception {
Permission model = new Permission();
model.setUser(new User());
model.getUser().setId(GUIDS[1].toString());
model.setRole(new Role());
model.getRole().setId(GUIDS[3].toString());
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Permission", "add", "dataCenter|cluster|host|storageDomain|vm|vmPool|template.id");
}
}
use of org.ovirt.engine.api.model.Permission in project ovirt-engine by oVirt.
the class BackendEntityAssignedPermissionsResourceTest method testAddIncompletePermission.
@Test
public void testAddIncompletePermission() throws Exception {
Permission model = new Permission();
model.setDataCenter(new DataCenter());
model.getDataCenter().setId(GUIDS[2].toString());
model.setRole(new Role());
model.getRole().setId(GUIDS[3].toString());
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Permission", "add", "user|group.id");
}
}
use of org.ovirt.engine.api.model.Permission 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);
}
Aggregations