diff options
Diffstat (limited to 'nix')
| -rw-r--r-- | nix/test.nix | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/nix/test.nix b/nix/test.nix index f2739eb..d2f69d9 100644 --- a/nix/test.nix +++ b/nix/test.nix @@ -52,6 +52,11 @@ pkgs.testers.runNixOSTest { systemd.services.consumer = credential 50 config "retiolum.key"; }; + # Adds a required slot: a submission for it is staged before switching. + specialisation.added.configuration = { + enstate.channels.secrets.slots."extra.key" = key; + }; + specialisation.retyped.configuration = { enstate.channels.secrets.slots = lib.mkForce { "tinc.key" = key // { @@ -110,6 +115,26 @@ pkgs.testers.runNixOSTest { machine.fail("/run/booted-system/specialisation/retyped/bin/switch-to-configuration test") machine.succeed("enstate --status | grep -q 'filled tinc.key'") + with subtest("a generation that adds a required slot: staged with its own enstate, then switched to"): + new = "/run/booted-system/specialisation/added" + machine.fail(f"{new}/bin/switch-to-configuration test") + machine.succeed( + "mkdir -p /root/added", + "printf X > /root/added/key", + """echo '{"channel": "secrets", "items": {"extra.key": {"source": {"file": "key"}}}}' """ + "> /root/added/sources.json", + f"{new}/sw/bin/enstate --pack /root/added/sources.json --out /root/added/submission", + f"{new}/sw/bin/enstate --plan /root/added/submission --schema {new}/etc/enstate/schema.json --config {new}/etc/enstate/config.json", + f"{new}/sw/bin/enstate --stage /root/added/submission --schema {new}/etc/enstate/schema.json --config {new}/etc/enstate/config.json", + ) + machine.fail("test -e /run/enstate/views/secrets.extra.key") + seen("tinc.key L") + machine.succeed(f"{new}/bin/switch-to-configuration test") + machine.wait_until_succeeds("grep -qx X /run/enstate/views/secrets.extra.key/extra.key") + seen("tinc.key L") + machine.succeed("/run/booted-system/bin/switch-to-configuration test") + machine.succeed("enstate --status | grep -q 'kept extra.key'") + with subtest("after a reboot, the views are there again"): machine.shutdown() machine.start() |
