This commit is contained in:
Luis Hebendanz 2024-06-22 15:17:34 +02:00
parent 6d2c506439
commit bb68104097
2 changed files with 5 additions and 3 deletions

View File

@ -38,9 +38,9 @@
];
generator.script = ''
if [[ -n $prompt_value ]]; then
echo $prompt_value > $secrets/user-password
echo $prompt_value | tr -d '\n' > $secrets/user-password
else
xkcdpass --numwords 3 --delimiter - --count 1 > $secrets/user-password
xkcdpass --numwords 3 --delimiter - --count 1 | tr -d '\n' > $secrets/user-password
fi
cat $secrets/user-password | mkpasswd -s -m sha-512 > $secrets/user-password-hash
'';

View File

@ -93,9 +93,11 @@ def test_generate_secret(
assert is_valid_ssh_key(ssh_secret, ssh_pub)
pwd_secret = decrypt_secret(test_flake_with_core.path, "vm1-password")
# remove last newline
pwd_secret = pwd_secret[:-1]
assert pwd_secret.isprintable()
assert pwd_secret.isascii()
assert not pwd_secret.endswith("\n")
# test idempotency for vm1 and also generate for vm2
cli.run(["facts", "generate", "--flake", str(test_flake_with_core.path)])