Normalize runtime secret transport whitespace
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s

This commit is contained in:
tegwick 2026-07-28 15:22:43 +02:00
parent 5e08b8129c
commit 0ef2ae515e
2 changed files with 27 additions and 1 deletions

View file

@ -0,0 +1,20 @@
import os
import unittest
from unittest.mock import patch
from user_engine.runtime import _required
class RequiredRuntimeValueTests(unittest.TestCase):
def test_normalizes_secret_file_newline(self):
with patch.dict(os.environ, {"USER_ENGINE_TEST_SECRET": "secret-value\n"}):
self.assertEqual(_required("USER_ENGINE_TEST_SECRET"), "secret-value")
def test_rejects_whitespace_only_value(self):
with patch.dict(os.environ, {"USER_ENGINE_TEST_SECRET": " \n\t"}):
with self.assertRaisesRegex(RuntimeError, "USER_ENGINE_TEST_SECRET is required"):
_required("USER_ENGINE_TEST_SECRET")
if __name__ == "__main__":
unittest.main()