diff options
author | Oleksii Filonenko <brightone@protonmail.com> | 2019-11-24 22:06:36 +0200 |
---|---|---|
committer | Oleksii Filonenko <brightone@protonmail.com> | 2019-11-24 22:11:04 +0200 |
commit | 1043b55e4b57357eaca136147ae24fd3bf4179d7 (patch) | |
tree | e590676b18478d3a578c5b5ec6405a15e82d469e /nixos/tests/sudo.nix | |
parent | a067458d6529828c837207819856516876779c85 (diff) | |
download | nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.tar nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.tar.gz nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.tar.bz2 nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.tar.lz nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.tar.xz nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.tar.zst nixpkgs-1043b55e4b57357eaca136147ae24fd3bf4179d7.zip |
nixosTests.sudo: port to python
Diffstat (limited to 'nixos/tests/sudo.nix')
-rw-r--r-- | nixos/tests/sudo.nix | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/nixos/tests/sudo.nix b/nixos/tests/sudo.nix index fc16b99cc19..5bbec3d5726 100644 --- a/nixos/tests/sudo.nix +++ b/nixos/tests/sudo.nix @@ -4,7 +4,7 @@ let password = "helloworld"; in - import ./make-test.nix ({ pkgs, ...} : { + import ./make-test-python.nix ({ pkgs, ...} : { name = "sudo"; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ lschuermann ]; @@ -50,44 +50,34 @@ in testScript = '' - subtest "users in wheel group should have passwordless sudo", sub { - $machine->succeed("su - test0 -c \"sudo -u root true\""); - }; + with subtest("users in wheel group should have passwordless sudo"): + machine.succeed('su - test0 -c "sudo -u root true"') - subtest "test1 user should have sudo with password", sub { - $machine->succeed("su - test1 -c \"echo ${password} | sudo -S -u root true\""); - }; + with subtest("test1 user should have sudo with password"): + machine.succeed('su - test1 -c "echo ${password} | sudo -S -u root true"') - subtest "test1 user should not be able to use sudo without password", sub { - $machine->fail("su - test1 -c \"sudo -n -u root true\""); - }; + with subtest("test1 user should not be able to use sudo without password"): + machine.fail('su - test1 -c "sudo -n -u root true"') - subtest "users in group 'foobar' should be able to use sudo with password", sub { - $machine->succeed("sudo -u test2 echo ${password} | sudo -S -u root true"); - }; + with subtest("users in group 'foobar' should be able to use sudo with password"): + machine.succeed("sudo -u test2 echo ${password} | sudo -S -u root true") - subtest "users in group 'barfoo' should be able to use sudo without password", sub { - $machine->succeed("sudo -u test3 sudo -n -u root true"); - }; + with subtest("users in group 'barfoo' should be able to use sudo without password"): + machine.succeed("sudo -u test3 sudo -n -u root true") - subtest "users in group 'baz' (GID 1337) should be able to use sudo without password", sub { - $machine->succeed("sudo -u test4 sudo -n -u root echo true"); - }; + with subtest("users in group 'baz' (GID 1337)"): + machine.succeed("sudo -u test4 sudo -n -u root echo true") - subtest "test5 user should be able to run commands under test1", sub { - $machine->succeed("sudo -u test5 sudo -n -u test1 true"); - }; + with subtest("test5 user should be able to run commands under test1"): + machine.succeed("sudo -u test5 sudo -n -u test1 true") - subtest "test5 user should not be able to run commands under root", sub { - $machine->fail("sudo -u test5 sudo -n -u root true"); - }; + with subtest("test5 user should not be able to run commands under root"): + machine.fail("sudo -u test5 sudo -n -u root true") - subtest "test5 user should be able to keep his environment", sub { - $machine->succeed("sudo -u test5 sudo -n -E -u test1 true"); - }; + with subtest("test5 user should be able to keep his environment"): + machine.succeed("sudo -u test5 sudo -n -E -u test1 true") - subtest "users in group 'barfoo' should not be able to keep their environment", sub { - $machine->fail("sudo -u test3 sudo -n -E -u root true"); - }; + with subtest("users in group 'barfoo' should not be able to keep their environment"): + machine.fail("sudo -u test3 sudo -n -E -u root true") ''; }) |