use hardcodedsecret in restic test
This commit is contained in:
parent
b134abeb6d
commit
9d81a72d51
1 changed files with 17 additions and 16 deletions
|
@ -12,11 +12,25 @@ let
|
||||||
commonTest = user: pkgs.testers.runNixOSTest {
|
commonTest = user: pkgs.testers.runNixOSTest {
|
||||||
name = "restic_backupAndRestore_${user}";
|
name = "restic_backupAndRestore_${user}";
|
||||||
|
|
||||||
nodes.machine = {
|
nodes.machine = { config, ... }: {
|
||||||
imports = ( testLib.baseImports pkgs' ) ++ [
|
imports = ( testLib.baseImports pkgs' ) ++ [
|
||||||
|
../../modules/blocks/hardcodedsecret.nix
|
||||||
../../modules/blocks/restic.nix
|
../../modules/blocks/restic.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
shb.hardcodedsecret.A = {
|
||||||
|
owner = "root";
|
||||||
|
group = "keys";
|
||||||
|
mode = "0440";
|
||||||
|
content = "secretA";
|
||||||
|
};
|
||||||
|
shb.hardcodedsecret.B = {
|
||||||
|
owner = "root";
|
||||||
|
group = "keys";
|
||||||
|
mode = "0440";
|
||||||
|
content = "secretB";
|
||||||
|
};
|
||||||
|
|
||||||
shb.restic.instances."testinstance" = {
|
shb.restic.instances."testinstance" = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
|
@ -39,8 +53,8 @@ let
|
||||||
# Those are not needed by the repository but are still included
|
# Those are not needed by the repository but are still included
|
||||||
# so we can test them in the hooks section.
|
# so we can test them in the hooks section.
|
||||||
secrets = {
|
secrets = {
|
||||||
A.source = "/run/secrets/A";
|
A.source = config.shb.hardcodedsecret.A.path;
|
||||||
B.source = "/run/secrets/B";
|
B.source = config.shb.hardcodedsecret.B.path;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -97,19 +111,6 @@ let
|
||||||
if len(result) > 0:
|
if len(result) > 0:
|
||||||
raise Exception("Unexpected files:", result)
|
raise Exception("Unexpected files:", result)
|
||||||
|
|
||||||
with subtest("Create secrets"):
|
|
||||||
print(machine.succeed("""
|
|
||||||
mkdir -p /run/secrets/
|
|
||||||
|
|
||||||
echo secretA > /run/secrets/A
|
|
||||||
echo secretB > /run/secrets/B
|
|
||||||
|
|
||||||
chown root:keys -R /run/secrets
|
|
||||||
find /run/secrets -type d -exec chmod u=rwx,g=rx,o=x '{}' ';'
|
|
||||||
find /run/secrets -type f -exec chmod u=r,g=r,o= '{}' ';'
|
|
||||||
ls -l /run/secrets
|
|
||||||
"""))
|
|
||||||
|
|
||||||
with subtest("Create initial content"):
|
with subtest("Create initial content"):
|
||||||
machine.succeed("""
|
machine.succeed("""
|
||||||
mkdir -p /opt/files/A
|
mkdir -p /opt/files/A
|
||||||
|
|
Loading…
Reference in a new issue