コード例 #1
0
    def test_gen_password(self):
        for testcase in old_style_params_data:
            params = testcase['params']
            candidate_chars = testcase['candidate_chars']
            params_chars_spec = password._gen_candidate_chars(params['chars'])
            password_string = password.random_password(length=params['length'],
                                                       chars=params_chars_spec)
            self.assertEquals(len(password_string),
                              params['length'],
                              msg='generated password=%s has length (%s) instead of expected length (%s)' %
                              (password_string, len(password_string), params['length']))

            for char in password_string:
                self.assertIn(char, candidate_chars,
                              msg='%s not found in %s from chars spect %s' %
                              (char, candidate_chars, params['chars']))
コード例 #2
0
ファイル: test_password.py プロジェクト: awiddersheim/ansible
    def test_gen_password(self):
        for testcase in old_style_params_data:
            params = testcase['params']
            candidate_chars = testcase['candidate_chars']
            params_chars_spec = password._gen_candidate_chars(params['chars'])
            password_string = password.random_password(length=params['length'],
                                                       chars=params_chars_spec)
            self.assertEquals(len(password_string),
                              params['length'],
                              msg='generated password=%s has length (%s) instead of expected length (%s)' %
                              (password_string, len(password_string), params['length']))

            for char in password_string:
                self.assertIn(char, candidate_chars,
                              msg='%s not found in %s from chars spect %s' %
                              (char, candidate_chars, params['chars']))
コード例 #3
0
 def test_unicode(self):
     res = password.random_password(length=11, chars=u'くらとみ')
     self._assert_valid_chars(res, u'くらとみ')
     self.assertEqual(len(res), 11)
コード例 #4
0
 def test_free_will(self):
     # A Rush and Spinal Tap reference twofer
     res = password.random_password(length=11, chars=u'a')
     self.assertEqual(len(res), 11)
     self.assertEqual(res, 'aaaaaaaaaaa')
     self._assert_valid_chars(res, u'a')
コード例 #5
0
 def test_just_a_common(self):
     res = password.random_password(length=1, chars=u',')
     self.assertEqual(len(res), 1)
     self.assertEqual(res, u',')
コード例 #6
0
 def test_zero_length(self):
     res = password.random_password(length=0)
     self.assertEqual(len(res), 0)
     self.assertTrue(isinstance(res, text_type))
     self._assert_valid_chars(res, u',')
コード例 #7
0
 def test_default(self):
     res = password.random_password()
     self.assertEqual(len(res), password.DEFAULT_LENGTH)
     self.assertTrue(isinstance(res, text_type))
     self._assert_valid_chars(res, DEFAULT_CANDIDATE_CHARS)
コード例 #8
0
 def test_seed(self):
     pw1 = password.random_password(seed=1)
     pw2 = password.random_password(seed=1)
     pw3 = password.random_password(seed=2)
     self.assertEqual(pw1, pw2)
     self.assertNotEqual(pw1, pw3)
コード例 #9
0
ファイル: test_password.py プロジェクト: awiddersheim/ansible
 def test_unicode(self):
     res = password.random_password(length=11, chars=u'くらとみ')
     self._assert_valid_chars(res, u'くらとみ')
     self.assertEquals(len(res), 11)
コード例 #10
0
ファイル: test_password.py プロジェクト: awiddersheim/ansible
 def test_free_will(self):
     # A Rush and Spinal Tap reference twofer
     res = password.random_password(length=11, chars=u'a')
     self.assertEquals(len(res), 11)
     self.assertEquals(res, 'aaaaaaaaaaa')
     self._assert_valid_chars(res, u'a')
コード例 #11
0
ファイル: test_password.py プロジェクト: awiddersheim/ansible
 def test_just_a_common(self):
     res = password.random_password(length=1, chars=u',')
     self.assertEquals(len(res), 1)
     self.assertEquals(res, u',')
コード例 #12
0
ファイル: test_password.py プロジェクト: awiddersheim/ansible
 def test_zero_length(self):
     res = password.random_password(length=0)
     self.assertEquals(len(res), 0)
     self.assertTrue(isinstance(res, text_type))
     self._assert_valid_chars(res, u',')
コード例 #13
0
ファイル: test_password.py プロジェクト: awiddersheim/ansible
 def test_default(self):
     res = password.random_password()
     self.assertEquals(len(res), password.DEFAULT_LENGTH)
     self.assertTrue(isinstance(res, text_type))
     self._assert_valid_chars(res, DEFAULT_CANDIDATE_CHARS)