···4 password = "helloworld";
56in
7- import ./make-test.nix ({ pkgs, ...} : {
8 name = "sudo";
9 meta = with pkgs.stdenv.lib.maintainers; {
10 maintainers = [ lschuermann ];
···5051 testScript =
52 ''
53- subtest "users in wheel group should have passwordless sudo", sub {
54- $machine->succeed("su - test0 -c \"sudo -u root true\"");
55- };
5657- subtest "test1 user should have sudo with password", sub {
58- $machine->succeed("su - test1 -c \"echo ${password} | sudo -S -u root true\"");
59- };
6061- subtest "test1 user should not be able to use sudo without password", sub {
62- $machine->fail("su - test1 -c \"sudo -n -u root true\"");
63- };
6465- subtest "users in group 'foobar' should be able to use sudo with password", sub {
66- $machine->succeed("sudo -u test2 echo ${password} | sudo -S -u root true");
67- };
6869- subtest "users in group 'barfoo' should be able to use sudo without password", sub {
70- $machine->succeed("sudo -u test3 sudo -n -u root true");
71- };
7273- subtest "users in group 'baz' (GID 1337) should be able to use sudo without password", sub {
74- $machine->succeed("sudo -u test4 sudo -n -u root echo true");
75- };
7677- subtest "test5 user should be able to run commands under test1", sub {
78- $machine->succeed("sudo -u test5 sudo -n -u test1 true");
79- };
8081- subtest "test5 user should not be able to run commands under root", sub {
82- $machine->fail("sudo -u test5 sudo -n -u root true");
83- };
8485- subtest "test5 user should be able to keep his environment", sub {
86- $machine->succeed("sudo -u test5 sudo -n -E -u test1 true");
87- };
8889- subtest "users in group 'barfoo' should not be able to keep their environment", sub {
90- $machine->fail("sudo -u test3 sudo -n -E -u root true");
91- };
92 '';
93 })
···4 password = "helloworld";
56in
7+ import ./make-test-python.nix ({ pkgs, ...} : {
8 name = "sudo";
9 meta = with pkgs.stdenv.lib.maintainers; {
10 maintainers = [ lschuermann ];
···5051 testScript =
52 ''
53+ with subtest("users in wheel group should have passwordless sudo"):
54+ machine.succeed('su - test0 -c "sudo -u root true"')
05556+ with subtest("test1 user should have sudo with password"):
57+ machine.succeed('su - test1 -c "echo ${password} | sudo -S -u root true"')
05859+ with subtest("test1 user should not be able to use sudo without password"):
60+ machine.fail('su - test1 -c "sudo -n -u root true"')
06162+ with subtest("users in group 'foobar' should be able to use sudo with password"):
63+ machine.succeed("sudo -u test2 echo ${password} | sudo -S -u root true")
06465+ with subtest("users in group 'barfoo' should be able to use sudo without password"):
66+ machine.succeed("sudo -u test3 sudo -n -u root true")
06768+ with subtest("users in group 'baz' (GID 1337)"):
69+ machine.succeed("sudo -u test4 sudo -n -u root echo true")
07071+ with subtest("test5 user should be able to run commands under test1"):
72+ machine.succeed("sudo -u test5 sudo -n -u test1 true")
07374+ with subtest("test5 user should not be able to run commands under root"):
75+ machine.fail("sudo -u test5 sudo -n -u root true")
07677+ with subtest("test5 user should be able to keep his environment"):
78+ machine.succeed("sudo -u test5 sudo -n -E -u test1 true")
07980+ with subtest("users in group 'barfoo' should not be able to keep their environment"):
81+ machine.fail("sudo -u test3 sudo -n -E -u root true")
082 '';
83 })