mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-28 13:57:43 +00:00
Merge origin/main into fix/meta-resolve/affected-real-includers
Takes main up to daea156470 (hotfix #2946 for the 501-line test file that turned this PR's Test job red, #2927, and the IAM line). Clean merge; on the merged tree test_invocations.py (28) and the affected resolution test_main.py (19 + 4 subtests) pass.
🎯 Fix: 93 %
💥 Break: 3 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 90
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %
Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
ffb37c841a
370 files changed
+14960
-59
No files matched your search
@@ -0,0 +1,17 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from cli.administration.inventory.provision import passwords
|
||||
|
||||
|
||||
class TestPasswordMasking(unittest.TestCase):
|
||||
def test_a_user_password_is_registered_for_masking(self) -> None:
|
||||
with patch.object(passwords, "mask") as masked:
|
||||
password = passwords.generate_user_password()
|
||||
masked.assert_called_once_with(password)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -5,7 +5,14 @@ import unittest
|
||||
from io import StringIO
|
||||
from unittest.mock import patch
|
||||
|
||||
from utils.annotations.message import error, error_each, notice, warning, warning_each
|
||||
from utils.annotations.message import (
|
||||
error,
|
||||
error_each,
|
||||
mask,
|
||||
notice,
|
||||
warning,
|
||||
warning_each,
|
||||
)
|
||||
|
||||
GHA_ENV = {"GITHUB_ACTIONS": "true"}
|
||||
NO_GHA_ENV = {"GITHUB_ACTIONS": ""}
|
||||
@@ -112,5 +119,35 @@ class TestAnnotationsPlainText(unittest.TestCase):
|
||||
self.assertIn("beta", lines[1])
|
||||
|
||||
|
||||
class TestMask(unittest.TestCase):
|
||||
def _capture(self, env: dict[str, str], value: str) -> tuple[str, str]:
|
||||
with (
|
||||
patch.dict(os.environ, env),
|
||||
patch("sys.stdout", new_callable=StringIO) as out,
|
||||
patch("sys.stderr", new_callable=StringIO) as err,
|
||||
):
|
||||
mask(value)
|
||||
return out.getvalue(), err.getvalue()
|
||||
|
||||
def test_a_secret_is_registered_on_stderr_only(self) -> None:
|
||||
out, err = self._capture(GHA_ENV, "s3cr€t")
|
||||
self.assertEqual(out, "")
|
||||
self.assertEqual(err, "::add-mask::s3cr€t\n")
|
||||
|
||||
def test_each_line_of_a_multiline_secret_is_registered(self) -> None:
|
||||
_, err = self._capture(GHA_ENV, "-----BEGIN-----\nabc\n\n-----END-----\n")
|
||||
self.assertEqual(
|
||||
err.splitlines(),
|
||||
[
|
||||
"::add-mask::-----BEGIN-----",
|
||||
"::add-mask::abc",
|
||||
"::add-mask::-----END-----",
|
||||
],
|
||||
)
|
||||
|
||||
def test_nothing_is_printed_outside_github_actions(self) -> None:
|
||||
self.assertEqual(self._capture(NO_GHA_ENV, "s3cret"), ("", ""))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user