forked from Yelp/detect-secrets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RegexBasedDetector.assign_regex_generator (Yelp#215)
* feat: use assign regex in cloudant * feat: use assign regex in db2 * feat: use assign regex in gh * feat: use assign regex in iam * feat: use assign regex in sl * address comments * address comments * address comments
- Loading branch information
XIANJUN ZHU
committed
Oct 18, 2019
1 parent
f949ae2
commit da3d9ca
Showing
2 changed files
with
55 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
from detect_secrets.core.constants import VerifiedResult | ||
from detect_secrets.core.potential_secret import PotentialSecret | ||
from detect_secrets.plugins.softlayer import get_username | ||
from detect_secrets.plugins.softlayer import find_username | ||
from detect_secrets.plugins.softlayer import SoftLayerDetector | ||
|
||
SL_USERNAME = '[email protected]' | ||
|
@@ -123,50 +123,49 @@ def test_verify_no_secret(self): | |
'no_un={}'.format(SL_USERNAME), | ||
) == VerifiedResult.UNVERIFIED | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'content, expected_output', | ||
( | ||
@pytest.mark.parametrize( | ||
'content, expected_output', | ||
( | ||
textwrap.dedent(""" | ||
--softlayer-username = {} | ||
""")[1:-1].format( | ||
SL_USERNAME, | ||
( | ||
textwrap.dedent(""" | ||
--softlayer-username = {} | ||
""")[1:-1].format( | ||
SL_USERNAME, | ||
), | ||
[SL_USERNAME], | ||
), | ||
[SL_USERNAME], | ||
), | ||
# With quotes | ||
( | ||
textwrap.dedent(""" | ||
sl_user_id = "{}" | ||
""")[1:-1].format( | ||
SL_USERNAME, | ||
# With quotes | ||
( | ||
textwrap.dedent(""" | ||
sl_user_id = "{}" | ||
""")[1:-1].format( | ||
SL_USERNAME, | ||
), | ||
[SL_USERNAME], | ||
), | ||
[SL_USERNAME], | ||
), | ||
# multiple candidates | ||
( | ||
textwrap.dedent(""" | ||
softlayer_id = '{}' | ||
sl-user = '{}' | ||
SOFTLAYER_USERID = '{}' | ||
softlayer-uname: {} | ||
""")[1:-1].format( | ||
SL_USERNAME, | ||
'[email protected]', | ||
'[email protected]', | ||
'notanemail', | ||
# multiple candidates | ||
( | ||
textwrap.dedent(""" | ||
softlayer_id = '{}' | ||
sl-user = '{}' | ||
SOFTLAYER_USERID = '{}' | ||
softlayer-uname: {} | ||
""")[1:-1].format( | ||
SL_USERNAME, | ||
'[email protected]', | ||
'[email protected]', | ||
'notanemail', | ||
), | ||
[ | ||
SL_USERNAME, | ||
'[email protected]', | ||
'[email protected]', | ||
'notanemail', | ||
], | ||
), | ||
[ | ||
SL_USERNAME, | ||
'[email protected]', | ||
'[email protected]', | ||
'notanemail', | ||
], | ||
), | ||
), | ||
) | ||
def test_get_username(content, expected_output): | ||
assert get_username(content) == expected_output | ||
) | ||
def test_find_username(self, content, expected_output): | ||
assert find_username(content) == expected_output |