forked from Yelp/detect-secrets
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathkeyword_test.py
35 lines (29 loc) · 973 Bytes
/
keyword_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from __future__ import absolute_import
from __future__ import unicode_literals
import pytest
from detect_secrets.plugins.keyword import KeywordDetector
from testing.mocks import mock_file_object
class TestKeywordDetector(object):
@pytest.mark.parametrize(
'file_content',
[
(
'login_somewhere --http-password hopenobodyfindsthisone\n'
),
(
'token = "noentropy"'
),
(
'PASSWORD = "verysimple"'
),
],
)
def test_analyze(self, file_content):
logic = KeywordDetector()
f = mock_file_object(file_content)
output = logic.analyze(f, 'mock_filename')
assert len(output) == 1
for potential_secret in output:
assert 'mock_filename' == potential_secret.filename
generated = list(logic.secret_generator(file_content))
assert len(generated) == len(output)