Normalize runtime secret transport whitespace
This commit is contained in:
parent
5e08b8129c
commit
0ef2ae515e
2 changed files with 27 additions and 1 deletions
20
tests/test_runtime_config.py
Normal file
20
tests/test_runtime_config.py
Normal 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()
|
||||
Loading…
Add table
Add a link
Reference in a new issue