2024-06-27 14:09:42 +00:00
|
|
|
{ lib, ... }:
|
|
|
|
let
|
|
|
|
eval =
|
|
|
|
module:
|
|
|
|
(lib.evalModules {
|
|
|
|
modules = [
|
2024-07-02 06:55:00 +00:00
|
|
|
../interface.nix
|
2024-06-27 14:09:42 +00:00
|
|
|
module
|
|
|
|
];
|
|
|
|
}).config;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
single_file_single_prompt =
|
|
|
|
let
|
|
|
|
config = eval {
|
2024-07-02 06:55:00 +00:00
|
|
|
generators.my_secret = {
|
2024-06-27 14:09:42 +00:00
|
|
|
files.password = { };
|
|
|
|
files.username.secret = false;
|
|
|
|
prompts.prompt1 = { };
|
|
|
|
script = ''
|
|
|
|
cp $prompts/prompt1 $files/password
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
test_file_secret_by_default = {
|
2024-07-02 06:55:00 +00:00
|
|
|
expr = config.generators.my_secret.files.password.secret;
|
2024-06-27 14:09:42 +00:00
|
|
|
expected = true;
|
|
|
|
};
|
|
|
|
test_secret_value_access_raises_error = {
|
2024-07-02 06:55:00 +00:00
|
|
|
expr = config.generators.my_secret.files.password.value;
|
2024-06-27 14:09:42 +00:00
|
|
|
expectedError.type = "ThrownError";
|
|
|
|
expectedError.msg = "Cannot access value of secret file";
|
|
|
|
};
|
|
|
|
test_public_value_access = {
|
2024-07-02 06:55:00 +00:00
|
|
|
expr = config.generators.my_secret.files.username ? value;
|
2024-06-27 14:09:42 +00:00
|
|
|
expected = true;
|
|
|
|
};
|
|
|
|
# both secret and public values must provide a path
|
|
|
|
test_secret_has_path = {
|
2024-07-02 06:55:00 +00:00
|
|
|
expr = config.generators.my_secret.files.password ? path;
|
2024-06-27 14:09:42 +00:00
|
|
|
expected = true;
|
|
|
|
};
|
|
|
|
test_public_var_has_path = {
|
2024-07-02 06:55:00 +00:00
|
|
|
expr = config.generators.my_secret.files.username ? path;
|
2024-06-27 14:09:42 +00:00
|
|
|
expected = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|