aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorBonfaceKilz2020-10-28 23:12:49 +0300
committerBonfaceKilz2020-10-28 23:12:49 +0300
commit2120392705c6aa652bab280e98c84b9c33bc5902 (patch)
tree6e3e8c4ec99585bf0d34cea47951a17b8614be5d /wqflask
parent629553ec992c59500ef64b04b8fc9fb0500bcaee (diff)
downloadgenenetwork2-2120392705c6aa652bab280e98c84b9c33bc5902.tar.gz
Add new test for hmac_creation with latin-1 secret
* wqflask/tests/utility/test_hmac.py (test_hmac_creation_with_cookie): New test. For this test, use a secret that behaves differently when encoded to either utf-8 or latin-1.
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/tests/utility/test_hmac.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/wqflask/tests/utility/test_hmac.py b/wqflask/tests/utility/test_hmac.py
index 7c61c0a6..4e3652f8 100644
--- a/wqflask/tests/utility/test_hmac.py
+++ b/wqflask/tests/utility/test_hmac.py
@@ -17,6 +17,19 @@ class TestHmacUtil(unittest.TestCase):
"""Test hmac creation with a utf-8 string"""
self.assertEqual(hmac_creation("ファイ"), "7410466338cfe109e946")
+ @mock.patch("utility.hmac.app.config",
+ {'SECRET_HMAC_CODE': ('\x08\xdf\xfa\x93N\x80'
+ '\xd9\\H@\\\x9f`\x98d^'
+ '\xb4a;\xc6OM\x946a\xbc'
+ '\xfc\x80:*\xebc')})
+ def test_hmac_creation_with_cookie(self):
+ """Test hmac creation with a cookie"""
+ cookie = "3f4c1dbf-5b56-4260-87d6-f35445bda37e:af4fcf5eace9e7c864ce"
+ uuid_, _, signature = cookie.partition(":")
+ self.assertEqual(
+ hmac_creation(uuid_),
+ "af4fcf5eace9e7c864ce")
+
@mock.patch("utility.hmac.app.config", {'SECRET_HMAC_CODE': "secret"})
def test_data_hmac(self):
"""Test data_hmac fn with a utf-8 string"""