Package org.apache.syncope.common.to

Examples of org.apache.syncope.common.to.UserTO


        super.resetRestTemplate();
    }

    @Test
    public void testUserSearch() throws InvalidSearchConditionException {
        UserTO userTO = UserTestITCase.getUniqueSampleTO("testusersearch@test.org");

        MembershipTO membershipTO = new MembershipTO();
        membershipTO.setRoleId(7L);
        AttributeTO testAttributeTO = new AttributeTO();
        testAttributeTO.setSchema("testAttribute");
        testAttributeTO.addValue("a value");
        membershipTO.addAttribute(testAttributeTO);
        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);
View Full Code Here


    @Test
    public void checkFailedLogins() {
        // Workaround for CXF issue.. remove after upgrade to 2.7.3
        CXFAuthenticator.addAuthenticator();
        Authenticator.setDefault(new CXFPatchedAuthenticator());
        UserTO userTO = UserTestITCase.getUniqueSampleTO("checkFailedLogin@syncope.apache.org");

        MembershipTO membershipTO = new MembershipTO();
        membershipTO.setRoleId(7L);
        AttributeTO testAttributeTO = new AttributeTO();
        testAttributeTO.setSchema("testAttribute");
        testAttributeTO.addValue("a value");
        membershipTO.addAttribute(testAttributeTO);
        userTO.addMembership(membershipTO);

        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

        assertEquals(0, getFailedLogins(userService4, userId));
    }

    @Test
    public void checkUserSuspension() {
        UserTO userTO = UserTestITCase.getUniqueSampleTO("checkSuspension@syncope.apache.org");

        MembershipTO membershipTO = new MembershipTO();
        membershipTO.setRoleId(7L);
        AttributeTO testAttributeTO = new AttributeTO();
        testAttributeTO.setSchema("testAttribute");
        testAttributeTO.addValue("a value");
        membershipTO.addAttribute(testAttributeTO);
        userTO.addMembership(membershipTO);

        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);

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

        // last authentication before suspension
        // TODO remove after CXF migration is complete
        userService3 = setupCredentials(userService, UserService.class, userTO.getUsername(), "wrongpwd1");
        assertReadFails(userService3, userId);

        // reset admin credentials for restTemplate
        super.resetRestTemplate();

        userTO = userService.read(userTO.getId());

        assertNotNull(userTO);
        assertNotNull(userTO.getFailedLogins());
        assertEquals(Integer.valueOf(3), userTO.getFailedLogins());
        assertEquals("suspended", userTO.getStatus());

        // Access with correct credentials should fail as user is suspended
        // TODO remove after CXF migration is complete
        userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(), "password123");
        assertReadFails(userService2, userId);

        // reset admin credentials for restTemplate
        super.resetRestTemplate();
        userTO = userService.reactivate(userTO.getId());
        assertNotNull(userTO);
        assertEquals("active", userTO.getStatus());

        // TODO remove after CXF migration is complete
        userService2 = setupCredentials(userService, UserService.class, userTO.getUsername(), "password123");
        assertEquals(0, getFailedLogins(userService2, userId));
    }
View Full Code Here

        response = roleService.create(childRole);
        childRole = getObject(response, RoleTO.class, roleService);
        assertNotNull(childRole);

        // User with child role, created by admin
        UserTO role1Admin = UserTestITCase.getUniqueSampleTO("syncope48admin@apache.org");
        role1Admin.setPassword("password");
        MembershipTO membershipTO = new MembershipTO();
        membershipTO.setRoleId(childRole.getId());
        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

        role1User = response.readEntity(UserTO.class);
        assertNotNull(role1User);
    }

    private int getFailedLogins(UserService testUserService, long userId) {
        UserTO readUserTO = testUserService.read(userId);
        assertNotNull(readUserTO);
        assertNotNull(readUserTO.getFailedLogins());
        return readUserTO.getFailedLogins();
    }
