app-admin/rsyslog: fix tests with Py3
authorThomas Deutschmann <whissi@gentoo.org>
Fri, 5 Apr 2019 22:42:59 +0000 (00:42 +0200)
committerThomas Deutschmann <whissi@gentoo.org>
Fri, 5 Apr 2019 23:53:27 +0000 (01:53 +0200)
Package-Manager: Portage-2.3.62, Repoman-2.3.12
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
app-admin/rsyslog/files/rsyslog-8.1903.0-add-py3-support-to-omhttp-test.patch.patch [new file with mode: 0644]
app-admin/rsyslog/rsyslog-8.1903.0.ebuild

diff --git a/app-admin/rsyslog/files/rsyslog-8.1903.0-add-py3-support-to-omhttp-test.patch.patch b/app-admin/rsyslog/files/rsyslog-8.1903.0-add-py3-support-to-omhttp-test.patch.patch
new file mode 100644 (file)
index 0000000..6600c61
--- /dev/null
@@ -0,0 +1,83 @@
+From c82b747eaf96cc77efa530ca5844ba01b91bfc88 Mon Sep 17 00:00:00 2001
+From: Thomas Deutschmann <whissi@whissi.de>
+Date: Sat, 6 Apr 2019 00:28:54 +0200
+Subject: [PATCH] tests: omhttp: add Python 3 compatibility
+
+Fixes: https://github.com/rsyslog/rsyslog/issues/3599
+---
+ tests/omhttp_server.py | 22 +++++++++++-----------
+ 1 file changed, 11 insertions(+), 11 deletions(-)
+
+diff --git a/tests/omhttp_server.py b/tests/omhttp_server.py
+index 6962138fa..d3fdb3a9a 100644
+--- a/tests/omhttp_server.py
++++ b/tests/omhttp_server.py
+@@ -36,16 +36,16 @@ def validate_auth(self):
+         if 'Authorization' not in self.headers:
+             self.send_response(401)
+             self.end_headers()
+-            self.wfile.write('missing "Authorization" header')
++            self.wfile.write(b'missing "Authorization" header')
+             return False
+         auth_header = self.headers['Authorization']
+         _, b64userpwd = auth_header.split()
+-        userpwd = base64.b64decode(b64userpwd)
++        userpwd = base64.b64decode(b64userpwd).decode('utf-8')
+         if userpwd != metadata['userpwd']:
+             self.send_response(401)
+             self.end_headers()
+-            self.wfile.write('invalid auth: {0}'.format(userpwd))
++            self.wfile.write(b'invalid auth: {0}'.format(userpwd))
+             return False
+         return True
+@@ -60,16 +60,16 @@ def do_POST(self):
+         if metadata['fail_with_400_after'] != -1 and metadata['posts'] > metadata['fail_with_400_after']:
+             self.send_response(400)
+             self.end_headers()
+-            self.wfile.write('BAD REQUEST')
++            self.wfile.write(b'BAD REQUEST')
+             return
+         if metadata['posts'] > 1 and metadata['fail_every'] != -1 and metadata['posts'] % metadata['fail_every'] == 0:
+             self.send_response(500)
+             self.end_headers()
+-            self.wfile.write('INTERNAL ERROR')
++            self.wfile.write(b'INTERNAL ERROR')
+             return
+-        content_length = int(self.headers['Content-Length'])
++        content_length = int(self.headers['Content-Length'] or 0)
+         raw_data = self.rfile.read(content_length)
+         if metadata['decompress']:
+@@ -79,12 +79,12 @@ def do_POST(self):
+         if self.path not in data:
+             data[self.path] = []
+-        data[self.path].append(post_data)
++        data[self.path].append(post_data.decode('utf-8'))
+-        res = json.dumps({'msg': 'ok'})
++        res = json.dumps({'msg': 'ok'}).encode('utf8')
+         self.send_response(200)
+-        self.send_header('Content-Type', 'application/json')
++        self.send_header('Content-Type', 'application/json; charset=utf-8')
+         self.send_header('Content-Length', len(res))
+         self.end_headers()
+@@ -97,10 +97,10 @@ def do_GET(self):
+         else:
+             result = []
+-        res = json.dumps(result)
++        res = json.dumps(result).encode('utf8')
+         self.send_response(200)
+-        self.send_header('Content-Type', 'application/json')
++        self.send_header('Content-Type', 'application/json; charset=utf-8')
+         self.send_header('Content-Length', len(res))
+         self.end_headers()
index 341d02321a0a7aadfc1f0a6e7add89480678bb74..d1896aca4726aa3570e23fe92e1cc28491a4c841 100644 (file)
@@ -100,7 +100,10 @@ if [[ ${PV} == "9999" ]]; then
        DEPEND+=" >=dev-python/docutils-0.12"
 fi
 
-PATCHES=( "${FILESDIR}"/${P}-add-missing-tests.patch )
+PATCHES=(
+       "${FILESDIR}"/${P}-add-missing-tests.patch
+       "${FILESDIR}"/${P}-add-py3-support-to-omhttp-test.patch.patch
+)
 
 CONFIG_CHECK="~INOTIFY_USER"
 WARNING_INOTIFY_USER="CONFIG_INOTIFY_USER isn't set. Imfile module on this system will only support polling mode!"