Search in sources :

Example 1 with Role

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);
}
Also used : Role(org.ovirt.engine.api.model.Role) Response(javax.ws.rs.core.Response) Permit(org.ovirt.engine.api.model.Permit) Permits(org.ovirt.engine.api.model.Permits) Test(org.junit.Test)

Example 2 with Role

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");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Example 3 with Role

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");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) WebApplicationException(javax.ws.rs.WebApplicationException) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Example 4 with Role

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;
}
Also used : Role(org.ovirt.engine.api.model.Role)

Example 5 with Role

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");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) WebApplicationException(javax.ws.rs.WebApplicationException) Permission(org.ovirt.engine.api.model.Permission) Test(org.junit.Test)

Aggregations

Role (org.ovirt.engine.api.model.Role)22 Test (org.junit.Test)12 WebApplicationException (javax.ws.rs.WebApplicationException)8 Permission (org.ovirt.engine.api.model.Permission)8 User (org.ovirt.engine.api.model.User)7 Permits (org.ovirt.engine.api.model.Permits)4 Roles (org.ovirt.engine.api.model.Roles)4 Response (javax.ws.rs.core.Response)3 DataCenter (org.ovirt.engine.api.model.DataCenter)3 Permit (org.ovirt.engine.api.model.Permit)3 Group (org.ovirt.engine.api.model.Group)2 V3Role (org.ovirt.engine.api.v3.types.V3Role)1