Beispiel #1
0
 def test_entropy_bits_req(self):
     passp = Passphrase()
     for wrongtype in constants.WRONGTYPES_INT_FLOAT:
         with self.assertRaises(TypeError) as context:
             passp.entropy_bits_req = wrongtype
         self.assertIn('entropy_bits_req can only be int or float',
                       str(context.exception))
     with self.assertRaises(ValueError) as context:
         passp.entropy_bits_req = -1
     self.assertIn('entropy_bits_req should be greater than 0',
                   str(context.exception))
Beispiel #2
0
 def test_words_amount_needed(self):
     passp = Passphrase()
     self.assertRaises(ValueError, passp.words_amount_needed)
     passp.amount_n = 1
     self.assertRaises(ValueError, passp.words_amount_needed)
     passp.entropy_bits_req = 77
     self.assertRaises(ValueError, passp.words_amount_needed)
     passp.load_internal_wordlist()
     self.assertEqual(passp.words_amount_needed(), 5)
Beispiel #3
0
    def test_words_amount_needed(self):
        passp = Passphrase()
        passp.load_internal_wordlist()
        passp.entropy_bits_req = 77
        passp.amount_n = 0
        amount_w = passp.words_amount_needed()
        self.assertEqual(amount_w, 6)

        passp.import_words_from_file(self.words_file, False)
        amount_w = passp.words_amount_needed()
        self.assertEqual(amount_w, 30)
Beispiel #4
0
    def test_password_length_needed(self):
        passp = Passphrase()
        for wrongtype in constants.WRONGTYPES_INT_FLOAT:
            passp._entropy_bits_req = wrongtype
            with self.assertRaises(TypeError) as context:
                passp.password_length_needed()
            self.assertIn('entropybits can only be int or float',
                          str(context.exception))

        passp._entropy_bits_req = -1
        with self.assertRaises(ValueError) as context:
            passp.password_length_needed()
        self.assertIn('entropybits should be greater than 0',
                      str(context.exception))
        passp = Passphrase()
        self.assertRaises(ValueError, passp.password_length_needed)
        passp.password_use_lowercase = False
        passp.password_use_uppercase = False
        passp.password_use_digits = False
        passp.password_use_punctuation = False
        self.assertRaises(ValueError, passp.password_length_needed)
        passp.entropy_bits_req = 77
        self.assertRaises(ValueError, passp.password_length_needed)
Beispiel #5
0
 def test_entropy_bits_req(self):
     passp = Passphrase()
     passp.entropy_bits_req = 1
     self.assertEqual(passp.entropy_bits_req, 1)
Beispiel #6
0
 def test_password_length_needed(self):
     passp = Passphrase()
     passp.entropy_bits_req = 128
     p_len = passp.password_length_needed()
     self.assertEqual(p_len, 20)