def test_verify_invalid_secret(self):
        responses.add(
            responses.GET, 'https://api.softlayer.com/rest/v3/SoftLayer_Account.json',
            json={'error': 'Access denied. '}, status=401,
        )

        assert SoftlayerDetector().verify(
            SL_TOKEN,
            'softlayer_username={}'.format(SL_USERNAME),
        ) == VerifiedResult.VERIFIED_FALSE
Esempio n. 2
0
 def test_verify_valid_secret(self):
     responses.add(
         responses.GET,
         'https://api.softlayer.com/rest/v3/SoftLayer_Account.json',
         json={'id': 1},
         status=200,
     )
     assert SoftlayerDetector().verify(
         SL_TOKEN,
         'softlayer_username={}'.format(SL_USERNAME),
     ) == VerifiedResult.VERIFIED_TRUE
 def test_verify_valid_secret(self):
     responses.add(
         responses.GET, 'https://api.softlayer.com/rest/v3/SoftLayer_Account.json',
         json={'id': 1}, status=200,
     )
     potential_secret = PotentialSecret('test softlayer', 'test filename', SL_TOKEN)
     assert SoftlayerDetector().verify(
         SL_TOKEN,
         'softlayer_username={}'.format(SL_USERNAME),
         potential_secret,
     ) == VerifiedResult.VERIFIED_TRUE
     assert potential_secret.other_factors['username'] == SL_USERNAME
    def test_analyze_line(self, payload, should_flag):
        logic = SoftlayerDetector()

        output = logic.analyze_line(payload, 1, 'mock_filename')
        assert len(output) == (1 if should_flag else 0)
 def test_verify_no_secret(self):
     assert SoftlayerDetector().verify(
         SL_TOKEN,
         'no_un={}'.format(SL_USERNAME),
     ) == VerifiedResult.UNVERIFIED
Esempio n. 6
0
 def test_verify_no_secret(self):
     assert SoftlayerDetector().verify(
         SL_TOKEN,
         get_code_snippet([f'no_un={SL_USERNAME}'], 1),
     ) == VerifiedResult.UNVERIFIED