Package org.apache.syncope.common.services

Examples of org.apache.syncope.common.services.UserService


        // 6. switch back to admin
        super.resetRestTemplate();

        // 7. user password has not changed yet
        UserService userService1 = super.setupCredentials(userService, UserService.class, userTO.getUsername(),
                userMod.getPassword());
        try {
            userService1.readSelf();
            fail("Credentials are not updated yet, thus request should raise AccessControlException");
        } catch (AccessControlException e) {
            assertNotNull(e);
        }
        resetRestTemplate();

        // 8. actually update user
        userTO = userService.update(userMod.getId(), userMod);
        assertNotNull(userTO);

        // 9. user password has now changed
        UserService userService2 = super.setupCredentials(userService, UserService.class, userTO.getUsername(),
                userMod.getPassword());
        try {
            UserTO user = userService2.readSelf();
            assertNotNull(user);
        } catch (AccessControlException e) {
            fail("Credentials should be valid and not cause AccessControlException");
        }
    }
View Full Code Here


        return userTO;
    }

    @Test
    public void selfRead() {
        UserService userService2 = setupCredentials(userService, UserService.class, "rossini", ADMIN_PWD);

        try {
            userService2.read(1L);
            fail();
        } catch (HttpClientErrorException e) {
            assertEquals(HttpStatus.FORBIDDEN, e.getStatusCode());
        } catch (AccessControlException e) {
            // Will be thrown by cxf service
            assertNotNull(e);
        }

        UserTO userTO = userService2.readSelf();
        assertEquals("rossini", userTO.getUsername());
    }
View Full Code Here

        assertNotNull(taskTO);
        assertEquals(maxTaskExecutions, taskTO.getExecutions().size());

        // 3. verify password
        UserService userService1 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
                "password123");
        try {
            UserTO user = userService1.readSelf();
            assertNotNull(user);
        } catch (AccessControlException e) {
            fail("Credentials should be valid and not cause AccessControlException");
        }

        UserService userService2 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
                "passwordXX");
        try {
            userService2.readSelf();
            fail("Credentials are invalid, thus request should raise AccessControlException");
        } catch (AccessControlException e) {
            assertNotNull(e);
        }
        resetRestTemplate();
View Full Code Here

        return userTO;
    }

    @Test
    public void selfRead() {
        UserService userService2 = setupCredentials(userService, UserService.class, "rossini", ADMIN_PWD);

        try {
            userService2.read(1L);
            fail();
        } catch (HttpClientErrorException e) {
            assertEquals(HttpStatus.FORBIDDEN, e.getStatusCode());
        } catch (AccessControlException e) {
            // Will be thrown by cxf service
            assertNotNull(e);
        }

        UserTO userTO = userService2.readSelf();
        assertEquals("rossini", userTO.getUsername());
    }
View Full Code Here

        assertNotNull(taskTO);
        assertEquals(maxTaskExecutions, taskTO.getExecutions().size());

        // 3. verify password
        UserService userService1 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
                "password123");
        try {
            UserTO user = userService1.readSelf();
            assertNotNull(user);
        } catch (AccessControlException e) {
            fail("Credentials should be valid and not cause AccessControlException");
        }

        UserService userService2 = super.setupCredentials(userService, UserService.class, newUserTO.getUsername(),
                "passwordXX");
        try {
            userService2.readSelf();
            fail("Credentials are invalid, thus request should raise AccessControlException");
        } catch (AccessControlException e) {
            assertNotNull(e);
        }
        resetRestTemplate();
View Full Code Here

        userTO.addMembership(membershipTO);

        userTO = createUser(userTO);
        assertNotNull(userTO);

        UserService userService2 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "password123");

        UserTO readUserTO = userService2.read(1L);
        assertNotNull(readUserTO);

        UserService userService3 = setupCredentials(userService, UserService.class, "verdi", ADMIN_PWD);

        SyncopeClientException exception = null;
        try {
            userService3.read(1L);
            fail();
        } catch (SyncopeClientCompositeErrorException e) {
            exception = e.getException(SyncopeClientExceptionType.UnauthorizedRole);
        }
        assertNotNull(exception);
View Full Code Here

        userTO.addMembership(membershipTO);

        userTO = createUser(userTO);
        assertNotNull(userTO);

        UserService userService2 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "password123");

        AttributeCond isNullCond = new AttributeCond(AttributeCond.Type.ISNOTNULL);
        isNullCond.setSchema("loginDate");
        NodeCond searchCondition = NodeCond.getLeafCond(isNullCond);

        List<UserTO> matchedUsers = userService2.search(searchCondition);
        assertNotNull(matchedUsers);
        assertFalse(matchedUsers.isEmpty());
        Set<Long> userIds = new HashSet<Long>(matchedUsers.size());
        for (UserTO user : matchedUsers) {
            userIds.add(user.getId());
        }
        assertTrue(userIds.contains(1L));

        UserService userService3 = setupCredentials(userService, UserService.class, "verdi", "password");

        matchedUsers = userService3.search(searchCondition);

        assertNotNull(matchedUsers);

        userIds = new HashSet<Long>(matchedUsers.size());
View Full Code Here

        userTO = createUser(userTO);
        assertNotNull(userTO);
        long userId = userTO.getId();

        UserService userService2 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "password123");
        assertEquals(0, getFailedLogins(userService2, userId));

        // authentications failed ...
        UserService userService3 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "wrongpwd1");
        assertReadFails(userService3, userId);
        assertReadFails(userService3, userId);

        // reset admin credentials for restTemplate
        super.resetRestTemplate();
        assertEquals(2, getFailedLogins(userService, userId));

        UserService userService4 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "password123");
        assertEquals(0, getFailedLogins(userService4, userId));
    }
View Full Code Here

        userTO = createUser(userTO);
        long userId = userTO.getId();
        assertNotNull(userTO);

        UserService userService2 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "password123");
        assertEquals(0, getFailedLogins(userService2, userId));

        // authentications failed ...
        UserService userService3 = setupCredentials(userService, UserService.class,
                userTO.getUsername(), "wrongpwd1");
        assertReadFails(userService3, userId);
        assertReadFails(userService3, userId);
        assertReadFails(userService3, userId);
View Full Code Here

        role1Admin.addMembership(membershipTO);

        role1Admin = createUser(role1Admin);
        assertNotNull(role1Admin);

        UserService userService2 = setupCredentials(userService, UserService.class,
                role1Admin.getUsername(), "password");

        // User with role 1, created by user with child role created above
        UserTO role1User = UserTestITCase.getUniqueSampleTO("syncope48user@apache.org");
        membershipTO = new MembershipTO();
        membershipTO.setRoleId(1L);
        role1User.addMembership(membershipTO);

        response = userService2.create(role1User);
        assertNotNull(response);
        role1User = response.readEntity(UserTO.class);
        assertNotNull(role1User);
    }
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.services.UserService

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.