Search in sources :

Example 6 with ConfigTO

use of org.syncany.config.to.ConfigTO in project syncany by syncany.

the class ConfigHelperTest method testConfigHelperLoadRepoTO.

@Test
public void testConfigHelperLoadRepoTO() throws Exception {
    // Setup
    Config testConfig = TestConfigUtil.createTestLocalConfig();
    // Run
    ConfigTO loadedConfigTO = ConfigHelper.loadConfigTO(testConfig.getLocalDir());
    RepoTO repoConfigTO = ConfigHelper.loadRepoTO(testConfig.getLocalDir(), loadedConfigTO);
    // Test
    assertNotNull(repoConfigTO);
    assertNotNull(repoConfigTO.getChunkerTO());
    assertNotNull(repoConfigTO.getMultiChunker());
    assertNotNull(repoConfigTO.getRepoId());
    if (TestConfigUtil.getCrypto()) {
        assertNotNull(repoConfigTO.getTransformers());
        assertEquals(2, repoConfigTO.getTransformers().size());
        assertEquals("gzip", repoConfigTO.getTransformers().get(0).getType());
        assertEquals("cipher", repoConfigTO.getTransformers().get(1).getType());
    } else {
        assertNull(repoConfigTO.getTransformers());
    }
    assertEquals("fixed", repoConfigTO.getChunkerTO().getType());
    assertEquals(1, repoConfigTO.getChunkerTO().getSettings().size());
    assertEquals("zip", repoConfigTO.getMultiChunker().getType());
    assertEquals(1, repoConfigTO.getMultiChunker().getSettings().size());
    assertEquals("010203", StringUtil.toHex(repoConfigTO.getRepoId()));
    // Tear down
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
Also used : Config(org.syncany.config.Config) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) Test(org.junit.Test)

Example 7 with ConfigTO

use of org.syncany.config.to.ConfigTO in project syncany by syncany.

the class ConfigHelperTest method testConfigHelperLoadConfigTO.

@Test
public void testConfigHelperLoadConfigTO() throws Exception {
    // Setup
    Config testConfig = TestConfigUtil.createTestLocalConfig();
    // Run
    ConfigTO loadedConfigTO = ConfigHelper.loadConfigTO(testConfig.getLocalDir());
    // Test
    assertNotNull(loadedConfigTO);
    assertEquals(testConfig.getDisplayName(), loadedConfigTO.getDisplayName());
    assertEquals(testConfig.getMachineName(), loadedConfigTO.getMachineName());
    assertEquals(testConfig.getMasterKey(), loadedConfigTO.getMasterKey());
    // Tear down
    TestConfigUtil.deleteTestLocalConfigAndData(testConfig);
}
Also used : Config(org.syncany.config.Config) ConfigTO(org.syncany.config.to.ConfigTO) Test(org.junit.Test)

Example 8 with ConfigTO

use of org.syncany.config.to.ConfigTO in project syncany by syncany.

the class ConfigTest method testConfigInitConfigTONull.

@Test(expected = ConfigException.class)
public void testConfigInitConfigTONull() throws Exception {
    File localDir = new File("/some/folder");
    ConfigTO configTO = null;
    RepoTO repoTO = new RepoTO();
    new Config(localDir, configTO, repoTO);
}
Also used : Config(org.syncany.config.Config) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Example 9 with ConfigTO

use of org.syncany.config.to.ConfigTO in project syncany by syncany.

the class ConfigTest method testConfigCipherTransformersInvalidType.

