GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(util[lifecycle]): Cover hook command log redaction · tmux-python/tmuxp@250222d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • tests
    • test_util.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/test_util.py‎

Copy file name to clipboardExpand all lines: tests/test_util.py
+26Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,32 @@ def test_run_hook_commands_logs_failure(
213213
assert records[0].tmux_exit_code == 7
214214

215215

216+
def test_run_hook_commands_redacts_logged_command(
217+
caplog: pytest.LogCaptureFixture,
218+
) -> None:
219+
"""run_hook_commands() keeps expanded hook commands out of logs."""
220+
secret = "secret-token-for-hook-log"
221+
222+
with caplog.at_level(logging.INFO, logger="tmuxp.util"):
223+
run_hook_commands(f"false # {secret}")
224+
225+
for record in caplog.records:
226+
assert secret not in record.getMessage()
227+
assert secret not in str(record.__dict__)
228+
229+
hook_records = [
230+
record for record in caplog.records if hasattr(record, "tmux_hook_cmd")
231+
]
232+
assert hook_records
233+
assert all(record.tmux_hook_cmd == "<redacted>" for record in hook_records)
234+
235+
failure_records = [
236+
record for record in caplog.records if hasattr(record, "tmux_exit_code")
237+
]
238+
assert len(failure_records) == 1
239+
assert failure_records[0].tmux_exit_code == 1
240+
241+
216242
def test_get_session_should_default_to_local_attached_session(
217243
server: Server,
218244
monkeypatch: pytest.MonkeyPatch,

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.