Add integration test for armored secret

This commit is contained in:
Andrew Lubawy 2024-07-29 10:44:12 -07:00
parent c14be7210e
commit af954310f1
No known key found for this signature in database
GPG key ID: 8E98BAE1F49C2709

View file

@ -63,6 +63,10 @@ pkgs.nixosTest {
file = ../example/secret2.age;
path = "/home/user1/secret2";
};
secrets.armored-secret = {
file = ../example/armored-secret.age;
path = "/home/user1/armored-secret";
};
};
};
};
@ -71,6 +75,7 @@ pkgs.nixosTest {
user = "user1";
password = "password1234";
secret2 = "world!";
armored-secret = "Hello World!";
in ''
system1.wait_for_unit("multi-user.target")
system1.wait_until_succeeds("pgrep -f 'agetty.*tty1'")
@ -89,8 +94,10 @@ pkgs.nixosTest {
system1.wait_for_file("/tmp/1")
assert "${user}" in system1.succeed("cat /tmp/1")
system1.send_chars("cat /run/user/$(id -u)/agenix/secret2 > /tmp/2\n")
system1.send_chars("cat /run/user/$(id -u)/agenix/armored-secret > /tmp/3\n")
system1.wait_for_file("/tmp/2")
assert "${secret2}" in system1.succeed("cat /tmp/2")
assert "${armored-secret}" in system1.succeed("cat /tmp/3")
userDo = lambda input : f"sudo -u user1 -- bash -c 'set -eou pipefail; cd /tmp/secrets; {input}'"