示例#1
0
 def test_match_extension_match(self, mock_find_extension):
     mock_find_extension.return_value = '.pem'
     simple_match = SimpleMatch('extension', 'Potential cryptographic private key', '.pem')
     self.assertTrue(simple_match.match('/path/to/pem', ''))
示例#2
0
 def test_match_str(self):
     simple_match = SimpleMatch('Part', 'Name ', 'Sig')
     self.assertEqual("Type:<class 'tell_me_your_secrets.__main__.SimpleMatch'> Name:Name  Part:Part: Signature:Sig",
                      str(simple_match))
示例#3
0
 def test_invalid(self):
     simple_match = SimpleMatch('unmapped', 'something ', '')
     self.assertFalse(simple_match.match('', ''))
示例#4
0
 def test_match_path_no_match(self):
     simple_match = SimpleMatch('path', 'Sample path match', '/path/to/secret')
     self.assertFalse(simple_match.match('/path/to/no_secret', ''))
示例#5
0
 def test_match_contents_no_match(self):
     simple_match = SimpleMatch('contents', 'Sample content match', 'abcdef')
     self.assertFalse(simple_match.match('/path/to/file', 'xyz'))
示例#6
0
 def test_match_filename_no_match(self):
     simple_match = SimpleMatch('filename', 'Ruby On Rails secret token configuration file', 'secret_token.rb')
     self.assertFalse(simple_match.match('/path/to/non_secret_token.rb', ''))
示例#7
0
 def test_match_path_match(self):
     simple_match = SimpleMatch('path', 'Sample path match',
                                '/path/to/secret')
     self.assertTrue(simple_match.match('/path/to/secret', '').is_match)
示例#8
0
 def test_match_contents_match(self):
     simple_match = SimpleMatch('contents', 'Sample content match',
                                'abcdef')
     self.assertTrue(simple_match.match('/path/to/file', 'abcdef').is_match)