1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-09 09:36:20 +09:00
nixpkgs/nixos/tests/stratis/encryption.nix
2025-05-12 19:39:22 -04:00

36 lines
1.2 KiB
Nix

import ../make-test-python.nix (
{ pkgs, ... }:
{
name = "stratis";
meta = with pkgs.lib.maintainers; {
maintainers = [ nickcao ];
};
nodes.machine =
{ pkgs, ... }:
{
services.stratis.enable = true;
virtualisation.emptyDiskImages = [ 2048 ];
};
testScript =
let
testkey1 = pkgs.writeText "testkey1" "supersecret1";
testkey2 = pkgs.writeText "testkey2" "supersecret2";
in
''
machine.wait_for_unit("stratisd")
# test creation of encrypted pool and filesystem
machine.succeed("stratis key set testkey1 --keyfile-path ${testkey1}")
machine.succeed("stratis key set testkey2 --keyfile-path ${testkey2}")
machine.succeed("stratis pool create testpool /dev/vdb --key-desc testkey1")
machine.succeed("stratis fs create testpool testfs")
# test rebinding encrypted pool
machine.succeed("stratis pool rebind keyring testpool testkey2")
# test restarting encrypted pool
machine.succeed("stratis pool stop --name testpool")
machine.succeed("stratis pool start --name testpool --unlock-method any")
'';
}
)