aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/tests/mutable-users.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/tests/mutable-users.nix')
-rw-r--r--nixpkgs/nixos/tests/mutable-users.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/nixpkgs/nixos/tests/mutable-users.nix b/nixpkgs/nixos/tests/mutable-users.nix
new file mode 100644
index 00000000000..e590703ab2f
--- /dev/null
+++ b/nixpkgs/nixos/tests/mutable-users.nix
@@ -0,0 +1,39 @@
+# Mutable users tests.
+
+import ./make-test.nix ({ pkgs, ...} : {
+ name = "mutable-users";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ gleber ];
+ };
+
+ nodes = {
+ machine = { ... }: {
+ users.mutableUsers = false;
+ };
+ mutable = { ... }: {
+ users.mutableUsers = true;
+ };
+ };
+
+ testScript = {nodes, ...}: let
+ immutableSystem = nodes.machine.config.system.build.toplevel;
+ mutableSystem = nodes.mutable.config.system.build.toplevel;
+ in ''
+ $machine->start();
+ $machine->waitForUnit("default.target");
+
+ # Machine starts in immutable mode. Add a user and test if reactivating
+ # configuration removes the user.
+ $machine->fail("cat /etc/passwd | grep ^foobar:");
+ $machine->succeed("sudo useradd foobar");
+ $machine->succeed("cat /etc/passwd | grep ^foobar:");
+ $machine->succeed("${immutableSystem}/bin/switch-to-configuration test");
+ $machine->fail("cat /etc/passwd | grep ^foobar:");
+
+ # In immutable mode passwd is not wrapped, while in mutable mode it is
+ # wrapped.
+ $machine->succeed('which passwd | grep /run/current-system/');
+ $machine->succeed("${mutableSystem}/bin/switch-to-configuration test");
+ $machine->succeed('which passwd | grep /run/wrappers/');
+ '';
+})