mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Add detect_secret_token
This commit is contained in:
parent
8ef58bed01
commit
d4eb9ec4d7
5 changed files with 87 additions and 0 deletions
36
tests/detect_secret_token_test.py
Normal file
36
tests/detect_secret_token_test.py
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue