summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-08-25 13:14:07 +0200
committerlassulus <lassulus@lassul.us>2022-08-25 15:32:09 +0200
commitdd99e29edc994056d5f700e24a75406115e98dff (patch)
tree10709b66fec84d7412ccbc9d12d2d42a7d06850c /tests
parent1237ac36db1a457ae561134d191d2924a9ce5ffc (diff)
fix cryptsetup luksOpen idempotency, add luks-lvm test
Diffstat (limited to 'tests')
-rw-r--r--tests/luks-lvm.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/luks-lvm.nix b/tests/luks-lvm.nix
new file mode 100644
index 0000000..3e2c5f2
--- /dev/null
+++ b/tests/luks-lvm.nix
@@ -0,0 +1,39 @@
+{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
+, pkgs ? (import <nixpkgs> {})
+}:
+let
+ makeTest' = args:
+ makeTest args {
+ inherit pkgs;
+ inherit (pkgs) system;
+ };
+ disko-config = import ../example/luks-lvm.nix;
+ tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config);
+ tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config);
+in makeTest' {
+ name = "disko";
+
+ nodes.machine =
+ { config, pkgs, modulesPath, ... }:
+
+ {
+ imports = [
+ (modulesPath + "/profiles/installation-device.nix")
+ (modulesPath + "/profiles/base.nix")
+ ];
+
+ # speed-up eval
+ documentation.enable = false;
+
+ virtualisation.emptyDiskImages = [ 512 ];
+ };
+
+ testScript = ''
+ machine.succeed("echo 'secret' > /tmp/secret.key");
+ machine.succeed("${tsp-create}");
+ machine.succeed("${tsp-mount}");
+ machine.succeed("${tsp-mount}"); # verify that the command is idempotent
+ machine.succeed("cryptsetup isLuks /dev/vdb2");
+ machine.succeed("grep -qs '/mnt/home' /proc/mounts");
+ '';
+}