Search in sources :

Example 36 with User

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

the class DefaultUserServiceAdapterTest method deletionValidationFail.

@Test
public void deletionValidationFail() {
    User user = new User("guy", "pass");
    user = this.service.createUser(user);
    this.service.deleteUser(user);
    Assert.assertFalse(this.service.validateUser("guy", "pass"));
}
Also used : User(org.candlepin.model.User) Test(org.junit.Test)

Example 37 with User

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

the class DefaultUserServiceAdapterTest method validationBadPassword.

@Test
public void validationBadPassword() {
    User user = new User("dude", "password");
    this.service.createUser(user);
    Assert.assertFalse(this.service.validateUser("dude", "invalid"));
}
Also used : User(org.candlepin.model.User) Test(org.junit.Test)

Example 38 with User

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

the class DefaultUserServiceAdapterTest method validationPass.

@Test
public void validationPass() {
    User user = new User("test_user", "mypassword");
    this.service.createUser(user);
    Assert.assertTrue(this.service.validateUser("test_user", "mypassword"));
}
Also used : User(org.candlepin.model.User) Test(org.junit.Test)

Example 39 with User

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

the class BasicAuthViaUserServiceTest method correctPrincipalColonPassword.

@Test
public void correctPrincipalColonPassword() throws Exception {
    Owner owner = new Owner("user", "user");
    setUserAndPassword("user", "1:2");
    when(userService.validateUser("user", "1:2")).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));
}
Also used : Owner(org.candlepin.model.Owner) OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) User(org.candlepin.model.User) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 40 with User

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

the class ConsumerCuratorPermissionsTest method setupEditMyConsumersViewAllPrincipal.

private User setupEditMyConsumersViewAllPrincipal() {
    Set<Permission> perms = new HashSet<>();
    User u = new User("fakeuser", "dontcare");
    perms.add(new UsernameConsumersPermission(u, owner));
    perms.add(new OwnerPermission(owner, Access.READ_ONLY));
    Principal p = new UserPrincipal(u.getUsername(), perms, false);
    setupPrincipal(p);
    return u;
}
Also used : User(org.candlepin.model.User) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) UserPrincipal(org.candlepin.auth.UserPrincipal) HashSet(java.util.HashSet)

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