forked from trufflesecurity/trufflehog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
26 lines (20 loc) · 976 Bytes
/
tests.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
import unittest
import os
from truffleHog import truffleHog
class TestStringMethods(unittest.TestCase):
def test_shannon(self):
random_stringB64 = "ZWVTjPQSdhwRgl204Hc51YCsritMIzn8B=/p9UyeX7xu6KkAGqfm3FJ+oObLDNEva"
random_stringHex = "b3A0a1FDfe86dcCE945B72"
self.assertGreater(truffleHog.shannon_entropy(random_stringB64, truffleHog.BASE64_CHARS), 4.5)
self.assertGreater(truffleHog.shannon_entropy(random_stringHex, truffleHog.HEX_CHARS), 3)
def test_cloning(self):
project_path = truffleHog.clone_git_repo("https://github.com/dxa4481/truffleHog.git")
license_file = os.path.join(project_path, "LICENSE")
self.assertTrue(os.path.isfile(license_file))
def test_unicode_expection(self):
try:
truffleHog.find_strings("https://github.com/dxa4481/tst.git")
except UnicodeEncodeError:
self.fail("Unicode print error")
if __name__ == '__main__':
unittest.main()