Skip to content

Commit e8f3ed8

Browse files
author
luigi liu
authored
Fix test
1 parent e7b410e commit e8f3ed8

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎tests/unit/test_redaction.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,26 @@ def test_redacts_base64_private_key_bytes():
116116
assert redact(value) == b'{"PrivateKey": "' + REDACTED.encode() + b'"}'
117117

118118

119+
@pytest.mark.xfail(
120+
strict=True,
121+
reason='A key split across argv items, such as an unquoted $KEY, is '
122+
'not redacted',
123+
)
124+
def test_redacts_word_split_private_key():
125+
argv = ['--private-key'] + KEY_PEM.split()
126+
assert 'MIIEow' not in redact(argv)
127+
128+
129+
@pytest.mark.xfail(
130+
strict=True,
131+
reason='Base64 PEM data that does not start with -----BEGIN is not '
132+
'redacted',
133+
)
134+
def test_redacts_base64_private_key_with_leading_text():
135+
encoded = _b64('Bag Attributes\n localKeyID: 01\n' + KEY_PEM)
136+
assert encoded not in redact(f'{{"PrivateKey": "{encoded}"}}')
137+
138+
119139
def test_register_redaction(monkeypatch):
120140
monkeypatch.setattr(redaction, '_REDACTIONS', list(redaction._REDACTIONS))
121141
register_redaction(r'secret-\w+', '<redacted secret>')

0 commit comments

Comments
 (0)