Permalink
Browse files

correct TOTP test case, fixes #4

 - the key for the SHA256 case was wrong, only 11 bytes instead of 16,
 - the order of the key and response argument was reversed in a previous
	 commit to conform to the accept_hotp function and this was not
	 reflected in the test case,
 - the default format was changed to 'dec6' also to conform to the same
	 API as the accept_hotp function and it was salso not reflected in the
	 test cas.
  • Loading branch information...
1 parent 1b3afeb commit 1a099c2b48db9d86efe3f1881a00e73cf3370777 @bdauvergne committed Aug 12, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 tests/totp.py
View
@@ -10,7 +10,7 @@ def parse_tv(tv):
class Totp(unittest.TestCase):
key_sha1 = binascii.hexlify('1234567890'*2)
- key_sha256 = binascii.hexlify('1234567890'*2+'12')
+ key_sha256 = binascii.hexlify('1234567890'*3+'12')
key_sha512 = binascii.hexlify('1234567890'*6+'1234')
tv = parse_tv('''| 59 | 1970-01-01 | 0000000000000001 | 94287082 | SHA1 |
@@ -66,5 +66,5 @@ class Totp(unittest.TestCase):
def test_totp(self):
for t, _, _, response, algo_key in self.tv:
algo = self.hash_algos[algo_key]
- self.assertTrue(accept_totp(response, algo['key'], t=int(t),
- hash=algo['alg']))
+ self.assertTrue(accept_totp(algo['key'], response, t=int(t),
+ hash=algo['alg'], format='dec8'))

0 comments on commit 1a099c2

Please sign in to comment.