3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #31569 from gleber/add-mutable-users-test

nixos/tests: add a test for config.users.mutableUsers.
This commit is contained in:
Franz Pletz 2017-11-19 19:54:28 +01:00 committed by GitHub
commit f367bb4d6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View file

@ -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)

View file

@ -291,6 +291,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 {};

View file

@ -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/');
'';
})