use of org.candlepin.model.User in project candlepin by candlepin.
the class DefaultUserServiceAdapter method createRole.
@Override
public Role createRole(Role role) {
Set<User> actualUsers = new HashSet<>();
for (User user : role.getUsers()) {
User actualUser = findByLogin(user.getUsername());
actualUsers.add(actualUser);
}
role.setUsers(actualUsers);
for (PermissionBlueprint permission : role.getPermissions()) {
permission.setRole(role);
}
this.roleCurator.create(role);
return role;
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class AuthenticationFilterTest method securityHoleWithAuth.
@Test
public void securityHoleWithAuth() throws Exception {
Method method = FakeResource.class.getMethod("annotatedMethod", String.class);
mockResourceMethod(method);
mockReq.header("Authorization", "BASIC QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
when(usa.validateUser(eq("Aladdin"), eq("open sesame"))).thenReturn(true);
when(usa.findByLogin(eq("Aladdin"))).thenReturn(new User("Aladdin", "open sesame"));
interceptor.filter(getContext());
Principal p = ResteasyProviderFactory.getContextData(Principal.class);
assertTrue(p instanceof UserPrincipal);
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class AuthenticationFilterTest method noSecurityHole.
@Test
public void noSecurityHole() throws Exception {
mockReq.header("Authorization", "BASIC QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
when(usa.validateUser(eq("Aladdin"), eq("open sesame"))).thenReturn(true);
when(usa.findByLogin(eq("Aladdin"))).thenReturn(new User("Aladdin", "open sesame", true));
Method method = FakeResource.class.getMethod("someMethod", String.class);
mockResourceMethod(method);
interceptor.filter(getContext());
Principal p = ResteasyProviderFactory.getContextData(Principal.class);
assertTrue(p instanceof UserPrincipal);
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class PersonConsumerResourceCreationLiberalNameRules method initConsumerType.
@Override
public ConsumerType initConsumerType() {
ConsumerType systemtype = new ConsumerType(ConsumerType.ConsumerTypeEnum.PERSON);
// create an owner, an ownerperm, and roles for the user we provide
// 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 systemtype;
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class UserResourceTest method testDeleteUser.
@Test
public void testDeleteUser() {
User user = new User();
user.setUsername("henri");
user.setPassword("password");
userResource.createUser(user);
userResource.deleteUser("henri");
assertNull(userResource.getUserInfo("henri"));
}
Aggregations