1
mirror of https://github.com/streamlink/streamlink synced 2024-11-01 01:19:33 +01:00
streamlink/tests/test_utils_crypto.py
beardypig c9fff48e9a Test coverage increase (#1646)
* tests: logger tests

* test: file stream

* test: missing sessions tests

* test: missing util tests

* tests: call can_handle_url for each plugin to ensure it won't error

* tests: speed up by 2 seconds, mocking sleep

* test for streamname lookups

* refactor test structure

* tests: rebase plugins tests

* tests: no need for Python 3.6 support

* tests: remove 2.6 from the travis build

* tests: rebase on master

* tests: rename plugin.api tests

* tests: add mock http resource

* move new plugin tests

* rebase master

* tests: coverage for ConsoleOutput
2018-06-29 11:31:37 -07:00

22 lines
742 B
Python

import base64
import unittest
from streamlink.utils.crypto import evp_bytestokey, decrypt_openssl
class TestUtil(unittest.TestCase):
def test_evp_bytestokey(self):
self.assertEqual((b']A@*\xbcK*v\xb9q\x9d\x91\x10\x17\xc5\x92',
b'(\xb4n\xd3\xc1\x11\xe8Q\x02\x90\x9b\x1c\xfbP\xea\x0f'),
evp_bytestokey(b"hello", b"", 16, 16))
def test_decrpyt(self):
# data generated with:
# echo "this is a test" | openssl enc -aes-256-cbc -pass pass:"streamlink" -base64
data = base64.b64decode("U2FsdGVkX18nVyJ6Y+ksOASMSHKuRoQ9b4DKHuPbyQc=")
self.assertEqual(
b"this is a test\n",
decrypt_openssl(data, b"streamlink")
)