mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
07.29.2019 3ebfd4bc53b5b2c20d0cdb78441450784f50915d
Environment variables are now built by BorgRepoConfig itself.
1 files added
33 ■■■■■ changed files
borgbutler-core/src/test/java/de/micromata/borgbutler/config/BorgRepoConfigTest.java 33 ●●●●● patch | view | raw | blame | history
borgbutler-core/src/test/java/de/micromata/borgbutler/config/BorgRepoConfigTest.java
New file
@@ -0,0 +1,33 @@
package de.micromata.borgbutler.config;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BorgRepoConfigTest {
    @Test
    void protectPassphraseTest()  {
        BorgRepoConfig config = new BorgRepoConfig();
        config.setRepo("Repo");
        config.setPassphrase("secret");
        config.setRsh("RSH");
        String[] variables = config.getEnvironmentVariables();
        test(variables,"BORG_REPO", "Repo");
        test(variables,"BORG_RSH", "RSH");
        test(variables,"BORG_PASSPHRASE", "******");
         variables = config.getEnvironmentVariables(true);
        test(variables,"BORG_REPO", "Repo");
        test(variables,"BORG_RSH", "RSH");
        test(variables,"BORG_PASSPHRASE", "secret");
    }
    private void test(String[] variables, String name, String value) {
        String val = null;
        for (String variable : variables) {
            if (!variable.startsWith(name))
                continue;
             val = variable;
        }
        assertEquals(name + "=" + value, val);
    }
}