Skip to content

Commit 433e1cc

Browse files
codexByron
authored andcommitted
test: exclude fixture paths from credential redaction assertions
The Ubuntu 3.14t CI job rejected correctly redacted clone output because its randomly generated `/tmp/.tmpg8ibob` fixture path contained `bob`. The credential assertions scanned the whole error and trace, so ordinary source and destination paths could masquerade as leaked credentials. Replace only the known fixture directory with `<fixture>` before checking the error and trace for credentials. Keep the exact redacted-option assertions and the credential checks outside that directory. Include `alice-bob-user-token` in the input paths so this false positive is now covered deterministically, rather than depending on a random name. All four trace subtests failed before the assertion fix. The focused CLI and Gix runs each pass three redaction tests and four subtests afterward. `ruff check`, `ruff format --check`, and `git diff --check` also pass. This commit changes only `test/test_git.py` and is intentionally not pushed.
1 parent b03c608 commit 433e1cc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎test/test_git.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def test_it_redacts_authorization_extra_header_from_error(self):
518518
def test_clone_redacts_config_urls_from_trace_and_error(self, option, expected):
519519
for trace in (True, "full"):
520520
with self.subTest(trace=trace), writable_fixture("repo.sh", "empty") as temporary:
521-
directory = temporary.path()
521+
directory = temporary.path() / "alice-bob-user-token"
522522
with mock.patch.object(Git, "GIT_PYTHON_TRACE", trace):
523523
with self.assertLogs("git.cmd", level="INFO") as logs:
524524
with self.assertRaises(GitCommandError) as context:
@@ -529,9 +529,9 @@ def test_clone_redacts_config_urls_from_trace_and_error(self, option, expected):
529529
allow_unsafe_options=True,
530530
)
531531
self.assertIn(expected, context.exception.command)
532-
message = str(context.exception)
532+
message = str(context.exception).replace(str(directory), "<fixture>")
533533
assert logs is not None
534-
log_output = " ".join(logs.output)
534+
log_output = " ".join(logs.output).replace(str(directory), "<fixture>")
535535
self.assertIn(expected, log_output)
536536
for credential in ("alice", "bob", "user", "token"):
537537
self.assertNotIn(credential, message)

0 commit comments

Comments
 (0)