Package org.candlepin.model

Examples of org.candlepin.model.User


    @Test
    public void addUserToRole() {
        Role adminRole = createAdminRole(owner);
        roleCurator.create(adminRole);
        User user = new User("testuser", "password");
        service.createUser(user);
        service.addUserToRole(adminRole, user);
        adminRole = service.getRole(adminRole.getId());
        assertEquals(1, adminRole.getUsers().size());
    }
View Full Code Here


    @Test
    public void deleteUserRemovesUserFromRoles() {
        Role adminRole = createAdminRole(owner);
        roleCurator.create(adminRole);
        User user = new User("testuser", "password");
        service.createUser(user);
        service.addUserToRole(adminRole, user);
        service.deleteUser(user);

        adminRole = service.getRole(adminRole.getId());
View Full Code Here

        assertEquals(0, adminRole.getUsers().size());
    }

    @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());
    }
View Full Code Here

        consumerTypeCurator.create(consumerType);
    }

    @Test
    public void testListForOwnerPermissionFiltering() {
        User u = setupOnlyMyConsumersPrincipal();

        Consumer c1 = new Consumer("c1", u.getUsername(), owner, consumerType);
        consumerCurator.create(c1);
        Consumer c2 = new Consumer("c2", "anotheruser", owner, consumerType);
        consumerCurator.create(c2);

        List<Consumer> results = consumerCurator.listByOwner(owner);
View Full Code Here

        assertEquals(c1.getName(), results.get(0).getName());
    }

    @Test
    public void testListForOwnerEditMineViewAllPermissionFiltering() {
        User u = setupEditMyConsumersViewAllPrincipal();

        Consumer c1 = new Consumer("c1", u.getUsername(), owner, consumerType);
        consumerCurator.create(c1);
        Consumer c2 = new Consumer("c2", "anotheruser", owner, consumerType);
        consumerCurator.create(c2);

        List<Consumer> results = consumerCurator.listByOwner(owner);
View Full Code Here

        assertEquals(2, results.size());
    }

    @Test
    public void testFindByUuidPermissionFiltering() {
        User u = setupOnlyMyConsumersPrincipal();

        Consumer c1 = new Consumer("c1", u.getUsername(), owner, consumerType);
        consumerCurator.create(c1);
        Consumer c2 = new Consumer("c2", "anotheruser", owner, consumerType);
        consumerCurator.create(c2);

        assertEquals(c1, consumerCurator.findByUuid(c1.getUuid()));
View Full Code Here

        assertNull(consumerCurator.findByUuid(c2.getUuid()));
    }

    private User setupOnlyMyConsumersPrincipal() {
        Set<Permission> perms = new HashSet<Permission>();
        User u = new User("fakeuser", "dontcare");
        perms.add(new UsernameConsumersPermission(u, owner));
        Principal p = new UserPrincipal(u.getUsername(), perms, false);
        setupPrincipal(p);
        return u;
    }
View Full Code Here

        return u;
    }

    private User setupEditMyConsumersViewAllPrincipal() {
        Set<Permission> perms = new HashSet<Permission>();
        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;
    }
View Full Code Here

        ownerCurator.create(owner2);
        ownerCurator.create(owner3);

        // Setup a principal with access to org 1 and 2, but not 3.
        Set<Permission> perms = new HashSet<Permission>();
        User u = new User("fakeuser", "dontcare");
        perms.add(new UsernameConsumersPermission(u, owner1));
        perms.add(new OwnerPermission(owner1, Access.ALL));
        perms.add(new OwnerPermission(owner2, Access.READ_ONLY)); // just read for org 2
        principal = new UserPrincipal(u.getUsername(), perms, false);
        setupPrincipal(principal);
    }
View Full Code Here

            null, null, this.config, null, null, null, this.consumerBindUtil);

        this.system = initSystem();

        owner = new Owner("test_owner");
        user = new User(USER, "");
        PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner,
            Access.ALL);
        role = new Role();
        role.addPermission(p);
        role.addUser(user);
View Full Code Here

TOP

Related Classes of org.candlepin.model.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.