Rename project to collectionparser
This commit is contained in:
1 parent
997df90c21
commit
3205ab2311
26 files changed
+1285
-1420
No files matched your search
+13
-18
@@ -1,16 +1,8 @@
|
||||
import unittest
|
||||
from time import time
|
||||
|
||||
from breach.parser import LineParser
|
||||
from breach.splitter import get_output_file
|
||||
from breach.utils import alpha_num_lookup
|
||||
|
||||
from breach.cparser import c_parseline
|
||||
|
||||
p_fast = c_parseline
|
||||
p_slow = LineParser.parseline
|
||||
|
||||
p = p_fast
|
||||
from collectionparser.parser import parseline as p
|
||||
from collectionparser.splitter import get_output_file
|
||||
|
||||
|
||||
class ParserTest(unittest.TestCase):
|
||||
@@ -53,6 +45,10 @@ class ParserTest(unittest.TestCase):
|
||||
self.assertIsNone(p('ESSENTIALWAY'))
|
||||
self.assertIsNone(p('ESTARRON-ESPINOSA'))
|
||||
self.assertIsNone(p('ERLONMIRANDA:sha98ne'))
|
||||
# No '@' and no '%40' -> cannot yield a pair, must stay None.
|
||||
self.assertIsNone(p('no at sign at all'))
|
||||
self.assertIsNone(p('plain text line:with:colons'))
|
||||
self.assertIsNotNone(p('user%40domain.com:password')) # %40 still becomes '@'
|
||||
self.assertIsNotNone(p('[email protected]:[email protected]:victory'))
|
||||
self.assertIsNotNone(p('[email protected];;shanmuga6'))
|
||||
self.assertIsNotNone(p('[email protected]::shanmuga6'))
|
||||
@@ -109,7 +105,7 @@ class ParserTest(unittest.TestCase):
|
||||
|
||||
def test_parse_2(self):
|
||||
t = time()
|
||||
for i in range(20000): # 10,000 * 13 = 130,000 in 4.0 seconds.
|
||||
for _ in range(20000): # 10,000 * 13 = 130,000 in 4.0 seconds.
|
||||
# => 32B in in 10 days. That's a lot.
|
||||
p('[email protected]:123')
|
||||
p('hello@@gmail.com:123')
|
||||
@@ -128,13 +124,12 @@ class ParserTest(unittest.TestCase):
|
||||
print(time() - t)
|
||||
|
||||
def test_parse_3(self):
|
||||
alpha = alpha_num_lookup()
|
||||
self.assertEqual('j/o/s', get_output_file(alpha, 'josemariacanyero@hotmail.com'))
|
||||
self.assertEqual('c/e/o', get_output_file(alpha, 'ceo21w@gmail.com'))
|
||||
self.assertEqual('x/symbols', get_output_file(alpha, '[email protected]'))
|
||||
self.assertEqual('x/a/symbols', get_output_file(alpha, 'xa_fear_238@hotmail.fr'))
|
||||
self.assertEqual('x/symbols', get_output_file(alpha, 'x@hotmail.com'))
|
||||
self.assertEqual('k/e/v', get_output_file(alpha, '[email protected]'))
|
||||
self.assertEqual('j/o/s', get_output_file('[email protected]'))
|
||||
self.assertEqual('c/e/o', get_output_file('ceo21w@gmail.com'))
|
||||
self.assertEqual('x/symbols', get_output_file('x_fear_238@hotmail.fr'))
|
||||
self.assertEqual('x/a/symbols', get_output_file('xa[email protected]'))
|
||||
self.assertEqual('x/symbols', get_output_file('x@hotmail.com'))
|
||||
self.assertEqual('k/e/v', get_output_file('kevmedic13@yahoo.com'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
import unittest
|
||||
|
||||
from breach.query import mask_pass, mask_pass_justin_rule
|
||||
|
||||
|
||||
class ParserTest(unittest.TestCase):
|
||||
|
||||
def test_mask_password(self):
|
||||
self.assertEqual('123456**654321', mask_pass('12345688654321', num_asterisks=2))
|
||||
self.assertEqual('123456***54321', mask_pass('12345688654321', num_asterisks=3))
|
||||
self.assertEqual('12345****54321', mask_pass('12345688654321', num_asterisks=4))
|
||||
self.assertEqual('12**********21', mask_pass('12345688654321', num_asterisks=10))
|
||||
self.assertEqual('1************1', mask_pass('12345688654321', num_asterisks=12))
|
||||
self.assertEqual('**************', mask_pass('12345688654321', num_asterisks=14))
|
||||
self.assertEqual('**************', mask_pass('12345688654321', num_asterisks=18))
|
||||
self.assertEqual('**************', mask_pass('12345688654321', num_asterisks=99))
|
||||
self.assertEqual('1234568*654321', mask_pass('12345688654321', num_asterisks=1))
|
||||
self.assertEqual('12345688654321', mask_pass('12345688654321', num_asterisks=0))
|
||||
|
||||
def test_mask_password_justin(self):
|
||||
expected = 'il**********m'
|
||||
initial = 'iloveicecream'
|
||||
assert len(expected) == len(initial)
|
||||
self.assertEqual(expected, mask_pass_justin_rule(initial, num_asterisks=-1))
|
||||
|
||||
expected = 'm****n'
|
||||
initial = 'martin'
|
||||
assert len(expected) == len(initial)
|
||||
self.assertEqual(expected, mask_pass_justin_rule(initial, num_asterisks=-1))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from breach.utils import RingDictionary
|
||||
from collectionparser.utils import RingDictionary
|
||||
|
||||
|
||||
class UtilsTest(unittest.TestCase):
|
||||
@@ -8,27 +8,27 @@ class UtilsTest(unittest.TestCase):
|
||||
def test_ring_dictionary_1(self):
|
||||
rd = RingDictionary(max_num_keys=3)
|
||||
rd['a'] = 2
|
||||
self.assertListEqual(sorted(rd.keys()), ['a'])
|
||||
self.assertListEqual(sorted(rd.d), ['a'])
|
||||
self.assertListEqual(sorted(rd.k), ['a'])
|
||||
rd['b'] = 2
|
||||
self.assertListEqual(sorted(rd.keys()), ['a', 'b'])
|
||||
self.assertListEqual(sorted(rd.d), ['a', 'b'])
|
||||
self.assertListEqual(sorted(rd.k), ['a', 'b'])
|
||||
rd['c'] = 2
|
||||
self.assertListEqual(sorted(rd.keys()), ['a', 'b', 'c'])
|
||||
self.assertListEqual(sorted(rd.d), ['a', 'b', 'c'])
|
||||
self.assertListEqual(sorted(rd.k), ['a', 'b', 'c'])
|
||||
rd['d'] = 2
|
||||
self.assertListEqual(sorted(rd.keys()), ['b', 'c', 'd'])
|
||||
self.assertListEqual(sorted(rd.d), ['b', 'c', 'd'])
|
||||
self.assertListEqual(sorted(rd.k), ['b', 'c', 'd'])
|
||||
|
||||
rd = RingDictionary(max_num_keys=1)
|
||||
rd['c'] = 1
|
||||
rd['c'] = 2
|
||||
rd['c'] = 3
|
||||
self.assertListEqual(sorted(rd.keys()), ['c'])
|
||||
self.assertListEqual(sorted(rd.d), ['c'])
|
||||
self.assertListEqual(sorted(rd.k), ['c'])
|
||||
|
||||
rd['d'] = 3
|
||||
self.assertListEqual(sorted(rd.keys()), ['d'])
|
||||
self.assertListEqual(sorted(rd.d), ['d'])
|
||||
self.assertListEqual(sorted(rd.k), ['d'])
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user