def test_generate_44_max_domain(self): for n in range(44, 45): pg = PasswordGenerator(length=n, numbers=True, symbols=True, lowercase=True, uppercase=True) p = pg.generate() # validate length self.assertEqual(n, len(p))
def test_validate_4_nlus(self): pg = PasswordGenerator(length=4, numbers=True, lowercase=True, uppercase=True, symbols=True) p = pg.generate() # print(p) helper = PasswordHelper() self.assertTrue( helper.validate(password=p, numbers=True, lowercase=True, uppercase=True, symbols=True))
def test_generate_1_to_1000_max_domain(self): for n in range(1, 1001): pg = PasswordGenerator(length=n, numbers=True, symbols=True, lowercase=True, uppercase=True) p = pg.generate() # validate length self.assertEqual(n, len(p)) # validate complexity for c in p: self.assertTrue(c in pg.getActiveDomain())
def test_generate_domain_analysis(self): pwl = 10 pg = PasswordGenerator(length=pwl, numbers=True, symbols=True, lowercase=True, uppercase=True) p = pg.generate() n, l, u, s = 0, 0, 0, 0 for c in p: if c in pg.NUMBERS: n += 1 if c in pg.LOWER_CASE: l += 1 if c in pg.UPPER_CASE: u += 1 if c in pg.SYMBOLS: s += 1 diff = numpy.subtract((n, l, u, s), (pwl / 4, pwl / 4, pwl / 4, pwl / 4)) for x in diff: self.assertTrue(abs(x) < 2)
def test_generate_default_blank(self): pg = PasswordGenerator() self.assertEqual(len(pg.generate()), 0)
def test_generate_5_max_domain(self): pg = PasswordGenerator(length=5) p = pg.generate() self.assertEqual(len(p), 5)
def test_generate_1_lowercase(self): pg = PasswordGenerator(length=1, lowercase=True) p = pg.generate() self.assertTrue(p in pg.LOWER_CASE)
def test_generate_1_symbol(self): pg = PasswordGenerator(length=1, symbols=True) p = pg.generate() self.assertTrue(p in pg.SYMBOLS)
def test_generate_1_number(self): pg = PasswordGenerator(length=1, numbers=True) p = pg.generate() self.assertTrue(p in pg.NUMBERS)
def test_generate_1_defaults(self): pg = PasswordGenerator(length=1) self.assertEqual(len(pg.generate()), 1)
def test_get_domain_group_count(self): pg = PasswordGenerator(length=1) dgc = pg.getDomainGroupCount() self.assertEqual(dgc, 4)
def test_generate_1_uppercase(self): pg = PasswordGenerator(length=1, uppercase=True) p = pg.generate() self.assertTrue(p in pg.UPPER_CASE)
# Generate output to measure time spent on processing from datetime import datetime import time from pwdpy import PasswordGenerator start = time.time() pgen4 = PasswordGenerator( length=1, symbols=False, numbers=True, uppercase=False, lowercase=False) password = pgen4.generate() #print(len(pgen4.NUMBERS+pgen4.LOWER_CASE+pgen4.UPPER_CASE+pgen4.SYMBOLS)) #print(pgen4.NUMBERS+pgen4.LOWER_CASE+pgen4.UPPER_CASE+pgen4.SYMBOLS) print("password: "******"" found = False print(pgen4.getStrength()) exit() while found == False: # Max base is 92, the len of 5479231608oyjbwsqzimtalrfnvudgcxphkePGWUCZNXEOKVJYHAQMIDLTSFRB'?[^)&|:{/%@!`$}=,+;(]_\-#*."~ for j in pgen4.getMaxDomain(): if password == guess + j: