Search in sources :

Example 21 with User

use of org.candlepin.model.User in project candlepin by candlepin.

the class KatelloUserServiceAdapterTest method updateUser.

@Test(expected = UnsupportedOperationException.class)
public void updateUser() throws Exception {
    User user = mock(User.class);
    kusa.updateUser(user);
}
Also used : User(org.candlepin.model.User) Test(org.junit.Test)

Example 22 with User

use of org.candlepin.model.User in project candlepin by candlepin.

the class ConsumerResourceIntegrationTest method setUp.

@Before
public void setUp() {
    standardSystemType = consumerTypeCurator.create(new ConsumerType("standard-system"));
    standardSystemTypeDTO = modelTranslator.translate(standardSystemType, ConsumerTypeDTO.class);
    personType = consumerTypeCurator.create(new ConsumerType(ConsumerTypeEnum.PERSON));
    personTypeDTO = modelTranslator.translate(personType, ConsumerTypeDTO.class);
    owner = ownerCurator.create(new Owner("test-owner"));
    ownerDTO = modelTranslator.translate(owner, OwnerDTO.class);
    owner.setDefaultServiceLevel(DEFAULT_SERVICE_LEVEL);
    ownerCurator.create(owner);
    someuser = userCurator.create(new User(USER_NAME, "dontcare"));
    ownerAdminRole = createAdminRole(owner);
    ownerAdminRole.addUser(someuser);
    roleCurator.create(ownerAdminRole);
    List<Permission> perms = permFactory.createPermissions(someuser, ownerAdminRole.getPermissions());
    principal = new UserPrincipal(USER_NAME, perms, false);
    setupPrincipal(principal);
    consumer = TestUtil.createConsumer(standardSystemType, owner);
    consumerCurator.create(consumer);
    product = TestUtil.createProduct();
    product.setAttribute(Product.Attributes.SUPPORT_LEVEL, DEFAULT_SERVICE_LEVEL);
    productCurator.create(product);
    pool = createPool(owner, product, 10L, TestDateUtil.date(2010, 1, 1), TestDateUtil.date(2020, 12, 31));
}
Also used : Owner(org.candlepin.model.Owner) User(org.candlepin.model.User) OwnerDTO(org.candlepin.dto.api.v1.OwnerDTO) OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) Permission(org.candlepin.auth.permissions.Permission) ConsumerType(org.candlepin.model.ConsumerType) ConsumerTypeDTO(org.candlepin.dto.api.v1.ConsumerTypeDTO) UserPrincipal(org.candlepin.auth.UserPrincipal) Before(org.junit.Before)

Example 23 with User

use of org.candlepin.model.User in project candlepin by candlepin.

the class ConsumerResourceIntegrationTest method userwithEmail.

@Test
public void userwithEmail() {
    String username = "(foo)@{baz}.[com]&?";
    User u = userCurator.create(new User(username, "dontcare"));
    ownerAdminRole.addUser(u);
    roleCurator.merge(ownerAdminRole);
    Principal emailuser = TestUtil.createPrincipal(username, owner, Access.ALL);
    setupPrincipal(emailuser);
    ConsumerDTO personal = createConsumerDTO(personTypeDTO, ownerDTO);
    personal.setName(((UserPrincipal) emailuser).getUsername());
    personal = consumerResource.create(personal, emailuser, username, null, null, true);
    // Not sure if this should be hard-coded to default
    assertEquals(username, personal.getName());
}
Also used : User(org.candlepin.model.User) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) TestUtil.createConsumerDTO(org.candlepin.test.TestUtil.createConsumerDTO) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) Test(org.junit.Test)

Example 24 with User

use of org.candlepin.model.User in project candlepin by candlepin.

the class PersonConsumerResourceCreationTest method initConsumerType.

public ConsumerType initConsumerType() {
    ConsumerType ctype = new ConsumerType(ConsumerType.ConsumerTypeEnum.PERSON);
    this.mockConsumerType(ctype);
    // create an owner, a ownerperm, and roles for the user we prodive
    // as coming from userService
    owner = new Owner("test_owner");
    PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner, Access.ALL);
    User user = new User("anyuser", "");
    role = new Role();
    role.addPermission(p);
    role.addUser(user);
    when(userService.findByLogin("anyuser")).thenReturn(user);
    return ctype;
}
Also used : Role(org.candlepin.model.Role) Owner(org.candlepin.model.Owner) User(org.candlepin.model.User) PermissionBlueprint(org.candlepin.model.PermissionBlueprint) ConsumerType(org.candlepin.model.ConsumerType)

Example 25 with User

use of org.candlepin.model.User in project candlepin by candlepin.

the class RoleResource method addUser.

@ApiOperation(notes = "Adds a User to a Role", value = "addUser")
@ApiResponses({ @ApiResponse(code = 404, message = "") })
@POST
@Path("/{role_id}/users/{username}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.WILDCARD)
public Role addUser(@PathParam("role_id") String roleId, @PathParam("username") String username) {
    Role role = lookupRole(roleId);
    User user = lookupUser(username);
    userService.addUserToRole(role, user);
    return role;
}
Also used : Role(org.candlepin.model.Role) User(org.candlepin.model.User) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

User (org.candlepin.model.User)49 Test (org.junit.Test)33 Role (org.candlepin.model.Role)14 Owner (org.candlepin.model.Owner)13 HashSet (java.util.HashSet)11 UserPrincipal (org.candlepin.auth.UserPrincipal)10 Principal (org.candlepin.auth.Principal)7 OwnerPermission (org.candlepin.auth.permissions.OwnerPermission)6 PermissionBlueprint (org.candlepin.model.PermissionBlueprint)6 Consumer (org.candlepin.model.Consumer)5 Before (org.junit.Before)5 ApiOperation (io.swagger.annotations.ApiOperation)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 LinkedList (java.util.LinkedList)3 Permission (org.candlepin.auth.permissions.Permission)3 ConsumerType (org.candlepin.model.ConsumerType)3 Ignore (org.junit.Ignore)3 ApiResponses (io.swagger.annotations.ApiResponses)2 Method (java.lang.reflect.Method)2