From ea443d719c62ae7bf9b4acac95e34ee4e1cdf62e Mon Sep 17 00:00:00 2001 From: Joachim Fasting Date: Fri, 25 Mar 2016 06:28:01 +0100 Subject: [PATCH] nixos/tests: implement a trivial test for sudo This is an alternative to NixOS/nixpkgs#6721, with improvements suggested by @edolstra --- nixos/tests/misc.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nixos/tests/misc.nix b/nixos/tests/misc.nix index 73af0cfad21f..b926a62194b4 100644 --- a/nixos/tests/misc.nix +++ b/nixos/tests/misc.nix @@ -23,6 +23,8 @@ import ./make-test.nix ({ pkgs, ...} : { { wantedBy = [ "multi-user.target" ]; where = "/tmp2"; }; + users.users.sybil = { isNormalUser = true; group = "wheel"; }; + security.sudo = { enable = true; wheelNeedsPassword = false; }; }; testScript = @@ -110,5 +112,10 @@ import ./make-test.nix ({ pkgs, ...} : { subtest "nix-db", sub { $machine->succeed("nix-store -qR /run/current-system | grep nixos-"); }; + + # Test sudo + subtest "sudo", sub { + $machine->succeed("su - sybil -c 'sudo true'"); + }; ''; })