Beispiel #1
0
 def test_multiple_iterations_nequal(self):
     """Totally naive basic randomness check.
     (the implementation uses django.utils.crypto.get_random_string()
     under the hood so this should suffice)
     """
     s1 = random_ascii_letters()
     s2 = random_ascii_letters()
     self.assertNotEqual(s1, s2)
Beispiel #2
0
 def test_issue81_regression(self):
     """We switched to django.utils.crypto.get_random_string() because we were
     generating passwords with the builtin mersenne twister, seeded manually
     from '/dev/urandom'.
     This had already been 'fixed' once due to missing parens in a seed() call.
     This regression test ensures that we're using django's sane, portable
     crypto-quality generator, instead of some unvetted pile.
     """
     with mock.patch(
         PACKAGE_BASE + '.utils.random.get_random_string',
         mock.MagicMock(return_value='thisisrandom')
     ) as patched:
         string = random_ascii_letters()
         self.assertEqual(string, 'thisisrandom')
         self.assertTrue(patched.called)
Beispiel #3
0
 def test_ascii_only(self):
     for x in range(1000):
         s = random_ascii_letters()
         for c in s:
             self.assertIn(c, self.ascii_printable)