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);
}
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));
}
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());
}
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;
}
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;
}
Aggregations