mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
support/testing: add test for python-gnupg
This commit add a simple test doing symmetric encryption/decryption to check this python interface with the gpg binary is working fine. Signed-off-by: Julien Olivain <ju.o@free.fr> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
committed by
Yann E. MORIN
parent
ee228403e9
commit
9a79397fc5
@@ -1611,6 +1611,8 @@ F: package/python-distro/
|
|||||||
F: package/python-gnupg/
|
F: package/python-gnupg/
|
||||||
F: package/python-pyalsa/
|
F: package/python-pyalsa/
|
||||||
F: package/riscv-isa-sim/
|
F: package/riscv-isa-sim/
|
||||||
|
F: support/testing/tests/package/sample_python_gnupg.py
|
||||||
|
F: support/testing/tests/package/test_python_gnupg.py
|
||||||
|
|
||||||
N: Julien Viard de Galbert <julien@vdg.name>
|
N: Julien Viard de Galbert <julien@vdg.name>
|
||||||
F: package/dieharder/
|
F: package/dieharder/
|
||||||
|
|||||||
24
support/testing/tests/package/sample_python_gnupg.py
Normal file
24
support/testing/tests/package/sample_python_gnupg.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import gnupg
|
||||||
|
|
||||||
|
gpg = gnupg.GPG(verbose=True)
|
||||||
|
|
||||||
|
plain_data = "Some plain text data"
|
||||||
|
good_passphrase = "Good Passphrase"
|
||||||
|
|
||||||
|
# Test Encrypt
|
||||||
|
result = gpg.encrypt(plain_data, None, passphrase=good_passphrase, symmetric=True)
|
||||||
|
assert(result.returncode == 0)
|
||||||
|
enc_data = str(result)
|
||||||
|
assert(enc_data != plain_data)
|
||||||
|
|
||||||
|
# Test Good Decrypt
|
||||||
|
result = gpg.decrypt(enc_data, passphrase=good_passphrase)
|
||||||
|
assert(result.returncode == 0)
|
||||||
|
dec_data = str(result)
|
||||||
|
assert(dec_data == plain_data)
|
||||||
|
|
||||||
|
# Test Bad Decrypt
|
||||||
|
result = gpg.decrypt(enc_data, passphrase='A Wrong Passphrase')
|
||||||
|
assert(result.returncode != 0)
|
||||||
|
dec_data = str(result)
|
||||||
|
assert(dec_data != plain_data)
|
||||||
21
support/testing/tests/package/test_python_gnupg.py
Normal file
21
support/testing/tests/package/test_python_gnupg.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from tests.package.test_python import TestPythonPackageBase
|
||||||
|
|
||||||
|
|
||||||
|
class TestPythonPy2GnuPG(TestPythonPackageBase):
|
||||||
|
__test__ = True
|
||||||
|
config = TestPythonPackageBase.config + \
|
||||||
|
"""
|
||||||
|
BR2_PACKAGE_PYTHON=y
|
||||||
|
BR2_PACKAGE_PYTHON_GNUPG=y
|
||||||
|
"""
|
||||||
|
sample_scripts = ["tests/package/sample_python_gnupg.py"]
|
||||||
|
|
||||||
|
|
||||||
|
class TestPythonPy3GnuPG(TestPythonPackageBase):
|
||||||
|
__test__ = True
|
||||||
|
config = TestPythonPackageBase.config + \
|
||||||
|
"""
|
||||||
|
BR2_PACKAGE_PYTHON3=y
|
||||||
|
BR2_PACKAGE_PYTHON_GNUPG=y
|
||||||
|
"""
|
||||||
|
sample_scripts = ["tests/package/sample_python_gnupg.py"]
|
||||||
Reference in New Issue
Block a user