View Full Code Here

    @Test
    public void issueSYNCOPE267() {
        // ----------------------------------
        // create user and check virtual attribute value propagation
        // ----------------------------------
        UserTO userTO = getUniqueSampleTO("syncope267@apache.org");
        userTO.getResources().clear();
        userTO.addResource("resource-db-virattr");

        userTO = createUser(userTO);
        assertNotNull(userTO);
        assertFalse(userTO.getPropagationStatusTOs().isEmpty());
        assertEquals("resource-db-virattr", userTO.getPropagationStatusTOs().get(0).getResource());
        assertEquals(PropagationTaskExecStatus.SUBMITTED, userTO.getPropagationStatusTOs().get(0).getStatus());

        ConnObjectTO connObjectTO = readConnectorObject("resource-db-virattr", userTO.getId());
        assertNotNull(connObjectTO);
        assertEquals("virtualvalue", connObjectTO.getAttributeMap().get("USERNAME").getValues().get(0));
        // ----------------------------------

        userTO = userService.read(userTO.getId());

        assertNotNull(userTO);
        assertEquals(1, userTO.getVirtualAttributes().size());
        assertEquals("virtualvalue", userTO.getVirtualAttributes().get(0).getValues().get(0));
    }
View Full Code Here

        assertEquals("virtualvalue", userTO.getVirtualAttributes().get(0).getValues().get(0));
    }

    @Test
    public void issueSYNCOPE266() {
        UserTO userTO = getUniqueSampleTO("syncope266@apache.org");
        userTO.getResources().clear();

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

        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());

        // this resource has not a mapping for Password
        userMod.addResourceToBeAdded("ws-target-resource-update");

        userTO = userService.update(userTO.getId(), userMod);
        assertNotNull(userTO);
    }
View Full Code Here

        assertNotNull(userTO);
    }

    @Test(expected = SyncopeClientCompositeErrorException.class)
    public void issueSYNCOPE279() {
        UserTO userTO = getUniqueSampleTO("syncope279@apache.org");
        userTO.getResources().clear();
        userTO.addResource("ws-target-resource-timeout");
        createUser(userTO);
    }
