nixpkgs/nixos/tests/fscrypt.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

55 lines
1.7 KiB
Nix

import ./make-test-python.nix (
{ ... }:
{
name = "fscrypt";
nodes.machine =
{ pkgs, ... }:
{
imports = [ ./common/user-account.nix ];
security.pam.enableFscrypt = true;
};
testScript = ''
def login_as_alice():
machine.wait_until_tty_matches("1", "login: ")
machine.send_chars("alice\n")
machine.wait_until_tty_matches("1", "Password: ")
machine.send_chars("foobar\n")
machine.wait_until_tty_matches("1", "alice\@machine")
def logout():
machine.send_chars("logout\n")
machine.wait_until_tty_matches("1", "login: ")
machine.wait_for_unit("default.target")
with subtest("Enable fscrypt on filesystem"):
machine.succeed("tune2fs -O encrypt /dev/vda")
machine.succeed("fscrypt setup --quiet --force --time=1ms")
with subtest("Set up alice with an fscrypt-enabled home directory"):
machine.succeed("(echo foobar; echo foobar) | passwd alice")
machine.succeed("chown -R alice.users ~alice")
machine.succeed("echo foobar | fscrypt encrypt --skip-unlock --source=pam_passphrase --user=alice /home/alice")
with subtest("Create file as alice"):
login_as_alice()
machine.succeed("echo hello > /home/alice/world")
logout()
# Wait for logout to be processed
machine.sleep(1)
with subtest("File should not be readable without being logged in as alice"):
machine.fail("cat /home/alice/world")
with subtest("File should be readable again as alice"):
login_as_alice()
machine.succeed("cat /home/alice/world")
logout()
'';
}
)