about summary refs log tree commit diff
path: root/nixos/tests
diff options
context:
space:
mode:
authorGleb Peregud <gleber.p@gmail.com>2017-11-12 20:18:10 +0100
committerGleb Peregud <gleber.p@gmail.com>2017-11-19 19:11:19 +0100
commit1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18 (patch)
tree0dd7cead41eb3b87023f38ee843c2324945c1b78 /nixos/tests
parentf1caf10ec96708e198a0e9242104d2381ea4f0ca (diff)
downloadnixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.tar
nixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.tar.gz
nixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.tar.bz2
nixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.tar.lz
nixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.tar.xz
nixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.tar.zst
nixlib-1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18.zip
nixos/tests: Add a test for config.users.mutableUsers.
It's in preparation to add an assertion for #4990.
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/mutable-users.nix39
1 files changed, 39 insertions, 0 deletions
diff --git a/nixos/tests/mutable-users.nix b/nixos/tests/mutable-users.nix
new file mode 100644
index 000000000000..4f11a4b83669
--- /dev/null
+++ b/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 = { config, lib, pkgs, ... }: {
+      users.mutableUsers = false;
+    };
+    mutable = { config, lib, pkgs, ... }: {
+      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/');
+  '';
+})