diff options
author | rachmadani haryono <rachmadaniHaryono@users.noreply.github.com> | 2019-07-17 16:09:09 +0800 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2019-07-17 10:09:09 +0200 |
commit | ec88fb8a0f2db0a789349e04caf23e2283daaf13 (patch) | |
tree | ecd0d57e62c4eb3f84bc53132b7b0341fa70a082 /tests/unit/test_utils.py | |
parent | 8f44014627ff26019c0ffc01f77394f56dfb7db1 (diff) | |
download | searxng-ec88fb8a0f2db0a789349e04caf23e2283daaf13.tar.gz searxng-ec88fb8a0f2db0a789349e04caf23e2283daaf13.zip |
[fix] secret_key can be bytes instead of a string (#1602)
Fix #1600
In settings.yml, the secret_key can be written as string or as base64 encoded data using !!binary notation.
Diffstat (limited to 'tests/unit/test_utils.py')
-rw-r--r-- | tests/unit/test_utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 4854636c7..fbaed2bd1 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -128,3 +128,17 @@ class TestUnicodeWriter(SearxTestCase): rows = [1, 2, 3] self.unicode_writer.writerows(rows) self.assertEqual(self.unicode_writer.writerow.call_count, len(rows)) + + +class TestNewHmac(SearxTestCase): + + def test_bytes(self): + for secret_key in ['secret', b'secret', 1]: + if secret_key == 1: + with self.assertRaises(TypeError): + utils.new_hmac(secret_key, b'http://example.com') + continue + res = utils.new_hmac(secret_key, b'http://example.com') + self.assertEqual( + res, + '23e2baa2404012a5cc8e4a18b4aabf0dde4cb9b56f679ddc0fd6d7c24339d819') |