···44 password = "helloworld";
5566in
77- import ./make-test.nix ({ pkgs, ...} : {
77+ import ./make-test-python.nix ({ pkgs, ...} : {
88 name = "sudo";
99 meta = with pkgs.stdenv.lib.maintainers; {
1010 maintainers = [ lschuermann ];
···50505151 testScript =
5252 ''
5353- subtest "users in wheel group should have passwordless sudo", sub {
5454- $machine->succeed("su - test0 -c \"sudo -u root true\"");
5555- };
5353+ with subtest("users in wheel group should have passwordless sudo"):
5454+ machine.succeed('su - test0 -c "sudo -u root true"')
56555757- subtest "test1 user should have sudo with password", sub {
5858- $machine->succeed("su - test1 -c \"echo ${password} | sudo -S -u root true\"");
5959- };
5656+ with subtest("test1 user should have sudo with password"):
5757+ machine.succeed('su - test1 -c "echo ${password} | sudo -S -u root true"')
60586161- subtest "test1 user should not be able to use sudo without password", sub {
6262- $machine->fail("su - test1 -c \"sudo -n -u root true\"");
6363- };
5959+ with subtest("test1 user should not be able to use sudo without password"):
6060+ machine.fail('su - test1 -c "sudo -n -u root true"')
64616565- subtest "users in group 'foobar' should be able to use sudo with password", sub {
6666- $machine->succeed("sudo -u test2 echo ${password} | sudo -S -u root true");
6767- };
6262+ with subtest("users in group 'foobar' should be able to use sudo with password"):
6363+ machine.succeed("sudo -u test2 echo ${password} | sudo -S -u root true")
68646969- subtest "users in group 'barfoo' should be able to use sudo without password", sub {
7070- $machine->succeed("sudo -u test3 sudo -n -u root true");
7171- };
6565+ with subtest("users in group 'barfoo' should be able to use sudo without password"):
6666+ machine.succeed("sudo -u test3 sudo -n -u root true")
72677373- subtest "users in group 'baz' (GID 1337) should be able to use sudo without password", sub {
7474- $machine->succeed("sudo -u test4 sudo -n -u root echo true");
7575- };
6868+ with subtest("users in group 'baz' (GID 1337)"):
6969+ machine.succeed("sudo -u test4 sudo -n -u root echo true")
76707777- subtest "test5 user should be able to run commands under test1", sub {
7878- $machine->succeed("sudo -u test5 sudo -n -u test1 true");
7979- };
7171+ with subtest("test5 user should be able to run commands under test1"):
7272+ machine.succeed("sudo -u test5 sudo -n -u test1 true")
80738181- subtest "test5 user should not be able to run commands under root", sub {
8282- $machine->fail("sudo -u test5 sudo -n -u root true");
8383- };
7474+ with subtest("test5 user should not be able to run commands under root"):
7575+ machine.fail("sudo -u test5 sudo -n -u root true")
84768585- subtest "test5 user should be able to keep his environment", sub {
8686- $machine->succeed("sudo -u test5 sudo -n -E -u test1 true");
8787- };
7777+ with subtest("test5 user should be able to keep his environment"):
7878+ machine.succeed("sudo -u test5 sudo -n -E -u test1 true")
88798989- subtest "users in group 'barfoo' should not be able to keep their environment", sub {
9090- $machine->fail("sudo -u test3 sudo -n -E -u root true");
9191- };
8080+ with subtest("users in group 'barfoo' should not be able to keep their environment"):
8181+ machine.fail("sudo -u test3 sudo -n -E -u root true")
9282 '';
9383 })