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

Kai Reinhard
15.39.2021 d80a4b3ab35af575fd06d4e2fb9a3726418c6727
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
    }
}