Search in sources :

Example 26 with User

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

the class CompletenessAssertorTest method testCompleteListSubField.

@Test
public void testCompleteListSubField() 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).setId("0");
    CompletenessAssertor.validateParameters(user, "roles.id");
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Example 27 with User

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

the class CompletenessAssertorTest method testMissingListSubField.

@Test
public void testMissingListSubField() 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).setName("0");
    try {
        CompletenessAssertor.validateParameters(user, "roles.id");
        fail("expected WebApplicationException on incomplete model");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "User", "roles.id");
    }
}
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 28 with User

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

the class BackendVmSessionsResource method setSessionUser.

/**
 * The console user, if exists, is a real ovirt-user. Use its name to get ID and href information, and set them
 * inside the user object, inside the session. If user is not found in database, those information won't be set.
 */
private void setSessionUser(Session session) {
    // Get the user entity and don't fail if user is not found in database:
    DbUser entity = getEntity(DbUser.class, QueryType.GetDbUserByUserNameAndDomain, new GetDbUserByUserNameAndDomainQueryParameters(session.getUser().getUserName(), session.getUser().getDomain().getName()), "", false, false);
    // Map the database user to model user:
    if (entity != null) {
        User user = BackendApiResource.getInstance().getUsersResource().getUserResource(entity.getId().toString()).get();
        /**
         * TODO: It's enough to set user ID and href, we don't have to set also domain, please consider this
         * when moving to API version 5.
         */
        if (user != null) {
            session.getUser().setId(user.getId());
            session.getUser().setHref(user.getHref());
            session.getUser().getDomain().setId(user.getDomain().getId());
            session.getUser().getDomain().setHref(user.getDomain().getHref());
        }
    }
}
Also used : DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) User(org.ovirt.engine.api.model.User) GetDbUserByUserNameAndDomainQueryParameters(org.ovirt.engine.core.common.queries.GetDbUserByUserNameAndDomainQueryParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 29 with User

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

the class BackendUsersResource method mapDbUserCollection.

protected Users mapDbUserCollection(List<DbUser> entities) {
    Users collection = new Users();
    for (DbUser entity : entities) {
        User user = map(entity);
        user = populate(user, entity);
        user = addLinks(user, BaseResource.class);
        collection.getUsers().add(user);
    }
    return collection;
}
Also used : User(org.ovirt.engine.api.model.User) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) BaseResource(org.ovirt.engine.api.model.BaseResource) Users(org.ovirt.engine.api.model.Users) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 30 with User

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

the class BackendEntityAssignedPermissionsResourceTest method getModel.

@Override
protected Permission getModel() {
    Permission model = new Permission();
    model.setUser(new User());
    model.getUser().setId(GUIDS[1].toString());
    model.setRole(new Role());
    model.getRole().setId(GUIDS[3].toString());
    return model;
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) Permission(org.ovirt.engine.api.model.Permission)

Aggregations

User (org.ovirt.engine.api.model.User)31 Test (org.junit.Test)12 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)9 Role (org.ovirt.engine.api.model.Role)7 Permission (org.ovirt.engine.api.model.Permission)6 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)6 Roles (org.ovirt.engine.api.model.Roles)5 Domain (org.ovirt.engine.api.model.Domain)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 Group (org.ovirt.engine.api.model.Group)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Groups (org.ovirt.engine.api.model.Groups)2 Session (org.ovirt.engine.api.model.Session)2 Ssh (org.ovirt.engine.api.model.Ssh)2 Users (org.ovirt.engine.api.model.Users)2 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)2 ArrayList (java.util.ArrayList)1 AuthorizedKey (org.ovirt.engine.api.model.AuthorizedKey)1 BaseResource (org.ovirt.engine.api.model.BaseResource)1