]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] bpo-14322: added test case for invalid update to hmac (GH-26636) (#115905)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 25 Feb 2024 10:52:55 +0000 (11:52 +0100)
committerGitHub <noreply@github.com>
Sun, 25 Feb 2024 10:52:55 +0000 (10:52 +0000)
Co-authored-by: Arjun <ccldarjun@icloud.com>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Lib/test/test_hmac.py

index a39a2c45ebc2e28e2254b1036d4ebe79dea3ecb5..1502fba9f3e8b8bf974c1caffecddba517af0972 100644 (file)
@@ -479,6 +479,14 @@ class SanityTestCase(unittest.TestCase):
             self.fail("Exception raised during normal usage of HMAC class.")
 
 
+class UpdateTestCase(unittest.TestCase):
+    @hashlib_helper.requires_hashdigest('sha256')
+    def test_with_str_update(self):
+        with self.assertRaises(TypeError):
+            h = hmac.new(b"key", digestmod='sha256')
+            h.update("invalid update")
+
+
 class CopyTestCase(unittest.TestCase):
 
     @hashlib_helper.requires_hashdigest('sha256')