use of org.candlepin.model.User in project candlepin by candlepin.
the class DefaultUserServiceAdapterTest method testFindAllUsers.
@Test
public void testFindAllUsers() {
User user = new User("test_user", "mypassword");
this.service.createUser(user);
List<User> users = this.service.listUsers();
assertTrue("The size of the list should be 1", users.size() == 1);
assertEquals("test_user", users.get(0).getUsername());
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class DefaultUserServiceAdapterTest method testUpdating.
@Test
public void testUpdating() {
User user = TestUtil.createUser(null, null, true);
user = this.userCurator.create(user);
user.setUsername("JarJar");
user.setHashedPassword("Binks");
user.setSuperAdmin(false);
User updated = service.updateUser(user);
assertEquals("JarJar", updated.getUsername());
assertEquals("Binks", updated.getHashedPassword());
assertFalse(updated.isSuperAdmin());
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class DefaultUserServiceAdapterTest method findOwner.
@Test
@Ignore("Find a way to do this with permissions")
public void findOwner() {
User user = new User("test_name", "password");
this.service.createUser(user);
Role adminRole = createAdminRole(owner);
adminRole.addUser(user);
roleCurator.create(adminRole);
// List<Owner> owners = this.service.getOwners("test_name");
// Assert.assertEquals(1, owners.size());
// Assert.assertEquals(owner, owners.get(0));
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class BasicAuthViaUserServiceTest method correctPrincipalNoPassword.
@Test
public void correctPrincipalNoPassword() throws Exception {
Owner owner = new Owner("user", "user");
setUserNoPassword("user");
when(userService.validateUser("user", null)).thenReturn(true);
Set<OwnerPermission> permissions = new HashSet<>();
permissions.add(new OwnerPermission(owner, Access.ALL));
when(userService.findByLogin("user")).thenReturn(new User());
UserPrincipal expected = new UserPrincipal("user", new ArrayList<>(permissions), false);
assertEquals(expected, this.auth.getPrincipal(request));
}
use of org.candlepin.model.User in project candlepin by candlepin.
the class BasicAuthViaUserServiceTest method correctPrincipal.
/**
* Valid credentials are given - checks if the correct principal is created.
*
* @throws Exception
*/
@Test
public void correctPrincipal() throws Exception {
Owner owner = new Owner("user", "user");
setUserAndPassword("user", "redhat");
when(userService.validateUser("user", "redhat")).thenReturn(true);
// TODO: test will fail, need to mock the permissions setup
Set<OwnerPermission> permissions = new HashSet<>();
permissions.add(new OwnerPermission(owner, Access.ALL));
when(userService.findByLogin("user")).thenReturn(new User());
UserPrincipal expected = new UserPrincipal("user", new ArrayList<>(permissions), false);
assertEquals(expected, this.auth.getPrincipal(request));
}
Aggregations