Skip to content

Commit

Permalink
Add DigestFunctionTest unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
FaizRahiemy committed Aug 31, 2024
1 parent 2ed7bec commit 516531a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,16 @@ def test_valid_window(self):
self.assertTrue(totp.verify("681610", 200, 1))
self.assertFalse(totp.verify("195979", 200, 1))

class DigestFunctionTest(unittest.TestCase):
def test_md5(self):
with self.assertRaises(ValueError) as cm:
pyotp.OTP(s="secret", digest=hashlib.md5)
self.assertEqual("selected digest function must generate digest size greater than or equals to 18 bytes", str(cm.exception))

def test_shake128(self):
with self.assertRaises(ValueError) as cm:
pyotp.OTP(s="secret", digest=hashlib.shake_128)
self.assertEqual("selected digest function must generate digest size greater than or equals to 18 bytes", str(cm.exception))

class ParseUriTest(unittest.TestCase):
def test_invalids(self):
Expand Down

0 comments on commit 516531a

Please sign in to comment.