Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/agent/test_redact.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,38 @@ def test_path_unchanged(self):
result = redact_sensitive_text(text)
assert result == text

def test_lowercase_python_variable_token_unchanged(self):
# Regression: #4367 — lowercase 'token' assignment must not be redacted
text = "before_tokens = response.usage.prompt_tokens"
result = redact_sensitive_text(text)
assert result == text

def test_lowercase_python_variable_api_key_unchanged(self):
# Regression: #4367 — lowercase 'api_key' must not be redacted
text = "api_key = config.get('api_key')"
result = redact_sensitive_text(text)
assert result == text

def test_typescript_await_token_unchanged(self):
# Regression: #4367 — 'await' keyword must not be redacted as a secret value
text = "const token = await getToken();"
result = redact_sensitive_text(text)
assert result == text

def test_typescript_await_secret_unchanged(self):
# Regression: #4367 — similar pattern with 'secret' variable
text = "const secret = await fetchSecret();"
result = redact_sensitive_text(text)
assert result == text

def test_export_whitespace_preserved(self):
# Regression: #4367 — whitespace before uppercase env var must be preserved
text = "export SECRET_TOKEN=mypassword"
result = redact_sensitive_text(text)
assert result.startswith("export ")
assert "SECRET_TOKEN=" in result
assert "mypassword" not in result


class TestJsonFields:
def test_json_api_key(self):
Expand Down
Loading