def test_verify(self): for no_digits in (6, 8): with self.settings(TWO_FACTOR_TOTP_DIGITS=no_digits): device = PhoneDevice(key=random_hex().decode()) self.assertFalse(device.verify_token(-1)) self.assertFalse(device.verify_token('foobar')) self.assertTrue(device.verify_token(totp(device.bin_key, digits=no_digits)))
def test_verify_token_as_string(self): """ The field used to read the token may be a CharField, so the PhoneDevice must be able to validate tokens read as strings """ device = PhoneDevice(key=random_hex().decode()) self.assertTrue(device.verify_token(str(totp(device.bin_key))))
def test_verify_token_as_string(self): """ The field used to read the token may be a CharField, so the PhoneDevice must be able to validate tokens read as strings """ for no_digits in (6, 8): with self.settings(TWO_FACTOR_TOTP_DIGITS=no_digits): device = PhoneDevice(key=random_hex().decode()) self.assertTrue(device.verify_token(str(totp(device.bin_key, digits=no_digits))))
def test_verify(self): device = PhoneDevice(key=random_hex().decode()) self.assertFalse(device.verify_token(-1)) self.assertTrue(device.verify_token(totp(device.bin_key)))