From 72a6d5ff48d94f9d77931f11a1510ac0be263bc1 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sat, 7 Feb 2026 16:17:57 +0100 Subject: [PATCH] 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 --- tests/functional2/build/test_ca.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/functional2/build/test_ca.py b/tests/functional2/build/test_ca.py index fba54ae63..cb1234676 100644 --- a/tests/functional2/build/test_ca.py +++ b/tests/functional2/build/test_ca.py @@ -135,3 +135,16 @@ class TestCertClobberingInFODs: assert assess_cert_presence_in_builds( nix, "clobbering-impurities", sandboxed=sandboxed ).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)