Пример #1
0
    def test_wrong_device_hash(self):
        user = mock.Mock()
        user.pk = 123
        user.password = make_password("xx")

        cookie_value = get_remember_device_cookie(user=user,
                                                  otp_device_id="SomeModel/33")
        validation_result = validate_remember_device_cookie(
            cookie=cookie_value,
            user=user,
            otp_device_id="SomeModel/34",
        )
        self.assertFalse(validation_result)
Пример #2
0
 def test_create_and_validate_remember_cookie(self):
     user = mock.Mock()
     user.pk = 123
     user.password = make_password("xx")
     cookie_value = get_remember_device_cookie(user=user,
                                               otp_device_id="SomeModel/33")
     self.assertEqual(len(cookie_value.split(':')), 3)
     validation_result = validate_remember_device_cookie(
         cookie=cookie_value,
         user=user,
         otp_device_id="SomeModel/33",
     )
     self.assertTrue(validation_result)