Merge pull request #93 from nix-community/zfs-crypto

tests: change passphrase to secretsecret
This commit is contained in:
Jörg Thalheim 2022-12-27 09:05:22 +00:00 committed by GitHub
commit 1006ff074c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 5 deletions

View file

@ -88,6 +88,21 @@
mountpoint = "/ext4onzfs"; mountpoint = "/ext4onzfs";
}; };
}; };
encrypted = {
zfs_type = "filesystem";
size = "20M";
options = {
mountpoint = "none";
encryption = "aes-256-gcm";
keyformat = "passphrase";
keylocation = "file:///tmp/secret.key";
};
};
"encrypted/test" = {
zfs_type = "filesystem";
size = "2M";
mountpoint = "/zfs_crypted";
};
}; };
}; };
}; };

View file

@ -20,7 +20,7 @@ makeDiskoTest {
enableOCR = true; enableOCR = true;
bootCommands = '' bootCommands = ''
machine.wait_for_text("Passphrase for") machine.wait_for_text("Passphrase for")
machine.send_chars("secret\n") machine.send_chars("secretsecret\n")
''; '';
extraConfig = { extraConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ]; boot.kernelModules = [ "dm-raid" "dm-mirror" ];

View file

@ -19,7 +19,7 @@ makeDiskoTest {
enableOCR = true; enableOCR = true;
bootCommands = '' bootCommands = ''
machine.wait_for_text("Passphrase for") machine.wait_for_text("Passphrase for")
machine.send_chars("secret\n") machine.send_chars("secretsecret\n")
''; '';
extraConfig = { extraConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ]; boot.kernelModules = [ "dm-raid" "dm-mirror" ];

View file

@ -12,6 +12,7 @@
, grub-devices ? [ "nodev" ] , grub-devices ? [ "nodev" ]
, efi ? true , efi ? true
, enableOCR ? false , enableOCR ? false
, postDisko ? ""
, testMode ? "direct" # can be one of direct module cli , testMode ? "direct" # can be one of direct module cli
, testBoot ? true # if we actually want to test booting or just create/mount , testBoot ? true # if we actually want to test booting or just create/mount
}: }:
@ -123,7 +124,7 @@
return machine return machine
machine.start() machine.start()
machine.succeed("echo -n 'secret' > /tmp/secret.key") machine.succeed("echo -n 'secretsecret' > /tmp/secret.key")
${lib.optionalString (testMode == "direct") '' ${lib.optionalString (testMode == "direct") ''
machine.succeed("${tsp-create}") machine.succeed("${tsp-create}")
machine.succeed("${tsp-mount}") machine.succeed("${tsp-mount}")
@ -148,6 +149,8 @@
machine.succeed("${tsp-disko}") # verify that we can destroy and recreate machine.succeed("${tsp-disko}") # verify that we can destroy and recreate
''} ''}
${postDisko}
${lib.optionalString testBoot '' ${lib.optionalString testBoot ''
# mount nix-store in /mnt # mount nix-store in /mnt
machine.succeed("mkdir -p /mnt/nix/store") machine.succeed("mkdir -p /mnt/nix/store")

View file

@ -10,6 +10,6 @@ makeDiskoTest {
enableOCR = true; enableOCR = true;
bootCommands = '' bootCommands = ''
machine.wait_for_text("Passphrase for") machine.wait_for_text("Passphrase for")
machine.send_chars("secret\n") machine.send_chars("secretsecret\n")
''; '';
} }

View file

@ -20,7 +20,7 @@ makeDiskoTest {
enableOCR = true; enableOCR = true;
bootCommands = '' bootCommands = ''
machine.wait_for_text("Passphrase for") machine.wait_for_text("Passphrase for")
machine.send_chars("secret\n") machine.send_chars("secretsecret\n")
''; '';
extraConfig = { extraConfig = {
boot.kernelModules = [ "dm-raid" "dm-mirror" ]; boot.kernelModules = [ "dm-raid" "dm-mirror" ];

View file

@ -5,7 +5,16 @@ makeDiskoTest {
disko-config = ../example/zfs.nix; disko-config = ../example/zfs.nix;
extraConfig = { extraConfig = {
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this! fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
boot.zfs.requestEncryptionCredentials = true;
}; };
postDisko = ''
machine.succeed("zfs set keylocation=prompt zroot/encrypted")
'';
enableOCR = true;
bootCommands = ''
machine.wait_for_text("passphrase for")
machine.send_chars("secretsecret\n")
'';
extraTestScript = '' extraTestScript = ''
machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume"); machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");
@ -25,5 +34,8 @@ makeDiskoTest {
machine.succeed("mountpoint /zfs_fs"); machine.succeed("mountpoint /zfs_fs");
machine.succeed("mountpoint /zfs_legacy_fs"); machine.succeed("mountpoint /zfs_legacy_fs");
machine.succeed("mountpoint /ext4onzfs"); machine.succeed("mountpoint /ext4onzfs");
machine.succeed("mountpoint /zfs_crypted");
machine.succeed("zfs get keystatus zroot/encrypted");
machine.succeed("zfs get keystatus zroot/encrypted/test");
''; '';
} }