use of org.syncany.config.to.RepoTO in project syncany by syncany.
the class TestConfigUtil method createTestInitOperationOptions.
public static InitOperationOptions createTestInitOperationOptions(String machineName) throws Exception {
File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("client-" + machineName, machineName));
File tempRepoDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("repo", machineName));
tempLocalDir.mkdirs();
tempRepoDir.mkdirs();
RepoTO repoTO = createRepoTO();
// Create config TO
ConfigTO configTO = new ConfigTO();
configTO.setMachineName(machineName + Math.abs(new Random().nextInt()));
// Get Masterkey
SaltedSecretKey masterKey = getMasterKey();
configTO.setMasterKey(masterKey);
// Generic connection settings wont work anymore, because they are plugin dependent now.
LocalTransferSettings transferSettings = Plugins.get("local", TransferPlugin.class).createEmptySettings();
transferSettings.setPath(tempRepoDir);
configTO.setTransferSettings(transferSettings);
InitOperationOptions operationOptions = new InitOperationOptions();
operationOptions.setLocalDir(tempLocalDir);
operationOptions.setConfigTO(configTO);
operationOptions.setRepoTO(repoTO);
operationOptions.setEncryptionEnabled(cryptoEnabled);
operationOptions.setCipherSpecs(CipherSpecs.getDefaultCipherSpecs());
operationOptions.setPassword(cryptoEnabled ? "some password" : null);
return operationOptions;
}
use of org.syncany.config.to.RepoTO in project syncany by syncany.
the class ConfigTest method testConfigCipherTransformersCipherFound.
@Test
@SuppressWarnings("serial")
public void testConfigCipherTransformersCipherFound() 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>() {
{
put("cipherspecs", "1,2");
}
});
List<TransformerTO> transformers = new ArrayList<TransformerTO>();
transformers.add(invalidTransformerTO);
// <<< valid
repoTO.setTransformers(transformers);
// Run!
Config config = new Config(localDir, configTO, repoTO);
// Test
assertNotNull(config.getChunker());
assertNotNull(config.getMultiChunker());
assertNotNull(config.getTransformer());
assertEquals("CipherTransformer", config.getTransformer().getClass().getSimpleName());
}
use of org.syncany.config.to.RepoTO in project syncany by syncany.
the class ConfigTest method testConfigChunkerNull.
@Test
@Ignore
public // TODO [low] ChunkerTO is not used yet; so no test for it.
void testConfigChunkerNull() throws Exception {
// Setup
File localDir = new File("/some/folder");
ConfigTO configTO = new ConfigTO();
RepoTO repoTO = new RepoTO();
// <<< valid
configTO.setMachineName("somevalidmachinename");
// <<< valid
repoTO.setMultiChunker(TestConfigUtil.createZipMultiChunkerTO());
// <<< valid
repoTO.setRepoId(new byte[] { 0x01, 0x02 });
// <<< valid
repoTO.setTransformers(null);
// <<< INVALID !!
repoTO.setChunkerTO(null);
// Run!
try {
new Config(localDir, configTO, repoTO);
fail("Config should not been have initialized.");
} catch (ConfigException e) {
TestAssertUtil.assertErrorStackTraceContains("No multichunker", e);
}
}
use of org.syncany.config.to.RepoTO 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);
}
}
use of org.syncany.config.to.RepoTO in project syncany by syncany.
the class ConfigTest method testConfigInitLocalDirNull.
@Test(expected = ConfigException.class)
public void testConfigInitLocalDirNull() throws Exception {
File localDir = null;
ConfigTO configTO = new ConfigTO();
RepoTO repoTO = new RepoTO();
new Config(localDir, configTO, repoTO);
}
Aggregations