diff options
author | Alexanderlacuna | 2020-10-29 16:14:32 +0300 |
---|---|---|
committer | Alexanderlacuna | 2020-10-29 16:14:32 +0300 |
commit | 480217fdde68589ad84799c3b5df2c61608494ad (patch) | |
tree | a39c1be021bfe59869435ea97cfb93890609a2a0 /wqflask/tests | |
parent | 18304a9b20bd4180b40be8296df26c2a0acf62fa (diff) | |
parent | 6e6911b466c2727b16a190d8b714f55d7842d7e2 (diff) | |
download | genenetwork2-480217fdde68589ad84799c3b5df2c61608494ad.tar.gz |
Merge branch 'testing' of https://github.com/genenetwork/genenetwork2 into test-branch
Diffstat (limited to 'wqflask/tests')
-rw-r--r-- | wqflask/tests/utility/test_hmac.py | 13 | ||||
-rw-r--r-- | wqflask/tests/wqflask/test_user_session.py | 15 |
2 files changed, 28 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""" diff --git a/wqflask/tests/wqflask/test_user_session.py b/wqflask/tests/wqflask/test_user_session.py new file mode 100644 index 00000000..ebb0334a --- /dev/null +++ b/wqflask/tests/wqflask/test_user_session.py @@ -0,0 +1,15 @@ +"""Test cases for some methods in user_session.py""" + +import unittest +from wqflask.user_session import verify_cookie + + +class TestUserSession(unittest.TestCase): + def test_verify_cookie(self): + """ + Test cookie verification + """ + self.assertEqual( + "3f4c1dbf-5b56-4260-87d6-f35445bda37e", + verify_cookie(("3f4c1dbf-5b56-4260-87d6-" + "f35445bda37e:af4fcf5eace9e7c864ce"))) |