2017-09-07 15:25:42 +02:00
|
|
|
from tests.package.test_python import TestPythonBase
|
|
|
|
|
2018-03-13 04:09:41 +01:00
|
|
|
|
2017-09-07 15:25:42 +02:00
|
|
|
class TestPythonCryptography(TestPythonBase):
|
|
|
|
def fernet_test(self, timeout=-1):
|
|
|
|
cmd = self.interpreter + " -c 'from cryptography.fernet import Fernet;"
|
|
|
|
cmd += "key = Fernet.generate_key();"
|
|
|
|
cmd += "f = Fernet(key)'"
|
|
|
|
_, exit_code = self.emulator.run(cmd, timeout)
|
|
|
|
self.assertEqual(exit_code, 0)
|
|
|
|
|
2018-03-13 04:09:41 +01:00
|
|
|
|
2017-09-07 15:25:42 +02:00
|
|
|
class TestPythonPy2Cryptography(TestPythonCryptography):
|
|
|
|
config = TestPythonBase.config + \
|
2018-03-13 04:09:41 +01:00
|
|
|
"""
|
|
|
|
BR2_PACKAGE_PYTHON=y
|
|
|
|
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
|
|
|
|
"""
|
|
|
|
|
2017-09-07 15:25:42 +02:00
|
|
|
def test_run(self):
|
|
|
|
self.login()
|
|
|
|
self.fernet_test(40)
|
|
|
|
|
2018-03-13 04:09:41 +01:00
|
|
|
|
2017-09-07 15:25:42 +02:00
|
|
|
class TestPythonPy3Cryptography(TestPythonCryptography):
|
|
|
|
config = TestPythonBase.config + \
|
2018-03-13 04:09:41 +01:00
|
|
|
"""
|
|
|
|
BR2_PACKAGE_PYTHON3=y
|
|
|
|
BR2_PACKAGE_PYTHON_CRYPTOGRAPHY=y
|
|
|
|
"""
|
|
|
|
|
2017-09-07 15:25:42 +02:00
|
|
|
def test_run(self):
|
|
|
|
self.login()
|
|
|
|
self.fernet_test(40)
|