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

        // 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(RESOURCE_NAME_WS1);

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

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


    @PreAuthorize("hasRole('CONFIGURATION_DELETE')")
    @RequestMapping(method = RequestMethod.GET, value = "/delete/{key}")
    public ConfigurationTO delete(@PathVariable("key") final String key) {
        SyncopeConf conf = confDAO.find(key);
        ConfigurationTO confToDelete = binder.getConfigurationTO(conf);
        confDAO.delete(key);
        return confToDelete;
    }
View Full Code Here

    }

    @PreAuthorize("hasRole('CONFIGURATION_READ')")
    @RequestMapping(method = RequestMethod.GET, value = "/read/{key}")
    public ConfigurationTO read(final HttpServletResponse response, @PathVariable("key") final String key) {
        ConfigurationTO result;
        try {
            SyncopeConf conf = confDAO.find(key);
            result = binder.getConfigurationTO(conf);
        } catch (MissingConfKeyException e) {
            LOG.error("Could not find configuration key '" + key + "', returning null");

            result = new ConfigurationTO();
            result.setKey(key);
        }

        return result;
    }
View Full Code Here

    }

    @Test
    public void testLists() throws IOException {
        List<ConfigurationTO> confList = new ArrayList<ConfigurationTO>();
        ConfigurationTO configuration = new ConfigurationTO();
        configuration.setKey("key1");
        configuration.setValue("value1");
        confList.add(configuration);
        configuration = new ConfigurationTO();
        configuration.setKey("key2");
        configuration.setValue("value2");
        confList.add(configuration);

        ObjectMapper mapper = new ObjectMapper();

        StringWriter writer = new StringWriter();
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

        }
    }

    @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(RESOURCE_NAME_WS1);

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

        // 6. restore initial cipher algorithm
        pwdCipherAlgo.setValue(origpwdCipherAlgo);
        configurationService.update(pwdCipherAlgo.getKey(), pwdCipherAlgo);
    }
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.