Add detect_secret_token

This commit is contained in:
Max R 2023-09-06 13:24:58 -04:00
parent 8ef58bed01
commit d4eb9ec4d7
5 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1,36 @@
from __future__ import annotations
import pytest
from pre_commit_hooks.detect_secret_token import main
@pytest.mark.parametrize(
('input', 'expected'),
(
pytest.param(
'There is no secret here',
0,
id='no secret-token',
),
pytest.param(
'There is no secret here ☃',
0,
id='no secret-token unicode',
),
pytest.param(
'Read about using "secret-token:" in RFC 8959',
0,
id='has secret-token prefix only',
),
pytest.param(
'secret-token:E92FB7EB-D882-47A4-A265-A0B6135DC842%20foo',
1,
id='has secret-token',
),
),
)
def test_main(input, expected, tmpdir):
path = tmpdir.join('file.txt')
path.write(input)
assert main([str(path)]) == expected