示例#1
0
    def test_wrong_data_type(self):

        with self.assertRaises(Exception) as e:
            type5_pw([])
        self.assertEqual(
            "type5_pw password input should be a string, but was given a input of list",
            str(e.exception),
        )

        with self.assertRaises(Exception) as e:
            type5_pw({})
        self.assertEqual(
            "type5_pw password input should be a string, but was given a input of dict",
            str(e.exception),
        )

        with self.assertRaises(Exception) as e:
            type5_pw("pass", [])
        self.assertEqual(
            "type5_pw salt input should be a string, but was given a input of list",
            str(e.exception),
        )

        with self.assertRaises(Exception) as e:
            type5_pw("pass", {})
        self.assertEqual(
            "type5_pw salt input should be a string, but was given a input of dict",
            str(e.exception),
        )
    def test_bad_salt_char(self):

        with self.assertRaises(Exception) as e:
            type5_pw('password', '*()')
        self.assertEqual(
            "type5_pw salt used inproper characters, must be one of "
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./",
            str(e.exception))

        with self.assertRaises(Exception) as e:
            type5_pw('password', 'asd$')
        self.assertEqual(
            "type5_pw salt used inproper characters, must be one of "
            "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./",
            str(e.exception))
示例#3
0
 def test_undefined_salt_success(self):
     password = "******"
     parsed = type5_pw(password)
     self.assertEqual(len(parsed), 30)
示例#4
0
 def test_defined_salt_success(self):
     password = "******"
     salt = "nTc1"
     expected = "$1$nTc1$Z28sUTcWfXlvVe2x.3XAa."
     parsed = type5_pw(password, salt)
     self.assertEqual(parsed, expected)
 def test_defined_salt_success(self):
     password = '******'
     salt = 'nTc1'
     expected = '$1$nTc1$Z28sUTcWfXlvVe2x.3XAa.'
     parsed = type5_pw(password, salt)
     self.assertEqual(parsed, expected)