nixosTests.mutable-users: Port tests to python
This commit is contained in:
parent
58cd46ba21
commit
c811e76d82
|
@ -1,6 +1,6 @@
|
||||||
# Mutable users tests.
|
# Mutable users tests.
|
||||||
|
|
||||||
import ./make-test.nix ({ pkgs, ...} : {
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||||
name = "mutable-users";
|
name = "mutable-users";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ gleber ];
|
maintainers = [ gleber ];
|
||||||
|
@ -19,21 +19,27 @@ import ./make-test.nix ({ pkgs, ...} : {
|
||||||
immutableSystem = nodes.machine.config.system.build.toplevel;
|
immutableSystem = nodes.machine.config.system.build.toplevel;
|
||||||
mutableSystem = nodes.mutable.config.system.build.toplevel;
|
mutableSystem = nodes.mutable.config.system.build.toplevel;
|
||||||
in ''
|
in ''
|
||||||
$machine->start();
|
machine.start()
|
||||||
$machine->waitForUnit("default.target");
|
machine.wait_for_unit("default.target")
|
||||||
|
|
||||||
# Machine starts in immutable mode. Add a user and test if reactivating
|
# Machine starts in immutable mode. Add a user and test if reactivating
|
||||||
# configuration removes the user.
|
# configuration removes the user.
|
||||||
$machine->fail("cat /etc/passwd | grep ^foobar:");
|
with subtest("Machine in immutable mode"):
|
||||||
$machine->succeed("sudo useradd foobar");
|
assert "foobar" not in machine.succeed("cat /etc/passwd")
|
||||||
$machine->succeed("cat /etc/passwd | grep ^foobar:");
|
machine.succeed("sudo useradd foobar")
|
||||||
$machine->succeed("${immutableSystem}/bin/switch-to-configuration test");
|
assert "foobar" in machine.succeed("cat /etc/passwd")
|
||||||
$machine->fail("cat /etc/passwd | grep ^foobar:");
|
machine.succeed(
|
||||||
|
"${immutableSystem}/bin/switch-to-configuration test"
|
||||||
|
)
|
||||||
|
assert "foobar" not in machine.succeed("cat /etc/passwd")
|
||||||
|
|
||||||
# In immutable mode passwd is not wrapped, while in mutable mode it is
|
# In immutable mode passwd is not wrapped, while in mutable mode it is
|
||||||
# wrapped.
|
# wrapped.
|
||||||
$machine->succeed('which passwd | grep /run/current-system/');
|
with subtest("Password is wrapped in mutable mode"):
|
||||||
$machine->succeed("${mutableSystem}/bin/switch-to-configuration test");
|
assert "/run/current-system/" in machine.succeed("which passwd")
|
||||||
$machine->succeed('which passwd | grep /run/wrappers/');
|
machine.succeed(
|
||||||
|
"${mutableSystem}/bin/switch-to-configuration test"
|
||||||
|
)
|
||||||
|
assert "/run/wrappers/" in machine.succeed("which passwd")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue