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.
- Loading branch information
Xianjun Zhu
committed
Oct 18, 2019
1 parent
25889a1
commit 2d841c7
Showing
2 changed files
with
9 additions
and
9 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,13 +7,13 @@ | |
|
||
from detect_secrets.core.constants import VerifiedResult | ||
from detect_secrets.plugins.softlayer import find_username | ||
from detect_secrets.plugins.softlayer import SoftLayerDetector | ||
from detect_secrets.plugins.softlayer import SoftlayerDetector | ||
|
||
SL_USERNAME = '[email protected]' | ||
SL_TOKEN = 'abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234abcd1234' | ||
|
||
|
||
class TestSoftLayerDetector(object): | ||
class TestSoftlayerDetector(object): | ||
|
||
@pytest.mark.parametrize( | ||
'payload, should_flag', | ||
|
@@ -78,7 +78,7 @@ class TestSoftLayerDetector(object): | |
], | ||
) | ||
def test_analyze_string(self, payload, should_flag): | ||
logic = SoftLayerDetector() | ||
logic = SoftlayerDetector() | ||
|
||
output = logic.analyze_string(payload, 1, 'mock_filename') | ||
assert len(output) == (1 if should_flag else 0) | ||
|
@@ -90,7 +90,7 @@ def test_verify_invalid_secret(self): | |
json={'error': 'Access denied. '}, status=401, | ||
) | ||
|
||
assert SoftLayerDetector().verify( | ||
assert SoftlayerDetector().verify( | ||
SL_TOKEN, | ||
'softlayer_username={}'.format(SL_USERNAME), | ||
) == VerifiedResult.VERIFIED_FALSE | ||
|
@@ -101,20 +101,20 @@ def test_verify_valid_secret(self): | |
responses.GET, 'https://api.softlayer.com/rest/v3/SoftLayer_Account.json', | ||
json={'id': 1}, status=200, | ||
) | ||
assert SoftLayerDetector().verify( | ||
assert SoftlayerDetector().verify( | ||
SL_TOKEN, | ||
'softlayer_username={}'.format(SL_USERNAME), | ||
) == VerifiedResult.VERIFIED_TRUE | ||
|
||
@responses.activate | ||
def test_verify_unverified_secret(self): | ||
assert SoftLayerDetector().verify( | ||
assert SoftlayerDetector().verify( | ||
SL_TOKEN, | ||
'softlayer_username={}'.format(SL_USERNAME), | ||
) == VerifiedResult.UNVERIFIED | ||
|
||
def test_verify_no_secret(self): | ||
assert SoftLayerDetector().verify( | ||
assert SoftlayerDetector().verify( | ||
SL_TOKEN, | ||
'no_un={}'.format(SL_USERNAME), | ||
) == VerifiedResult.UNVERIFIED | ||
|