Search in sources :

Example 26 with ConfigTO

use of org.syncany.config.to.ConfigTO 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;
}
Also used : SaltedSecretKey(org.syncany.crypto.SaltedSecretKey) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) HashMap(java.util.HashMap) UserConfig(org.syncany.config.UserConfig) Config(org.syncany.config.Config) ConfigTO(org.syncany.config.to.ConfigTO) Persister(org.simpleframework.xml.core.Persister) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File)

Example 27 with ConfigTO

use of org.syncany.config.to.ConfigTO 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;
}
Also used : SaltedSecretKey(org.syncany.crypto.SaltedSecretKey) TransferPlugin(org.syncany.plugins.transfer.TransferPlugin) UnreliableLocalTransferPlugin(org.syncany.plugins.unreliable_local.UnreliableLocalTransferPlugin) Random(java.util.Random) LocalTransferSettings(org.syncany.plugins.local.LocalTransferSettings) UnreliableLocalTransferSettings(org.syncany.plugins.unreliable_local.UnreliableLocalTransferSettings) InitOperationOptions(org.syncany.operations.init.InitOperationOptions) ConfigTO(org.syncany.config.to.ConfigTO) RepoTO(org.syncany.config.to.RepoTO) File(java.io.File)

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