Package org.apache.syncope.common.to

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


    }

    @Test
    public void isseSYNCOPE136AES() {
        // 1. read configured cipher algorithm in order to be able to restore it at the end of test
        ConfigurationTO pwdCipherAlgo = configurationService.read("password.cipher.algorithm");
        final String origpwdCipherAlgo = pwdCipherAlgo.getValue();

        // 2. set AES password cipher algorithm
        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());
            assertEquals(PropagationTaskExecStatus.SUCCESS, prop.getStatus());
        } catch (Exception e) {
            LOG.error("Unexpected exception", e);
        } finally {
            // 6. restore initial cipher algorithm
            pwdCipherAlgo.setValue(origpwdCipherAlgo);
            configurationService.update(pwdCipherAlgo.getKey(), pwdCipherAlgo);
        }
    }
View Full Code Here


        }
    }

    @Test()
    public void issueSYNCOPE51() {
        ConfigurationTO defaultConfigurationTO = configurationService.read("password.cipher.algorithm");

        ConfigurationTO configurationTO = new ConfigurationTO();
        configurationTO.setKey("password.cipher.algorithm");
        configurationTO.setValue("MD5");

        configurationService.update(configurationTO.getKey(), configurationTO);
        ConfigurationTO newConfTO = configurationService.read(configurationTO.getKey());

        assertEquals(configurationTO, newConfTO);

        UserTO userTO = getSampleTO("syncope51@syncope.apache.org");
        userTO.setPassword("password");

        try {
            createUser(userTO);
            fail("Create user should not succeed");
        } catch (SyncopeClientCompositeErrorException e) {
            assertTrue(e.getException(SyncopeClientExceptionType.NotFound).getElements().iterator().next()
                    .contains("MD5"));
        }

        configurationService.update(defaultConfigurationTO.getKey(), defaultConfigurationTO);
        ConfigurationTO oldConfTO = configurationService.read(defaultConfigurationTO.getKey());

        assertEquals(defaultConfigurationTO, oldConfTO);
    }
View Full Code Here

    }

    @Test
    public void isseSYNCOPE136AES() {
        // 1. read configured cipher algorithm in order to be able to restore it at the end of test
        ConfigurationTO pwdCipherAlgo = configurationService.read("password.cipher.algorithm");
        final String origpwdCipherAlgo = pwdCipherAlgo.getValue();

        // 2. set AES password cipher algorithm
        pwdCipherAlgo.setValue("AES");
        configurationService.update(pwdCipherAlgo.getKey(), pwdCipherAlgo);

        // 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());
        assertEquals(PropagationTaskExecStatus.SUBMITTED, prop.getStatus());

        // 6. restore initial cipher algorithm
        pwdCipherAlgo.setValue(origpwdCipherAlgo);
        configurationService.update(pwdCipherAlgo.getKey(), pwdCipherAlgo);
    }
