tests/functional2: test spurious warnings for certificates

All impure environment variables are initialized as part of `initEnv()`
to an empty value if they are unset.

Whenever `NIX_SSL_CERT_FILE` is set, this cause a spurious warning.

Let's document it here as a test before we fix it.

Change-Id: Iccba8ccb487d9cc25490e940ff09c1c5a13ae097
Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
Raito Bezarius
2026-02-26 15:33:22 +00:00
parent 0741e24266
commit 72a6d5ff48
+13
View File
@@ -135,3 +135,16 @@ class TestCertClobberingInFODs:
assert assess_cert_presence_in_builds( assert assess_cert_presence_in_builds(
nix, "clobbering-impurities", sandboxed=sandboxed nix, "clobbering-impurities", sandboxed=sandboxed
).outcomes == ({"present", "present-env-var"} if sandboxed else {"present-env-var"}) ).outcomes == ({"present", "present-env-var"} if sandboxed else {"present-env-var"})
def test_warning_presence(self, nix: Nix, sandboxed: bool):
warning_prefix = "'NIX_SSL_CERT_FILE' is an impure environment variable"
# Under impureEnvVars set, Lix will always make `NIX_SSL_CERT_FILE` exist in the environment
# of the builder with an empty value.
# This should cause the warning to be trigger because `"" != "/nowhere"`.
nix.env.unset_env("NIX_SSL_CERT_FILE")
assessment = assess_cert_presence_in_builds(
nix, "clobbering-impurities", cert="cert", sandboxed=sandboxed
)
assert any(w.startswith(warning_prefix) for w in assessment.warnings)