use of org.syncany.config.Config 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.Config 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.Config in project syncany by syncany.
the class TestConfigUtil method createTestLocalConfig.
public static Config createTestLocalConfig(String machineName, TransferSettings connection) throws Exception {
File tempLocalDir = TestFileUtil.createTempDirectoryInSystemTemp(createUniqueName("client-" + machineName, connection));
tempLocalDir.mkdirs();
RepoTO repoTO = createRepoTO();
// Create config TO
ConfigTO configTO = new ConfigTO();
configTO.setMachineName(machineName + CipherUtil.createRandomAlphabeticString(20));
// Get Masterkey
SaltedSecretKey masterKey = getMasterKey();
configTO.setMasterKey(masterKey);
LocalTransferSettings localConnection = (LocalTransferSettings) connection;
// Create connection TO
Map<String, String> localConnectionSettings = new HashMap<String, String>();
localConnectionSettings.put("path", localConnection.getPath().getAbsolutePath());
configTO.setTransferSettings(connection);
// Create
Config config = new Config(tempLocalDir, configTO, repoTO);
config.setConnection(connection);
config.getAppDir().mkdirs();
config.getCacheDir().mkdirs();
config.getDatabaseDir().mkdirs();
config.getLogDir().mkdirs();
config.getStateDir().mkdirs();
// Write to config folder (required for some tests)
new Persister().write(configTO, new File(config.getAppDir() + "/" + Config.FILE_CONFIG));
new Persister().write(repoTO, new File(config.getAppDir() + "/" + Config.FILE_REPO));
return config;
}
Aggregations