def test_salt(): not_salted = dw.DicewareResult(words_count=2, system_rand=True, bonus_roll=False) salted = dw.DicewareResult(words_count=2, system_rand=True, bonus_roll=True) not_salted.make_rolls() salted.make_rolls() assert salted.salt is not None assert not_salted.salt is None
def test_passphrase_wordcount(bundled_dict): result = dw.DicewareResult(words_count=5, system_rand=True, bonus_roll=True) result.make_rolls() passphrase = result.password_from_dict(bundled_dict) m = re.findall(" ", passphrase) assert len(m) == 4 assert len(re.split(r" ", passphrase)) == 5
def test_passphrase_stability(bundled_dict): result = dw.DicewareResult(words_count=5, system_rand=True, bonus_roll=True) result.make_rolls() passphrases = [] passphrases.append(result.password_from_dict(bundled_dict)) passphrases.append(result.password_from_dict(bundled_dict)) # No new make_rolls() calls should leave the passphrase stable assert passphrases[0] == passphrases[1] result.make_rolls() passphrases.append(result.password_from_dict(bundled_dict)) assert passphrases[1] != passphrases[2]
def test_non_system_rand(): stored_results = [] result = dw.DicewareResult(words_count=5, system_rand=False, bonus_roll=True) result.ensure_random_generator() result.random_generator.seed(15) result.make_rolls() stored_results.append(copy.deepcopy(result)) result.make_rolls() stored_results.append(copy.deepcopy(result)) result.random_generator.seed(15) result.make_rolls() stored_results.append(copy.deepcopy(result)) assert stored_results[0].rolls != stored_results[1].rolls assert stored_results[0].rolls == stored_results[2].rolls
def create_passphrase(**kwargs): """ Create a passphrase using forwarded kwargs arguments to Diceware simulator.""" result = dw.DicewareResult(**kwargs) result.make_rolls() return result