From 1dd0379ba8a8f3f3fc64e3c8ca67967328e7db18 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Sun, 12 Nov 2017 20:18:10 +0100 Subject: [PATCH 1/2] nixos/tests: Add a test for config.users.mutableUsers. It's in preparation to add an assertion for #4990. --- nixos/tests/mutable-users.nix | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 nixos/tests/mutable-users.nix 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/'); + ''; +}) From cea83021825e6f562a8a5fb33d87a30b9a5b62e2 Mon Sep 17 00:00:00 2001 From: Gleb Peregud Date: Sun, 19 Nov 2017 19:20:50 +0100 Subject: [PATCH 2/2] nixos/release: include mutableUsers test to release tests. --- nixos/release-combined.nix | 1 + nixos/release.nix | 1 + 2 files changed, 2 insertions(+) diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix index 125e6b7050bc..8736e2a5b954 100644 --- a/nixos/release-combined.nix +++ b/nixos/release-combined.nix @@ -95,6 +95,7 @@ in rec { #(all nixos.tests.lightdm) (all nixos.tests.login) (all nixos.tests.misc) + (all nixos.tests.mutableUsers) (all nixos.tests.nat.firewall) (all nixos.tests.nat.standalone) (all nixos.tests.networking.scripted.loopback) diff --git a/nixos/release.nix b/nixos/release.nix index 28eb76d888e4..ba22a3e837eb 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -290,6 +290,7 @@ in rec { tests.mongodb = callTest tests/mongodb.nix {}; tests.mumble = callTest tests/mumble.nix {}; tests.munin = callTest tests/munin.nix {}; + tests.mutableUsers = callTest tests/mutable-users.nix {}; tests.mysql = callTest tests/mysql.nix {}; tests.mysqlBackup = callTest tests/mysql-backup.nix {}; tests.mysqlReplication = callTest tests/mysql-replication.nix {};