From d39fd0b1d95590ae4501b07ed8a4a46c3e7f37ec Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Mar 12 2019 13:21:05 +0000 Subject: Port tests to use python 3, drop python 2 dependencies --- diff --git a/0002-Port-to-using-python-3-for-use-in-the-test-framework.patch b/0002-Port-to-using-python-3-for-use-in-the-test-framework.patch new file mode 100644 index 0000000..5968347 --- /dev/null +++ b/0002-Port-to-using-python-3-for-use-in-the-test-framework.patch @@ -0,0 +1,170 @@ +From 5f2d519d8872cb68fe4bc1571e4b070e88a7a405 Mon Sep 17 00:00:00 2001 +From: Rob Crittenden +Date: Tue, 12 Mar 2019 12:38:30 +0000 +Subject: [PATCH] Port to using python 3 for use in the test framework + +--- + Makefile.am | 8 ++++---- + gencert.in | 2 +- + test/test.py | 8 -------- + test/test_config.py | 16 ++++++++-------- + test/test_request.py | 3 +-- + test/test_util.py | 9 +++++++-- + 6 files changed, 21 insertions(+), 25 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 2009060..1946d00 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -100,14 +100,14 @@ EXTRA_DIST = *.h *.8 LICENSE test docs + check: + cd test; \ + rm -rf work; \ +- nosetests -v test_cipher.py; \ ++ nosetests-3 -v test_cipher.py; \ + if [ `id -u` != 0 ]; then \ + ./setup.sh -s 1 dbm:; \ +- DBPREFIX=dbm: nosetests -v test.py; \ ++ DBPREFIX=dbm: nosetests-3 -v test.py; \ + sleep 5; \ + rm -rf work; \ + ./setup.sh -s 1 sql:; \ +- DBPREFIX=sql: nosetests -v test.py; \ ++ DBPREFIX=sql: nosetests-3 -v test.py; \ + cd ..; \ + else \ + echo "Skipping live tests as they cannot be run as root"; \ +@@ -117,7 +117,7 @@ checksni: + cd test; \ + rm -rf work; \ + ./setup.sh -s 25; \ +- nosetests -v testsni.py; \ ++ nosetests-3 -v testsni.py; \ + cd .. + + +diff --git a/gencert.in b/gencert.in +index d119f04..9418025 100755 +--- a/gencert.in ++++ b/gencert.in +@@ -38,7 +38,7 @@ getFQDN() { + echo $maxhost + return + fi +- hostname=$(python -c 'import socket; print(socket.getfqdn())') ++ hostname=$(python3 -c 'import socket; print(socket.getfqdn())') + if [ $? == 0 ]; then + echo $hostname + return +diff --git a/test/test.py b/test/test.py +index 20fd3d2..1b2cb66 100644 +--- a/test/test.py ++++ b/test/test.py +@@ -221,14 +221,6 @@ class test_suite1(Declarative): + expected=200, + ), + +- dict( +- desc='Try SSLv3 client on 1.2-only VH', +- request=('/protocoltls12/index.html', +- {'port': 8001, +- 'ssl_version': ssl.PROTOCOL_SSLv3}), +- expected=requests.exceptions.SSLError(), +- ), +- + dict( + desc='Try TLSv1 client on 1.2-only VH', + request=('/protocoltls12/index.html', +diff --git a/test/test_config.py b/test/test_config.py +index f3091e8..749d041 100644 +--- a/test/test_config.py ++++ b/test/test_config.py +@@ -61,7 +61,8 @@ def template_file(infilename, vars): + + def write_template_file(infilename, outfilename, vars): + """Read a file and perform template substitutions""" +- replacevars = dict(default_vars.items() + vars.items()) ++ replacevars = dict(default_vars.items()) ++ replacevars.update(vars.items()) + with open(outfilename, 'w') as f: + f.write('%s\n' % template_file(infilename, replacevars)) + +@@ -171,17 +172,16 @@ class Declarative(object): + name = klass.__name__ + try: + output = self.make_request(uri, options) +- except StandardError, e: +- pass ++ except Exception as e: ++ if not isinstance(e, klass): ++ if expected_str not in str(e): ++ raise AssertionError( ++ UNEXPECTED % (uri, name, options, e.__class__.__name__, e) ++ ) + else: + raise AssertionError( + EXPECTED % (uri, name, options, output) + ) +- if not isinstance(e, klass): +- if expected_str not in str(e): +- raise AssertionError( +- UNEXPECTED % (uri, name, options, e.__class__.__name__, e) +- ) + + def check_result(self, nice, uri, options, expected, cipher=None, + protocol=None, content=None): +diff --git a/test/test_request.py b/test/test_request.py +index 8b6dae2..6235e6f 100644 +--- a/test/test_request.py ++++ b/test/test_request.py +@@ -3,7 +3,6 @@ + + import socket + import requests +-import urlparse + import logging + import socket + from requests.packages.urllib3.util import get_host +@@ -227,7 +226,7 @@ try: + 'ssl_version': ssl.PROTOCOL_SSLv23, + 'ciphers': 'HIGH'}) + cipher = r.raw._pool._get_conn().client_cipher +-except requests.exceptions.SSLError, e: ++except requests.exceptions.SSLError as e: + print e.message + else: + print r.status_code +diff --git a/test/test_util.py b/test/test_util.py +index 101b6a2..95144fc 100644 +--- a/test/test_util.py ++++ b/test/test_util.py +@@ -1,3 +1,4 @@ ++import locale + import socket + import time + import subprocess +@@ -24,7 +25,7 @@ def host_port_open(host, port, socket_type=socket.SOCK_STREAM, + s.recv(512) + + return True +- except socket.error, e: ++ except socket.error: + pass + finally: + if s: +@@ -81,7 +82,11 @@ def run(args): + p.wait() + raise + +- return (stdout, stderr, p.returncode) ++ encoding = locale.getpreferredencoding() ++ output = stdout.decode(encoding) ++ error_output = stderr.decode(encoding) ++ ++ return (output, error_output, p.returncode) + + + def assert_equal(got, expected): +-- +2.20.1 + diff --git a/mod_nss.spec b/mod_nss.spec index c5ab7d1..c14862a 100644 --- a/mod_nss.spec +++ b/mod_nss.spec @@ -6,7 +6,7 @@ Name: mod_nss Version: 1.0.17 -Release: 5%{?dist} +Release: 6%{?dist} Summary: SSL/TLS module for the Apache HTTP server License: ASL 2.0 URL: https://pagure.io/mod_nss/ @@ -43,6 +43,7 @@ Patch2: mod_nss-gencert.patch Patch3: mod_nss-ssl_engine_set.patch # Fixes for unit tests against openssl 1.1.1a Patch4: 0001-Fixes-to-unit-tests-so-they-pass-with-openssl-1.1.1a.patch +Patch5: 0002-Port-to-using-python-3-for-use-in-the-test-framework.patch %description The mod_nss module provides strong cryptography for the Apache Web @@ -56,6 +57,7 @@ security library. %patch2 -p1 -b .gencert %patch3 -p1 -b .sslengineset %patch4 -p1 +%patch5 -p1 # Touch expression parser sources to prevent regenerating it touch nss_expr_*.[chyl] @@ -168,6 +170,9 @@ fi %{_sbindir}/gencert %changelog +* Tue Mar 12 2019 Rob Crittenden - 1.0.17-6 +- Port tests to use python 3, drop python 2 dependencies + * Tue Feb 26 2019 Rob Crittenden - 1.0.17-5 - Fix tests to work against openssl 1.1.1a - Add BuildRequires on gcc