mirror of
https://github.com/ryantm/agenix.git
synced 2024-11-25 11:08:30 +03:00
Add update actions to integration test
This commit is contained in:
parent
3d61cccadd
commit
4e139ebfa4
1 changed files with 78 additions and 44 deletions
|
@ -1,7 +1,16 @@
|
||||||
args@{ pkgs ? <nixpkgs>, ... }:
|
args@{ pkgs ? <nixpkgs>, ... }:
|
||||||
|
|
||||||
|
with (import "${pkgs}/lib");
|
||||||
|
|
||||||
import "${pkgs}/nixos/tests/make-test-python.nix"
|
import "${pkgs}/nixos/tests/make-test-python.nix"
|
||||||
{
|
(
|
||||||
|
let
|
||||||
|
sshdConf = {
|
||||||
|
enable = true;
|
||||||
|
hostKeys = [{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
rec {
|
||||||
name = "agenix-integration";
|
name = "agenix-integration";
|
||||||
|
|
||||||
nodes.system1 = { config, ... }: {
|
nodes.system1 = { config, ... }: {
|
||||||
|
@ -10,10 +19,7 @@ import "${pkgs}/nixos/tests/make-test-python.nix"
|
||||||
./install_ssh_host_keys.nix
|
./install_ssh_host_keys.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
services.openssh = {
|
services.openssh = sshdConf;
|
||||||
enable = true;
|
|
||||||
hostKeys = [{ type = "ed25519"; path = "/etc/ssh/ssh_host_ed25519_key"; }];
|
|
||||||
};
|
|
||||||
|
|
||||||
age.secrets.passwordfile-user1.file = ../example/passwordfile-user1.age;
|
age.secrets.passwordfile-user1.file = ../example/passwordfile-user1.age;
|
||||||
|
|
||||||
|
@ -29,12 +35,34 @@ import "${pkgs}/nixos/tests/make-test-python.nix"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nodes.system2 = {
|
||||||
|
imports = [
|
||||||
|
../modules/age.nix
|
||||||
|
./install_ssh_host_keys.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
services.openssh = sshdConf;
|
||||||
|
|
||||||
|
age.secrets.ex1 = {
|
||||||
|
file = ../example/passwordfile-user1.age;
|
||||||
|
action = "echo bar > /tmp/foo";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nodes.system2After = recursiveUpdate nodes.system2 {
|
||||||
|
age.secrets.ex1.file = ../example/secret1.age;
|
||||||
|
};
|
||||||
|
|
||||||
testScript =
|
testScript =
|
||||||
let
|
let
|
||||||
user = "user1";
|
user = "user1";
|
||||||
password = "password1234";
|
password = "password1234";
|
||||||
in
|
in
|
||||||
|
{ nodes, ... }:
|
||||||
''
|
''
|
||||||
|
system1.start()
|
||||||
|
system2.start()
|
||||||
|
|
||||||
system1.wait_for_unit("multi-user.target")
|
system1.wait_for_unit("multi-user.target")
|
||||||
system1.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
|
system1.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
|
||||||
system1.sleep(2)
|
system1.sleep(2)
|
||||||
|
@ -51,6 +79,12 @@ import "${pkgs}/nixos/tests/make-test-python.nix"
|
||||||
system1.send_chars("whoami > /tmp/1\n")
|
system1.send_chars("whoami > /tmp/1\n")
|
||||||
system1.wait_for_file("/tmp/1")
|
system1.wait_for_file("/tmp/1")
|
||||||
assert "${user}" in system1.succeed("cat /tmp/1")
|
assert "${user}" in system1.succeed("cat /tmp/1")
|
||||||
|
|
||||||
|
system2.wait_for_unit("multi-user.target")
|
||||||
|
system2.wait_until_fails("grep bar /tmp/foo")
|
||||||
|
system2.wait_until_succeeds("${nodes.system2After.config.system.build.toplevel}/bin/switch-to-configuration test")
|
||||||
|
system2.wait_until_succeeds("grep bar /tmp/foo")
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
)
|
||||||
args
|
args
|
||||||
|
|
Loading…
Reference in a new issue