use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class BackendRolesResourceTest method testAddRole.
@Test
public void testAddRole() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpCreationExpectations(ActionType.AddRoleWithActionGroups, RoleWithActionGroupsParameters.class, new String[] { "Role.Id", "Role.Name" }, new Object[] { GUIDS[0], NAMES[0] }, true, true, GUIDS[0], QueryType.GetRoleById, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Role model = new Role();
model.setName(NAMES[0]);
model.setPermits(new Permits());
model.getPermits().getPermits().add(new Permit());
model.getPermits().getPermits().get(0).setId("" + ActionGroup.CREATE_VM.getId());
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Role);
verifyModel((Role) response.getEntity(), 0);
}
use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class BackendRolesResourceTest method testAddIncompleteParametersNoPermits.
@Test
public void testAddIncompleteParametersNoPermits() throws Exception {
Role model = new Role();
model.setName(NAMES[0]);
setUriInfo(setUpBasicUriExpectations());
try {
collection.add(model);
fail("expected WebApplicationException on incomplete parameters");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Role", "add", "permits.id");
}
}
use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testMissingListSubFieldAlternatives.
@Test
public void testMissingListSubFieldAlternatives() throws Exception {
User user = new User();
user.setRoles(new Roles());
user.getRoles().getRoles().add(new Role());
user.getRoles().getRoles().get(0).setId("0");
user.getRoles().getRoles().add(new Role());
user.getRoles().getRoles().get(1).setDescription("0");
try {
CompletenessAssertor.validateParameters(user, "roles.id|name");
fail("expected WebApplicationException on incomplete model");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "User", "roles.id|name");
}
}
use of org.ovirt.engine.api.model.Role in project ovirt-engine by oVirt.
the class BackendPermitsResource method addParents.
@Override
public Permit addParents(Permit permit) {
permit.setRole(new Role());
permit.getRole().setId(roleId.toString());
return permit;
}
use of org.ovirt.engine.api.model.Role 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");
}
}
Aggregations