From 30e574e8f0759a747f77e0e45fa5dbefeb44f3f0 Mon Sep 17 00:00:00 2001 From: Ayrx Date: Sat, 15 Mar 2014 21:51:04 +0800 Subject: Added backend check to twofactor primitives --- tests/hazmat/primitives/twofactor/test_totp.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tests/hazmat/primitives/twofactor/test_totp.py') diff --git a/tests/hazmat/primitives/twofactor/test_totp.py b/tests/hazmat/primitives/twofactor/test_totp.py index f3bddb88..776a9f2a 100644 --- a/tests/hazmat/primitives/twofactor/test_totp.py +++ b/tests/hazmat/primitives/twofactor/test_totp.py @@ -13,9 +13,11 @@ from __future__ import absolute_import, division, print_function +import pretend + import pytest -from cryptography.exceptions import InvalidToken +from cryptography.exceptions import InvalidToken, UnsupportedInterface from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.twofactor.totp import TOTP from tests.utils import load_vectors_from_file, load_nist_vectors @@ -129,3 +131,12 @@ class TestTOTP(object): totp = TOTP(secret, 8, hashes.SHA1(), 30, backend) assert totp.generate(time) == b"94287082" + + +def test_invalid_backend(): + secret = b"12345678901234567890" + + pretend_backend = pretend.stub() + + with pytest.raises(UnsupportedInterface): + TOTP(secret, 8, hashes.SHA1(), 30, pretend_backend) -- cgit v1.2.3