View Full Code Here

    }

    @Test
    public void issueSYNCOPE122() {
        // 1. create user on testdb and testdb2
        UserTO userTO = getUniqueSampleTO("syncope123@apache.org");
        userTO.getResources().clear();
        userTO.addResource(RESOURCE_NAME_TESTDB);
        userTO.addResource("resource-testdb2");
        try {
            userTO = createUser(userTO);
        } catch (SyncopeClientCompositeErrorException scce) {
            // TODO Dirty workaround for AUTO generation Id strategy problem in AbstractVirAttr.
            // Must be removed after fix of SYNCOPE-298
            SyncopeClientException sce = scce.getException(SyncopeClientExceptionType.DataIntegrityViolation);
            assertNotNull(sce);
            return;
        }
        assertNotNull(userTO);
        assertTrue(userTO.getResources().contains(RESOURCE_NAME_TESTDB));
        assertTrue(userTO.getResources().contains("resource-testdb2"));

        final String pwdOnSyncope = userTO.getPassword();

        ConnObjectTO userOnDb =
                resourceService.getConnectorObject(RESOURCE_NAME_TESTDB, AttributableType.USER, userTO.getId());
        final AttributeTO pwdOnTestDbAttr = userOnDb.getAttributeMap().get(OperationalAttributes.PASSWORD_NAME);
        assertNotNull(pwdOnTestDbAttr);
        assertNotNull(pwdOnTestDbAttr.getValues());
        assertFalse(pwdOnTestDbAttr.getValues().isEmpty());
        final String pwdOnTestDb = pwdOnTestDbAttr.getValues().iterator().next();

        ConnObjectTO userOnDb2 =
                resourceService.getConnectorObject("resource-testdb2", AttributableType.USER, userTO.getId());
        final AttributeTO pwdOnTestDb2Attr = userOnDb2.getAttributeMap().get(OperationalAttributes.PASSWORD_NAME);
        assertNotNull(pwdOnTestDb2Attr);
        assertNotNull(pwdOnTestDb2Attr.getValues());
        assertFalse(pwdOnTestDb2Attr.getValues().isEmpty());
        final String pwdOnTestDb2 = pwdOnTestDb2Attr.getValues().iterator().next();

        // 2. request to change password only on testdb (no Syncope, no testdb2)
        UserMod userMod = new UserMod();
        userMod.setId(userTO.getId());
        userMod.setPassword(getUUIDString());
        PropagationRequestTO pwdPropRequest = new PropagationRequestTO();
        pwdPropRequest.addResource(RESOURCE_NAME_TESTDB);
        userMod.setPwdPropRequest(pwdPropRequest);

        userTO = userService.update(userMod.getId(), userMod);

        // 3a. Chech that only a single propagation took place
        assertNotNull(userTO.getPropagationStatusTOs());
        assertEquals(1, userTO.getPropagationStatusTOs().size());
        assertEquals(RESOURCE_NAME_TESTDB, userTO.getPropagationStatusTOs().iterator().next().getResource());

        // 3b. verify that password hasn't changed on Syncope
        assertEquals(pwdOnSyncope, userTO.getPassword());

        // 3c. verify that password *has* changed on testdb
        userOnDb = resourceService.getConnectorObject(RESOURCE_NAME_TESTDB, AttributableType.USER, userTO.getId());
        final AttributeTO pwdOnTestDbAttrAfter = userOnDb.getAttributeMap().get(OperationalAttributes.PASSWORD_NAME);
        assertNotNull(pwdOnTestDbAttrAfter);
        assertNotNull(pwdOnTestDbAttrAfter.getValues());
        assertFalse(pwdOnTestDbAttrAfter.getValues().isEmpty());
        assertNotEquals(pwdOnTestDb, pwdOnTestDbAttrAfter.getValues().iterator().next());

        // 3d. verify that password hasn't changed on testdb2
        userOnDb2 = resourceService.getConnectorObject("resource-testdb2", AttributableType.USER, userTO.getId());
        final AttributeTO pwdOnTestDb2AttrAfter = userOnDb2.getAttributeMap().get(OperationalAttributes.PASSWORD_NAME);
        assertNotNull(pwdOnTestDb2AttrAfter);
        assertNotNull(pwdOnTestDb2AttrAfter.getValues());
        assertFalse(pwdOnTestDb2AttrAfter.getValues().isEmpty());
        assertEquals(pwdOnTestDb2, pwdOnTestDb2AttrAfter.getValues().iterator().next());
View Full Code Here

        pwdCipherAlgo.setValue("AES");
        configurationService.update(pwdCipherAlgo.getKey(), pwdCipherAlgo);

        try {
            // 3. create user with no resources
            UserTO userTO = getUniqueSampleTO("syncope136_AES@apache.org");
            userTO.getResources().clear();

            userTO = userService.create(userTO).readEntity(UserTO.class);
            assertNotNull(userTO);

            // 4. update user, assign a propagation primary resource but don't provide any password
            UserMod userMod = new UserMod();
            userMod.setId(userTO.getId());
            userMod.addResourceToBeAdded("ws-target-resource-1");

            userTO = userService.update(userMod.getId(), userMod);
            assertNotNull(userTO);

            // 5. verify that propagation was successful
            List<PropagationStatusTO> props = userTO.getPropagationStatusTOs();
            assertNotNull(props);
            assertEquals(1, props.size());
            PropagationStatusTO prop = props.iterator().next();
            assertNotNull(prop);
            assertEquals("ws-target-resource-1", prop.getResource());
View Full Code Here

TOP

Related Classes of org.apache.syncope.common.to.UserTO

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.