diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 43a882180036..9e80e2cae6d1 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1304,6 +1304,7 @@ in systemd-escaping = handleTest ./systemd-escaping.nix { }; systemd-initrd-bridge = handleTest ./systemd-initrd-bridge.nix { }; systemd-initrd-btrfs-raid = handleTest ./systemd-initrd-btrfs-raid.nix { }; + systemd-initrd-credentials = handleTest ./systemd-initrd-credentials.nix { }; systemd-initrd-luks-fido2 = handleTest ./systemd-initrd-luks-fido2.nix { }; systemd-initrd-luks-keyfile = handleTest ./systemd-initrd-luks-keyfile.nix { }; systemd-initrd-luks-empty-passphrase = handleTest ./initrd-luks-empty-passphrase.nix { diff --git a/nixos/tests/systemd-initrd-credentials.nix b/nixos/tests/systemd-initrd-credentials.nix new file mode 100644 index 000000000000..6e3fb87f8b9b --- /dev/null +++ b/nixos/tests/systemd-initrd-credentials.nix @@ -0,0 +1,35 @@ +import ./make-test-python.nix ( + + { lib, pkgs, ... }: + { + name = "systemd-initrd-credentials"; + + nodes.machine = + { pkgs, ... }: + { + virtualisation = { + qemu.options = [ + "-smbios type=11,value=io.systemd.credential:cred-smbios=secret-smbios" + ]; + }; + + boot.initrd.availableKernelModules = [ "dmi_sysfs" ]; + + boot.kernelParams = [ "systemd.set_credential=cred-cmdline:secret-cmdline" ]; + + boot.initrd.systemd = { + enable = true; + }; + }; + + testScript = '' + machine.wait_for_unit("multi-user.target") + + # Check credential passed via kernel command line + assert "secret-cmdline" in machine.succeed("systemd-creds --system cat cred-cmdline") + + # Check credential passed via SMBIOS + assert "secret-smbios" in machine.succeed("systemd-creds --system cat cred-smbios") + ''; + } +)