@Test
public void testConfigCipherTransformersInvalidType() throws Exception {
    // Setup
    File localDir = new File("/some/folder");
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    // <<< valid
    configTO.setMachineName("somevalidmachinename");
    // <<< valid
    repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO());
    // <<< valid
    repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
    // <<< valid
    repoTO.setRepoId(new byte[] { 0x01, 0x02 });
    // Set invalid transformer
    TransformerTO invalidTransformerTO = new TransformerTO();
    invalidTransformerTO.setType("invalid-typeXXX");
    invalidTransformerTO.setSettings(new HashMap<String, String>());
    List<TransformerTO> transformers = new ArrayList<TransformerTO>();
    transformers.add(invalidTransformerTO);
    // <<< INVALID !
    repoTO.setTransformers(transformers);
    // Run!
    try {
        new Config(localDir, configTO, repoTO);
        fail("Transformer should NOT have been found.");
    } catch (ConfigException e) {
        TestAssertUtil.assertErrorStackTraceContains("invalid-typeXXX", e);
    }
}
Also used : TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) Config(org.syncany.config.Config) ArrayList(java.util.ArrayList) ConfigException(org.syncany.config.ConfigException) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Example 10 with ConfigTO

use of org.syncany.config.to.ConfigTO in project syncany by syncany.

the class ConfigTest method testConfigCipherTransformersCipherNotFound.

@Test
@SuppressWarnings("serial")
public void testConfigCipherTransformersCipherNotFound() throws Exception {
    // Setup
    File localDir = new File("/some/folder");
    ConfigTO configTO = new ConfigTO();
    RepoTO repoTO = new RepoTO();
    // <<< valid
    configTO.setMachineName("somevalidmachinename");
    // <<< valid
    repoTO.setChunkerTO(TestConfigUtil.createFixedChunkerTO());
    // <<< valid
    repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
    // <<< valid
    repoTO.setRepoId(new byte[] { 0x01, 0x02 });
    // <<< valid
    configTO.setMasterKey(createDummyMasterKey());
    // Set invalid transformer
    TransformerTO invalidTransformerTO = new TransformerTO();
    invalidTransformerTO.setType("cipher");
    invalidTransformerTO.setSettings(new HashMap<String, String>() {

        {
            // <<<< INVALID !
            put("cipherspecs", "1,INVALIDXXXX");
        }
    });
    List<TransformerTO> transformers = new ArrayList<TransformerTO>();
    transformers.add(invalidTransformerTO);
    repoTO.setTransformers(transformers);
    // Run!
    try {
        new Config(localDir, configTO, repoTO);
        fail("Transformer should NOT have been able to initialize.");
    } catch (ConfigException e) {
        TestAssertUtil.assertErrorStackTraceContains("INVALIDXXXX", e);
    }
}
Also used : TransformerTO(org.syncany.config.to.RepoTO.TransformerTO) Config(org.syncany.config.Config) ArrayList(java.util.ArrayList) ConfigException(org.syncany.config.ConfigException) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File) Test(org.junit.Test)

Aggregations

ConfigTO (org.syncany.config.to.ConfigTO)27 File (java.io.File)21 Test (org.junit.Test)18 RepoTO (org.syncany.config.to.RepoTO)17 Config (org.syncany.config.Config)15 InitOperationOptions (org.syncany.operations.init.InitOperationOptions)7 ConfigException (org.syncany.config.ConfigException)6 LocalTransferSettings (org.syncany.plugins.local.LocalTransferSettings)6 Random (java.util.Random)4 Persister (org.simpleframework.xml.core.Persister)4 ConnectOperationOptions (org.syncany.operations.init.ConnectOperationOptions)4 ArrayList (java.util.ArrayList)3 Serializer (org.simpleframework.xml.Serializer)3 TransformerTO (org.syncany.config.to.RepoTO.TransformerTO)3 SaltedSecretKey (org.syncany.crypto.SaltedSecretKey)3 ConnectOperation (org.syncany.operations.init.ConnectOperation)3 ConnectOperationResult (org.syncany.operations.init.ConnectOperationResult)3 InitOperation (org.syncany.operations.init.InitOperation)3 InitOperationResult (org.syncany.operations.init.InitOperationResult)3 TransferPlugin (org.syncany.plugins.transfer.TransferPlugin)3