Exemplo n.º 1
0
 def test_user_auth_success_otp(self):
     """The authentication should be succeeded with OTP."""
     from pyotp.totp import TOTP
     provider = TOTP(self.secret.secret)
     user = self.backend.authenticate(username=self.users[0].username,
                                      password="******",
                                      otp_auth=provider.now())
     self.assertEqual(user, self.users[0])
Exemplo n.º 2
0
 def test_user_auth_failure_otp(self):
     """The authentication should be failed with OTP."""
     from pyotp.totp import TOTP
     provider = TOTP(self.secret.secret)
     user = self.backend.authenticate(
         username=self.users[0].username,
         password="******",
         otp_auth=str(
             (int(provider.now()) + 1) % 1000000).zfill(provider.digits))
     self.assertIsNone(user)