View Full Code Here

            @Override
            public void populateItem(final Item<ICellPopulator<ConfigurationTO>> cellItem, final String componentId,
                    final IModel<ConfigurationTO> model) {

                final ConfigurationTO configurationTO = model.getObject();

                final ActionLinksPanel panel = new ActionLinksPanel(componentId, model, getPageReference());

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {

                        editConfigWin.setPageCreator(new ModalWindow.PageCreator() {

                            private static final long serialVersionUID = -7834632442532690940L;

                            @Override
                            public Page createPage() {
                                return new ConfigurationModalPage(Configuration.this.getPageReference(), editConfigWin,
                                        configurationTO, false);
                            }
                        });

                        editConfigWin.show(target);
                    }
                }, ActionLink.ActionType.EDIT, "Configuration");

                panel.add(new ActionLink() {

                    private static final long serialVersionUID = -3722207913631435501L;

                    @Override
                    public void onClick(final AjaxRequestTarget target) {
                        try {
                            confRestClient.deleteConfiguration(configurationTO.getKey());
                        } catch (SyncopeClientCompositeErrorException e) {
                            LOG.error("While deleting a conf key", e);
                            error(e.getMessage());
                            return;
                        }

                        info(getString(Constants.OPERATION_SUCCEEDED));
                        target.add(feedbackPanel);

                        target.add(confContainer);
                    }
                }, ActionLink.ActionType.DELETE, "Configuration");

                cellItem.add(panel);
            }
        });

        final AjaxFallbackDefaultDataTable<ConfigurationTO, String> confTable =
                new AjaxFallbackDefaultDataTable<ConfigurationTO, String>(
                "syncopeconf", confColumns, new SyncopeConfProvider(), confPaginatorRows);

        confContainer = new WebMarkupContainer("confContainer");
        confContainer.add(confTable);
        confContainer.setOutputMarkupId(true);

        add(confContainer);

        createConfigWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        createConfigWin.setInitialHeight(CONFIG_WIN_HEIGHT);
        createConfigWin.setInitialWidth(CONFIG_WIN_WIDTH);
        createConfigWin.setCookieName("create-configuration-modal");

        editConfigWin.setCssClassName(ModalWindow.CSS_CLASS_GRAY);
        editConfigWin.setInitialHeight(CONFIG_WIN_HEIGHT);
        editConfigWin.setInitialWidth(CONFIG_WIN_WIDTH);
        editConfigWin.setCookieName("edit-configuration-modal");

        setWindowClosedCallback(createConfigWin, confContainer);
        setWindowClosedCallback(editConfigWin, confContainer);

        AjaxLink createConfigurationLink = new AjaxLink("createConfigurationLink") {

            private static final long serialVersionUID = -7978723352517770644L;

            @Override
            public void onClick(final AjaxRequestTarget target) {

                createConfigWin.setPageCreator(new ModalWindow.PageCreator() {

                    private static final long serialVersionUID = -7834632442532690940L;

                    @Override
                    public Page createPage() {
                        return new ConfigurationModalPage(Configuration.this.getPageReference(), createConfigWin,
                                new ConfigurationTO(), true);
                    }
                });

                createConfigWin.show(target);
            }
View Full Code Here

@FixMethodOrder(MethodSorters.JVM)
public class ConfigurationTestITCase extends AbstractTest {

    @Test
    public void create() {
        ConfigurationTO configurationTO = new ConfigurationTO();
        configurationTO.setKey("testKey");
        configurationTO.setValue("testValue");

        Response response = configurationService.create(configurationTO);
        assertNotNull(response);
        assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
        ConfigurationTO newConfigurationTO = getObject(response, ConfigurationTO.class, configurationService);
        assertEquals(configurationTO, newConfigurationTO);
    }
View Full Code Here

            configurationService.delete("nonExistent");
        } catch (HttpStatusCodeException e) {
            assertEquals(HttpStatus.NOT_FOUND, e.getStatusCode());
        }

        ConfigurationTO tokenLengthTO = configurationService.read("token.length");

        configurationService.delete("token.length");
        try {
            configurationService.read("token.length");
        } catch (HttpStatusCodeException e) {
            assertEquals(e.getStatusCode(), HttpStatus.NOT_FOUND);
        }

        Response response = configurationService.create(tokenLengthTO);
        assertNotNull(response);
        assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
        ConfigurationTO newConfigurationTO = getObject(response, ConfigurationTO.class, configurationService);
        assertEquals(tokenLengthTO, newConfigurationTO);
    }
View Full Code Here

        }
    }

    @Test
    public void read() {
        ConfigurationTO configurationTO = configurationService.read("token.expireTime");

        assertNotNull(configurationTO);
    }
View Full Code Here

        assertNotNull(configurationTO);
    }

    @Test
    public void update() {
        ConfigurationTO configurationTO = configurationService.read("token.expireTime");
        int value = Integer.parseInt(configurationTO.getValue());
        value++;
        configurationTO.setValue(value + "");

        configurationService.update(configurationTO.getKey(), configurationTO);
        ConfigurationTO newConfigurationTO = configurationService.read(configurationTO.getKey());
        assertEquals(configurationTO, newConfigurationTO);

        newConfigurationTO = configurationService.read("token.expireTime");
        assertEquals(configurationTO, newConfigurationTO);
    }
View Full Code Here

        assertTrue(configExport.length() > 1000);
    }

    @Test
    public void issueSYNCOPE418() {
        ConfigurationTO configurationTO = new ConfigurationTO();
        configurationTO.setKey("http://schemas.examples.org/security/authorization/organizationUnit");

        try {
            configurationService.create(configurationTO);
            fail();
        } catch (SyncopeClientCompositeErrorException scce) {
View Full Code Here

        }
    }

    @Test()
    public void issueSYNCOPE51() {
        ConfigurationTO defaultConfigurationTO = configurationService.read("password.cipher.algorithm");

        ConfigurationTO configurationTO = new ConfigurationTO();
        configurationTO.setKey("password.cipher.algorithm");
        configurationTO.setValue("MD5");

        configurationService.update(configurationTO.getKey(), configurationTO);
        ConfigurationTO newConfTO = configurationService.read(configurationTO.getKey());

        assertEquals(configurationTO, newConfTO);

        UserTO userTO = getSampleTO("syncope51@syncope.apache.org");
        userTO.setPassword("password");

        try {
            createUser(userTO);
            fail("Create user should not succeed");
        } catch (SyncopeClientCompositeErrorException e) {
            assertTrue(e.getException(SyncopeClientExceptionType.NotFound).getElements().iterator().next()
                    .contains("MD5"));
        }

        configurationService.update(defaultConfigurationTO.getKey(), defaultConfigurationTO);
        ConfigurationTO oldConfTO = configurationService.read(defaultConfigurationTO.getKey());

        assertEquals(defaultConfigurationTO, oldConfTO);
    }
View Full Code Here

TOP

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

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.