Commit 5f82bc97 authored by Jérome Perrin's avatar Jérome Perrin

python3 tests

parent 6c3ce690
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from __future__ import absolute_import
from setuptools import setup, find_packages from setuptools import setup, find_packages
version = '0.0.1.dev0' version = '0.0.1.dev0'
......
...@@ -25,34 +25,37 @@ ...@@ -25,34 +25,37 @@
# #
############################################################################## ##############################################################################
from __future__ import absolute_import
import glob import glob
import os import os
import requests import requests
import httplib import six.moves.http_client
from requests_toolbelt.adapters import source from requests_toolbelt.adapters import source
import json import json
import multiprocessing import multiprocessing
import subprocess import subprocess
from unittest import skip from unittest import skip
import ssl import ssl
from BaseHTTPServer import HTTPServer from six.moves.BaseHTTPServer import HTTPServer
from BaseHTTPServer import BaseHTTPRequestHandler from six.moves.BaseHTTPServer import BaseHTTPRequestHandler
from SocketServer import ThreadingMixIn from six.moves.socketserver import ThreadingMixIn
import time import time
import tempfile import tempfile
import ipaddress import ipaddress
import StringIO from io import StringIO
import gzip import gzip
import base64 import base64
import re import re
from slapos.recipe.librecipe import generateHashFromFiles from slapos.recipe.librecipe import generateHashFromFiles
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import urlparse import six.moves.urllib.parse
import socket import socket
import sys import sys
import logging import logging
import random import random
import string import string
import six
from six.moves import range
try: try:
...@@ -133,7 +136,7 @@ def patch_broken_pipe_error(): ...@@ -133,7 +136,7 @@ def patch_broken_pipe_error():
"""Monkey Patch BaseServer.handle_error to not write """Monkey Patch BaseServer.handle_error to not write
a stacktrace to stderr on broken pipe. a stacktrace to stderr on broken pipe.
https://stackoverflow.com/a/7913160""" https://stackoverflow.com/a/7913160"""
from SocketServer import BaseServer from six.moves.socketserver import BaseServer
handle_error = BaseServer.handle_error handle_error = BaseServer.handle_error
...@@ -165,7 +168,7 @@ def createKey(): ...@@ -165,7 +168,7 @@ def createKey():
def createSelfSignedCertificate(name_list): def createSelfSignedCertificate(name_list):
key, key_pem = createKey() key, key_pem = createKey()
subject_alternative_name_list = x509.SubjectAlternativeName( subject_alternative_name_list = x509.SubjectAlternativeName(
[x509.DNSName(unicode(q)) for q in name_list] [x509.DNSName(six.text_type(q)) for q in name_list]
) )
subject = issuer = x509.Name([ subject = issuer = x509.Name([
x509.NameAttribute(NameOID.COMMON_NAME, u'Test Self Signed Certificate'), x509.NameAttribute(NameOID.COMMON_NAME, u'Test Self Signed Certificate'),
...@@ -195,10 +198,10 @@ def createCSR(common_name, ip=None): ...@@ -195,10 +198,10 @@ def createCSR(common_name, ip=None):
subject_alternative_name_list = [] subject_alternative_name_list = []
if ip is not None: if ip is not None:
subject_alternative_name_list.append( subject_alternative_name_list.append(
x509.IPAddress(ipaddress.ip_address(unicode(ip))) x509.IPAddress(ipaddress.ip_address(six.text_type(ip)))
) )
csr = x509.CertificateSigningRequestBuilder().subject_name(x509.Name([ csr = x509.CertificateSigningRequestBuilder().subject_name(x509.Name([
x509.NameAttribute(NameOID.COMMON_NAME, unicode(common_name)), x509.NameAttribute(NameOID.COMMON_NAME, six.text_type(common_name)),
])) ]))
if len(subject_alternative_name_list): if len(subject_alternative_name_list):
...@@ -222,10 +225,10 @@ class CertificateAuthority(object): ...@@ -222,10 +225,10 @@ class CertificateAuthority(object):
public_key = self.key.public_key() public_key = self.key.public_key()
builder = x509.CertificateBuilder() builder = x509.CertificateBuilder()
builder = builder.subject_name(x509.Name([ builder = builder.subject_name(x509.Name([
x509.NameAttribute(NameOID.COMMON_NAME, unicode(common_name)), x509.NameAttribute(NameOID.COMMON_NAME, six.text_type(common_name)),
])) ]))
builder = builder.issuer_name(x509.Name([ builder = builder.issuer_name(x509.Name([
x509.NameAttribute(NameOID.COMMON_NAME, unicode(common_name)), x509.NameAttribute(NameOID.COMMON_NAME, six.text_type(common_name)),
])) ]))
builder = builder.not_valid_before( builder = builder.not_valid_before(
datetime.datetime.utcnow() - datetime.timedelta(days=2)) datetime.datetime.utcnow() - datetime.timedelta(days=2))
...@@ -591,7 +594,7 @@ class TestHandler(BaseHTTPRequestHandler): ...@@ -591,7 +594,7 @@ class TestHandler(BaseHTTPRequestHandler):
if compress: if compress:
self.send_header('Content-Encoding', 'gzip') self.send_header('Content-Encoding', 'gzip')
out = StringIO.StringIO() out = StringIO()
# compress with level 0, to find out if in the middle someting would # compress with level 0, to find out if in the middle someting would
# like to alter the compression # like to alter the compression
with gzip.GzipFile(fileobj=out, mode="w", compresslevel=0) as f: with gzip.GzipFile(fileobj=out, mode="w", compresslevel=0) as f:
...@@ -700,7 +703,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -700,7 +703,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
master_parameter_dict = self.parseConnectionParameterDict() master_parameter_dict = self.parseConnectionParameterDict()
caucase_url = master_parameter_dict['backend-client-caucase-url'] caucase_url = master_parameter_dict['backend-client-caucase-url']
ca_certificate = requests.get(caucase_url + '/cas/crt/ca.crt.pem') ca_certificate = requests.get(caucase_url + '/cas/crt/ca.crt.pem')
assert ca_certificate.status_code == httplib.OK assert ca_certificate.status_code == six.moves.http_client.OK
ca_certificate_file = os.path.join( ca_certificate_file = os.path.join(
self.working_directory, 'ca-backend-client.crt.pem') self.working_directory, 'ca-backend-client.crt.pem')
with open(ca_certificate_file, 'w') as fh: with open(ca_certificate_file, 'w') as fh:
...@@ -746,18 +749,18 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -746,18 +749,18 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict() parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict()
ca_certificate = requests.get( ca_certificate = requests.get(
parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem') parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem')
assert ca_certificate.status_code == httplib.OK assert ca_certificate.status_code == six.moves.http_client.OK
cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem') cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem')
open(cls.ca_certificate_file, 'w').write(ca_certificate.text) open(cls.ca_certificate_file, 'w').write(ca_certificate.text)
auth = requests.get( auth = requests.get(
parameter_dict['master-key-generate-auth-url'], parameter_dict['master-key-generate-auth-url'],
verify=cls.ca_certificate_file) verify=cls.ca_certificate_file)
assert auth.status_code == httplib.CREATED assert auth.status_code == six.moves.http_client.CREATED
upload = requests.put( upload = requests.put(
parameter_dict['master-key-upload-url'] + auth.text, parameter_dict['master-key-upload-url'] + auth.text,
data=cls.key_pem + cls.certificate_pem, data=cls.key_pem + cls.certificate_pem,
verify=cls.ca_certificate_file) verify=cls.ca_certificate_file)
assert upload.status_code == httplib.CREATED assert upload.status_code == six.moves.http_client.CREATED
cls.runKedifaUpdater() cls.runKedifaUpdater()
@classmethod @classmethod
...@@ -855,7 +858,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -855,7 +858,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
frontend, url = entry frontend, url = entry
result = requests.get(url, verify=False) result = requests.get(url, verify=False)
self.assertEqual( self.assertEqual(
httplib.OK, six.moves.http_client.OK,
result.status_code, result.status_code,
'While accessing %r of %r the status code was %r' % ( 'While accessing %r of %r the status code was %r' % (
url, frontend, result.status_code)) url, frontend, result.status_code))
...@@ -869,11 +872,11 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -869,11 +872,11 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
sorted([q['name'] for q in result.json()]), sorted([q['name'] for q in result.json()]),
['access.log', 'backend.log', 'error.log']) ['access.log', 'backend.log', 'error.log'])
self.assertEqual( self.assertEqual(
httplib.OK, six.moves.http_client.OK,
requests.get(url + 'access.log', verify=False).status_code requests.get(url + 'access.log', verify=False).status_code
) )
self.assertEqual( self.assertEqual(
httplib.OK, six.moves.http_client.OK,
requests.get(url + 'error.log', verify=False).status_code requests.get(url + 'error.log', verify=False).status_code
) )
# assert only for few tests, as backend log is not available for many of # assert only for few tests, as backend log is not available for many of
...@@ -882,7 +885,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -882,7 +885,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
'test_url', 'test_auth_to_backend', 'test_compressed_result']: 'test_url', 'test_auth_to_backend', 'test_compressed_result']:
if self.id().endswith(test_name): if self.id().endswith(test_name):
self.assertEqual( self.assertEqual(
httplib.OK, six.moves.http_client.OK,
requests.get(url + 'backend.log', verify=False).status_code requests.get(url + 'backend.log', verify=False).status_code
) )
...@@ -919,7 +922,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -919,7 +922,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
backend_haproxy_statistic_url_dict[key] = parameter_dict.pop(key) backend_haproxy_statistic_url_dict[key] = parameter_dict.pop(key)
self.assertEqual( self.assertEqual(
[url_key], [url_key],
backend_haproxy_statistic_url_dict.keys() list(backend_haproxy_statistic_url_dict.keys())
) )
backend_haproxy_statistic_url = backend_haproxy_statistic_url_dict[url_key] backend_haproxy_statistic_url = backend_haproxy_statistic_url_dict[url_key]
...@@ -927,7 +930,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase): ...@@ -927,7 +930,7 @@ class HttpFrontendTestCase(SlapOSInstanceTestCase):
backend_haproxy_statistic_url, backend_haproxy_statistic_url,
verify=False, verify=False,
) )
self.assertEqual(httplib.OK, result.status_code) self.assertEqual(six.moves.http_client.OK, result.status_code)
self.assertIn('testing partition 0', result.text) self.assertIn('testing partition 0', result.text)
self.assertIn('Statistics Report for HAProxy', result.text) self.assertIn('Statistics Report for HAProxy', result.text)
...@@ -1822,12 +1825,12 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -1822,12 +1825,12 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.SERVICE_UNAVAILABLE, result.status_code) self.assertEqual(six.moves.http_client.SERVICE_UNAVAILABLE, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -1839,7 +1842,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -1839,7 +1842,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# check that 404 is as configured # check that 404 is as configured
result_missing = fakeHTTPSResult( result_missing = fakeHTTPSResult(
'forsuredoesnotexists.example.com', '') 'forsuredoesnotexists.example.com', '')
self.assertEqual(httplib.NOT_FOUND, result_missing.status_code) self.assertEqual(six.moves.http_client.NOT_FOUND, result_missing.status_code)
self.assertEqual( self.assertEqual(
"""<html> """<html>
<head> <head>
...@@ -1984,7 +1987,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -1984,7 +1987,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -2103,7 +2106,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2103,7 +2106,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.assertEqual( self.assertEqual(
result.status_code, result.status_code,
httplib.BAD_GATEWAY six.moves.http_client.BAD_GATEWAY
) )
finally: finally:
self.stopAuthenticatedServerProcess() self.stopAuthenticatedServerProcess()
...@@ -2145,7 +2148,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2145,7 +2148,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -2310,7 +2313,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2310,7 +2313,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual( self.assertEqual(
httplib.MOVED_PERMANENTLY, six.moves.http_client.MOVED_PERMANENTLY,
result.status_code result.status_code
) )
...@@ -2520,7 +2523,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2520,7 +2523,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = self.customdomain_ca_certificate_pem + \ data = self.customdomain_ca_certificate_pem + \
self.customdomain_ca_key_pem + \ self.customdomain_ca_key_pem + \
...@@ -2530,7 +2533,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2530,7 +2533,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
upload_url + auth.text, upload_url + auth.text,
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
result = fakeHTTPSResult( result = fakeHTTPSResult(
...@@ -2570,7 +2573,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2570,7 +2573,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = self.ca.certificate_pem data = self.ca.certificate_pem
...@@ -2579,7 +2582,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2579,7 +2582,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.UNPROCESSABLE_ENTITY, upload.status_code) self.assertEqual(six.moves.http_client.UNPROCESSABLE_ENTITY, upload.status_code)
self.assertEqual('Key incorrect', upload.text) self.assertEqual('Key incorrect', upload.text)
def test_ssl_ca_crt_garbage(self): def test_ssl_ca_crt_garbage(self):
...@@ -2603,7 +2606,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2603,7 +2606,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
_, ca_key_pem, csr, _ = createCSR( _, ca_key_pem, csr, _ = createCSR(
parameter_dict['domain']) parameter_dict['domain'])
...@@ -2615,7 +2618,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2615,7 +2618,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
result = fakeHTTPSResult( result = fakeHTTPSResult(
...@@ -2656,7 +2659,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2656,7 +2659,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = self.certificate_pem + self.key_pem + self.ca.certificate_pem data = self.certificate_pem + self.key_pem + self.ca.certificate_pem
...@@ -2665,7 +2668,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2665,7 +2668,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
result = fakeHTTPSResult( result = fakeHTTPSResult(
...@@ -2817,14 +2820,14 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2817,14 +2820,14 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = self.customdomain_certificate_pem + \ data = self.customdomain_certificate_pem + \
self.customdomain_key_pem self.customdomain_key_pem
upload = requests.put( upload = requests.put(
upload_url + auth.text, upload_url + auth.text,
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
result = fakeHTTPSResult( result = fakeHTTPSResult(
...@@ -2865,7 +2868,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2865,7 +2868,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -2984,7 +2987,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -2984,7 +2987,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -3025,7 +3028,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3025,7 +3028,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
headers={'Accept-Encoding': 'gzip, deflate'}) headers={'Accept-Encoding': 'gzip, deflate'})
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -3160,7 +3163,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3160,7 +3163,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
j = result.json() j = result.json()
except Exception: except Exception:
raise ValueError('JSON decode problem in:\n%s' % (result.text,)) raise ValueError('JSON decode problem in:\n%s' % (result.text,))
parsed = urlparse.urlparse(self.backend_url) parsed = six.moves.urllib.parse.urlparse(self.backend_url)
self.assertBackendHeaders( self.assertBackendHeaders(
j['Incoming Headers'], parsed.hostname, port='17', proto='irc', j['Incoming Headers'], parsed.hostname, port='17', proto='irc',
ignore_header_list=['Host']) ignore_header_list=['Host'])
...@@ -3266,7 +3269,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3266,7 +3269,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
j = result.json() j = result.json()
except Exception: except Exception:
raise ValueError('JSON decode problem in:\n%s' % (result.text,)) raise ValueError('JSON decode problem in:\n%s' % (result.text,))
parsed = urlparse.urlparse(self.backend_url) parsed = six.moves.urllib.parse.urlparse(self.backend_url)
self.assertBackendHeaders( self.assertBackendHeaders(
j['Incoming Headers'], parsed.hostname, port='17', proto='irc', j['Incoming Headers'], parsed.hostname, port='17', proto='irc',
ignore_header_list=['Host']) ignore_header_list=['Host'])
...@@ -3332,7 +3335,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3332,7 +3335,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -3368,7 +3371,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3368,7 +3371,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -3405,7 +3408,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3405,7 +3408,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual( self.assertEqual(
httplib.SERVICE_UNAVAILABLE, six.moves.http_client.SERVICE_UNAVAILABLE,
result.status_code result.status_code
) )
...@@ -3413,7 +3416,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3413,7 +3416,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -3452,7 +3455,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3452,7 +3455,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -3473,7 +3476,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3473,7 +3476,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual( self.assertEqual(
httplib.SERVICE_UNAVAILABLE, six.moves.http_client.SERVICE_UNAVAILABLE,
result.status_code result.status_code
) )
...@@ -3487,12 +3490,12 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3487,12 +3490,12 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.SERVICE_UNAVAILABLE, result.status_code) self.assertEqual(six.moves.http_client.SERVICE_UNAVAILABLE, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -3524,12 +3527,12 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3524,12 +3527,12 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.SERVICE_UNAVAILABLE, result.status_code) self.assertEqual(six.moves.http_client.SERVICE_UNAVAILABLE, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -3562,13 +3565,13 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3562,13 +3565,13 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.SERVICE_UNAVAILABLE, result.status_code) self.assertEqual(six.moves.http_client.SERVICE_UNAVAILABLE, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -3691,7 +3694,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3691,7 +3694,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'X-Reply-Header-Cache-Control': 'max-age=1, stale-while-' 'X-Reply-Header-Cache-Control': 'max-age=1, stale-while-'
'revalidate=3600, stale-if-error=3600'}) 'revalidate=3600, stale-if-error=3600'})
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -3740,7 +3743,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3740,7 +3743,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'X-Reply-Header-Cache-Control': 'max-age=1, stale-while-' 'X-Reply-Header-Cache-Control': 'max-age=1, stale-while-'
'revalidate=3600, stale-if-error=3600'}) 'revalidate=3600, stale-if-error=3600'})
self.assertEqual(httplib.OK, result.status_code) self.assertEqual(six.moves.http_client.OK, result.status_code)
self.assertEqualResultJson(result, 'Path', '/HTTPS/test') self.assertEqualResultJson(result, 'Path', '/HTTPS/test')
headers = result.headers.copy() headers = result.headers.copy()
...@@ -3751,7 +3754,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3751,7 +3754,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'X-Reply-Header-Cache-Control': 'max-age=1, stale-while-' 'X-Reply-Header-Cache-Control': 'max-age=1, stale-while-'
'revalidate=3600, stale-if-error=3600'}) 'revalidate=3600, stale-if-error=3600'})
self.assertEqual(httplib.OK, result.status_code) self.assertEqual(six.moves.http_client.OK, result.status_code)
self.assertEqualResultJson(result, 'Path', '/HTTP/test') self.assertEqualResultJson(result, 'Path', '/HTTP/test')
headers = result.headers.copy() headers = result.headers.copy()
...@@ -3911,7 +3914,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3911,7 +3914,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# https://github.com/apache/trafficserver/issues/7880 # https://github.com/apache/trafficserver/issues/7880
'X-Drop-Header': 'Content-Length', 'X-Drop-Header': 'Content-Length',
}) })
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, six.moves.http_client.CREATED)
def checkResult(status_code, body): def checkResult(status_code, body):
result = fakeHTTPSResult( result = fakeHTTPSResult(
...@@ -3923,39 +3926,39 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -3923,39 +3926,39 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# backend returns something correctly # backend returns something correctly
configureResult('200', body_200) configureResult('200', body_200)
checkResult(httplib.OK, body_200) checkResult(six.moves.http_client.OK, body_200)
configureResult('502', body_502) configureResult('502', body_502)
time.sleep(1) time.sleep(1)
# even if backend returns 502, ATS gives cached result # even if backend returns 502, ATS gives cached result
checkResult(httplib.OK, body_200) checkResult(six.moves.http_client.OK, body_200)
# interesting moment, time is between max_age and max_stale_age, triggers # interesting moment, time is between max_age and max_stale_age, triggers
# https://github.com/apache/trafficserver/issues/7880 # https://github.com/apache/trafficserver/issues/7880
time.sleep(max_age + 1) time.sleep(max_age + 1)
checkResult(httplib.OK, body_200) checkResult(six.moves.http_client.OK, body_200)
# max_stale_age passed, time to return 502 from the backend # max_stale_age passed, time to return 502 from the backend
time.sleep(max_stale_age + 2) time.sleep(max_stale_age + 2)
checkResult(httplib.BAD_GATEWAY, body_502) checkResult(six.moves.http_client.BAD_GATEWAY, body_502)
configureResult('502', body_502_new) configureResult('502', body_502_new)
time.sleep(1) time.sleep(1)
# even if there is new negative response on the backend, the old one is # even if there is new negative response on the backend, the old one is
# served from the cache # served from the cache
checkResult(httplib.BAD_GATEWAY, body_502) checkResult(six.moves.http_client.BAD_GATEWAY, body_502)
time.sleep(max_age + 2) time.sleep(max_age + 2)
# now as max-age of negative response passed, the new one is served # now as max-age of negative response passed, the new one is served
checkResult(httplib.BAD_GATEWAY, body_502_new) checkResult(six.moves.http_client.BAD_GATEWAY, body_502_new)
configureResult('200', body_200_new) configureResult('200', body_200_new)
time.sleep(1) time.sleep(1)
checkResult(httplib.BAD_GATEWAY, body_502_new) checkResult(six.moves.http_client.BAD_GATEWAY, body_502_new)
time.sleep(max_age + 2) time.sleep(max_age + 2)
# backend is back to normal, as soon as negative response max-age passed # backend is back to normal, as soon as negative response max-age passed
# the new response is served # the new response is served
checkResult(httplib.OK, body_200_new) checkResult(six.moves.http_client.OK, body_200_new)
@skip('Feature postponed') @skip('Feature postponed')
def test_enable_cache_stale_if_error_respected(self): def test_enable_cache_stale_if_error_respected(self):
...@@ -4020,7 +4023,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4020,7 +4023,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
}, },
source_ip=source_ip source_ip=source_ip
) )
self.assertEqual(result.status_code, httplib.BAD_GATEWAY) self.assertEqual(result.status_code, six.moves.http_client.BAD_GATEWAY)
finally: finally:
self.startServerProcess() self.startServerProcess()
# END: check stale-if-error support # END: check stale-if-error support
...@@ -4038,7 +4041,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4038,7 +4041,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
# ATS timed out # ATS timed out
self.assertEqual( self.assertEqual(
httplib.GATEWAY_TIMEOUT, six.moves.http_client.GATEWAY_TIMEOUT,
result.status_code result.status_code
) )
...@@ -4151,7 +4154,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4151,7 +4154,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
j = result.json() j = result.json()
except Exception: except Exception:
raise ValueError('JSON decode problem in:\n%s' % (result.text,)) raise ValueError('JSON decode problem in:\n%s' % (result.text,))
self.assertFalse('pragma' in j['Incoming Headers'].keys()) self.assertFalse('pragma' in list(j['Incoming Headers'].keys()))
def test_enable_cache_disable_via_header(self): def test_enable_cache_disable_via_header(self):
parameter_dict = self.assertSlaveBase('enable_cache-disable-via-header') parameter_dict = self.assertSlaveBase('enable_cache-disable-via-header')
...@@ -4402,7 +4405,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4402,7 +4405,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
headers={'Accept-Encoding': 'gzip, deflate'}) headers={'Accept-Encoding': 'gzip, deflate'})
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -4417,7 +4420,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4417,7 +4420,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
headers={'Accept-Encoding': 'deflate'}) headers={'Accept-Encoding': 'deflate'})
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -4431,7 +4434,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4431,7 +4434,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -4445,7 +4448,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4445,7 +4448,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result.status_code result.status_code
) )
...@@ -4498,7 +4501,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4498,7 +4501,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin):
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
self.assertEqual( self.assertEqual(
httplib.FOUND, six.moves.http_client.FOUND,
result_http.status_code result_http.status_code
) )
...@@ -4605,7 +4608,7 @@ class TestReplicateSlave(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -4605,7 +4608,7 @@ class TestReplicateSlave(SlaveHttpFrontendTestCase, TestDataMixin):
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual(httplib.FOUND, result_http.status_code) self.assertEqual(six.moves.http_client.FOUND, result_http.status_code)
# prove 2nd frontend by inspection of the instance # prove 2nd frontend by inspection of the instance
slave_configuration_name = '_replicate.conf' slave_configuration_name = '_replicate.conf'
...@@ -5133,7 +5136,7 @@ class TestSlaveSlapOSMasterCertificateCompatibilityOverrideMaster( ...@@ -5133,7 +5136,7 @@ class TestSlaveSlapOSMasterCertificateCompatibilityOverrideMaster(
parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict() parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict()
ca_certificate = requests.get( ca_certificate = requests.get(
parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem') parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem')
assert ca_certificate.status_code == httplib.OK assert ca_certificate.status_code == six.moves.http_client.OK
cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem') cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem')
open(cls.ca_certificate_file, 'w').write(ca_certificate.text) open(cls.ca_certificate_file, 'w').write(ca_certificate.text)
# Do not upload certificates for the master partition # Do not upload certificates for the master partition
...@@ -5223,7 +5226,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5223,7 +5226,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict() parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict()
ca_certificate = requests.get( ca_certificate = requests.get(
parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem') parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem')
assert ca_certificate.status_code == httplib.OK assert ca_certificate.status_code == six.moves.http_client.OK
cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem') cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem')
open(cls.ca_certificate_file, 'w').write(ca_certificate.text) open(cls.ca_certificate_file, 'w').write(ca_certificate.text)
# Do not upload certificates for the master partition # Do not upload certificates for the master partition
...@@ -5488,7 +5491,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5488,7 +5491,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = certificate_pem + key_pem data = certificate_pem + key_pem
...@@ -5496,7 +5499,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5496,7 +5499,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
upload_url + auth.text, upload_url + auth.text,
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
result = fakeHTTPSResult( result = fakeHTTPSResult(
...@@ -5579,7 +5582,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5579,7 +5582,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = certificate_pem + key_pem data = certificate_pem + key_pem
...@@ -5587,7 +5590,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5587,7 +5590,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
upload_url + auth.text, upload_url + auth.text,
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
...@@ -5663,7 +5666,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5663,7 +5666,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = certificate_pem + key_pem data = certificate_pem + key_pem
...@@ -5671,7 +5674,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5671,7 +5674,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
upload_url + auth.text, upload_url + auth.text,
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
...@@ -5756,7 +5759,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5756,7 +5759,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
auth = requests.get( auth = requests.get(
generate_auth, generate_auth,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, auth.status_code) self.assertEqual(six.moves.http_client.CREATED, auth.status_code)
data = certificate_pem + key_pem data = certificate_pem + key_pem
...@@ -5764,7 +5767,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility( ...@@ -5764,7 +5767,7 @@ class TestSlaveSlapOSMasterCertificateCompatibility(
upload_url + auth.text, upload_url + auth.text,
data=data, data=data,
verify=self.ca_certificate_file) verify=self.ca_certificate_file)
self.assertEqual(httplib.CREATED, upload.status_code) self.assertEqual(six.moves.http_client.CREATED, upload.status_code)
self.runKedifaUpdater() self.runKedifaUpdater()
...@@ -5983,7 +5986,7 @@ class TestSlaveSlapOSMasterCertificateCompatibilityUpdate( ...@@ -5983,7 +5986,7 @@ class TestSlaveSlapOSMasterCertificateCompatibilityUpdate(
parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict() parameter_dict = cls.requestDefaultInstance().getConnectionParameterDict()
ca_certificate = requests.get( ca_certificate = requests.get(
parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem') parameter_dict['kedifa-caucase-url'] + '/cas/crt/ca.crt.pem')
assert ca_certificate.status_code == httplib.OK assert ca_certificate.status_code == six.moves.http_client.OK
cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem') cls.ca_certificate_file = os.path.join(cls.working_directory, 'ca.crt.pem')
open(cls.ca_certificate_file, 'w').write(ca_certificate.text) open(cls.ca_certificate_file, 'w').write(ca_certificate.text)
# Do not upload certificates for the master partition # Do not upload certificates for the master partition
...@@ -6152,11 +6155,11 @@ class TestSlaveCiphers(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -6152,11 +6155,11 @@ class TestSlaveCiphers(SlaveHttpFrontendTestCase, TestDataMixin):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.OK, result.status_code) self.assertEqual(six.moves.http_client.OK, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual(httplib.FOUND, result_http.status_code) self.assertEqual(six.moves.http_client.FOUND, result_http.status_code)
configuration_file = glob.glob( configuration_file = glob.glob(
os.path.join( os.path.join(
...@@ -6178,11 +6181,11 @@ class TestSlaveCiphers(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -6178,11 +6181,11 @@ class TestSlaveCiphers(SlaveHttpFrontendTestCase, TestDataMixin):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.OK, result.status_code) self.assertEqual(six.moves.http_client.OK, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual(httplib.FOUND, result_http.status_code) self.assertEqual(six.moves.http_client.FOUND, result_http.status_code)
configuration_file = glob.glob( configuration_file = glob.glob(
os.path.join( os.path.join(
...@@ -6645,7 +6648,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase): ...@@ -6645,7 +6648,7 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual( self.assertEqual(
httplib.MOVED_PERMANENTLY, six.moves.http_client.MOVED_PERMANENTLY,
result.status_code result.status_code
) )
...@@ -6678,11 +6681,11 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase): ...@@ -6678,11 +6681,11 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.SERVICE_UNAVAILABLE, result.status_code) self.assertEqual(six.moves.http_client.SERVICE_UNAVAILABLE, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual(httplib.FOUND, result_http.status_code) self.assertEqual(six.moves.http_client.FOUND, result_http.status_code)
monitor_file = glob.glob( monitor_file = glob.glob(
os.path.join( os.path.join(
...@@ -6722,11 +6725,11 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase): ...@@ -6722,11 +6725,11 @@ class TestSlaveRejectReportUnsafeDamaged(SlaveHttpFrontendTestCase):
self.certificate_pem, self.certificate_pem,
der2pem(result.peercert)) der2pem(result.peercert))
self.assertEqual(httplib.SERVICE_UNAVAILABLE, result.status_code) self.assertEqual(six.moves.http_client.SERVICE_UNAVAILABLE, result.status_code)
result_http = fakeHTTPResult( result_http = fakeHTTPResult(
parameter_dict['domain'], 'test-path') parameter_dict['domain'], 'test-path')
self.assertEqual(httplib.FOUND, result_http.status_code) self.assertEqual(six.moves.http_client.FOUND, result_http.status_code)
monitor_file = glob.glob( monitor_file = glob.glob(
os.path.join( os.path.join(
...@@ -7053,8 +7056,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase): ...@@ -7053,8 +7056,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase):
expected_partition_parameter_dict_dict = { expected_partition_parameter_dict_dict = {
'caddy-frontend-1': { 'caddy-frontend-1': {
'X-software_release_url': base_software_url, 'X-software_release_url': base_software_url,
u'apache-certificate': unicode(self.certificate_pem), u'apache-certificate': six.text_type(self.certificate_pem),
u'apache-key': unicode(self.key_pem), u'apache-key': six.text_type(self.key_pem),
u'authenticate-to-backend': u'True', u'authenticate-to-backend': u'True',
u'backend-client-caucase-url': backend_client_caucase_url, u'backend-client-caucase-url': backend_client_caucase_url,
u'backend-connect-retries': u'1', u'backend-connect-retries': u'1',
...@@ -7080,8 +7083,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase): ...@@ -7080,8 +7083,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase):
}, },
'caddy-frontend-2': { 'caddy-frontend-2': {
'X-software_release_url': self.frontend_2_sr, 'X-software_release_url': self.frontend_2_sr,
u'apache-certificate': unicode(self.certificate_pem), u'apache-certificate': six.text_type(self.certificate_pem),
u'apache-key': unicode(self.key_pem), u'apache-key': six.text_type(self.key_pem),
u'authenticate-to-backend': u'True', u'authenticate-to-backend': u'True',
u'backend-client-caucase-url': backend_client_caucase_url, u'backend-client-caucase-url': backend_client_caucase_url,
u'backend-connect-retries': u'1', u'backend-connect-retries': u'1',
...@@ -7107,8 +7110,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase): ...@@ -7107,8 +7110,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase):
}, },
'caddy-frontend-3': { 'caddy-frontend-3': {
'X-software_release_url': self.frontend_3_sr, 'X-software_release_url': self.frontend_3_sr,
u'apache-certificate': unicode(self.certificate_pem), u'apache-certificate': six.text_type(self.certificate_pem),
u'apache-key': unicode(self.key_pem), u'apache-key': six.text_type(self.key_pem),
u'authenticate-to-backend': u'True', u'authenticate-to-backend': u'True',
u'backend-client-caucase-url': backend_client_caucase_url, u'backend-client-caucase-url': backend_client_caucase_url,
u'backend-connect-retries': u'1', u'backend-connect-retries': u'1',
...@@ -7153,8 +7156,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase): ...@@ -7153,8 +7156,8 @@ class TestPassedRequestParameter(HttpFrontendTestCase):
'-sla-2-computer_guid': 'local', '-sla-2-computer_guid': 'local',
'-sla-3-computer_guid': 'local', '-sla-3-computer_guid': 'local',
'X-software_release_url': base_software_url, 'X-software_release_url': base_software_url,
'apache-certificate': unicode(self.certificate_pem), 'apache-certificate': six.text_type(self.certificate_pem),
'apache-key': unicode(self.key_pem), 'apache-key': six.text_type(self.key_pem),
'authenticate-to-backend': 'True', 'authenticate-to-backend': 'True',
'automatic-internal-backend-client-caucase-csr': 'False', 'automatic-internal-backend-client-caucase-csr': 'False',
'automatic-internal-kedifa-caucase-csr': 'False', 'automatic-internal-kedifa-caucase-csr': 'False',
...@@ -7306,7 +7309,7 @@ class TestSlaveHealthCheck(SlaveHttpFrontendTestCase, TestDataMixin): ...@@ -7306,7 +7309,7 @@ class TestSlaveHealthCheck(SlaveHttpFrontendTestCase, TestDataMixin):
@classmethod @classmethod
def setUpAssertionDict(cls): def setUpAssertionDict(cls):
backend = urlparse.urlparse(cls.backend_url).netloc backend = six.moves.urllib.parse.urlparse(cls.backend_url).netloc
cls.assertion_dict = { cls.assertion_dict = {
'health-check-disabled': """\ 'health-check-disabled': """\
backend _health-check-disabled-http backend _health-check-disabled-http
...@@ -7391,7 +7394,7 @@ backend _health-check-default-http ...@@ -7391,7 +7394,7 @@ backend _health-check-default-http
self.backend_url + slave_parameter_dict[ self.backend_url + slave_parameter_dict[
'health-check-http-path'].strip('/'), 'health-check-http-path'].strip('/'),
headers={'X-Reply-Status-Code': '502'}) headers={'X-Reply-Status-Code': '502'})
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, six.moves.http_client.CREATED)
def restoreBackend(): def restoreBackend():
result = requests.put( result = requests.put(
...@@ -7498,7 +7501,7 @@ backend _health-check-default-http ...@@ -7498,7 +7501,7 @@ backend _health-check-default-http
self.backend_url + slave_parameter_dict[ self.backend_url + slave_parameter_dict[
'health-check-http-path'].strip('/'), 'health-check-http-path'].strip('/'),
headers={'X-Reply-Status-Code': '502'}) headers={'X-Reply-Status-Code': '502'})
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, six.moves.http_client.CREATED)
time.sleep(3) # > health-check-timeout + health-check-interval time.sleep(3) # > health-check-timeout + health-check-interval
...@@ -7531,7 +7534,7 @@ backend _health-check-default-http ...@@ -7531,7 +7534,7 @@ backend _health-check-default-http
self.backend_url + slave_parameter_dict[ self.backend_url + slave_parameter_dict[
'health-check-http-path'].strip('/'), 'health-check-http-path'].strip('/'),
headers={'X-Reply-Status-Code': '502'}) headers={'X-Reply-Status-Code': '502'})
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, six.moves.http_client.CREATED)
time.sleep(3) # > health-check-timeout + health-check-interval time.sleep(3) # > health-check-timeout + health-check-interval
...@@ -7560,7 +7563,7 @@ backend _health-check-default-http ...@@ -7560,7 +7563,7 @@ backend _health-check-default-http
self.backend_url + slave_parameter_dict[ self.backend_url + slave_parameter_dict[
'health-check-http-path'].strip('/'), 'health-check-http-path'].strip('/'),
headers={'X-Reply-Status-Code': '502'}) headers={'X-Reply-Status-Code': '502'})
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, six.moves.http_client.CREATED)
time.sleep(3) # > health-check-timeout + health-check-interval time.sleep(3) # > health-check-timeout + health-check-interval
...@@ -7572,7 +7575,7 @@ backend _health-check-default-http ...@@ -7572,7 +7575,7 @@ backend _health-check-default-http
der2pem(result.peercert)) der2pem(result.peercert))
# as ssl proxy verification failed, service is unavailable # as ssl proxy verification failed, service is unavailable
self.assertEqual(result.status_code, httplib.SERVICE_UNAVAILABLE) self.assertEqual(result.status_code, six.moves.http_client.SERVICE_UNAVAILABLE)
def test_health_check_failover_url_ssl_proxy_missing(self): def test_health_check_failover_url_ssl_proxy_missing(self):
parameter_dict = self.assertSlaveBase( parameter_dict = self.assertSlaveBase(
...@@ -7590,7 +7593,7 @@ backend _health-check-default-http ...@@ -7590,7 +7593,7 @@ backend _health-check-default-http
self.backend_url + slave_parameter_dict[ self.backend_url + slave_parameter_dict[
'health-check-http-path'].strip('/'), 'health-check-http-path'].strip('/'),
headers={'X-Reply-Status-Code': '502'}) headers={'X-Reply-Status-Code': '502'})
self.assertEqual(result.status_code, httplib.CREATED) self.assertEqual(result.status_code, six.moves.http_client.CREATED)
time.sleep(3) # > health-check-timeout + health-check-interval time.sleep(3) # > health-check-timeout + health-check-interval
...@@ -7602,7 +7605,7 @@ backend _health-check-default-http ...@@ -7602,7 +7605,7 @@ backend _health-check-default-http
der2pem(result.peercert)) der2pem(result.peercert))
# as ssl proxy verification failed, service is unavailable # as ssl proxy verification failed, service is unavailable
self.assertEqual(result.status_code, httplib.SERVICE_UNAVAILABLE) self.assertEqual(result.status_code, six.moves.http_client.SERVICE_UNAVAILABLE)
if __name__ == '__main__': if __name__ == '__main__':
...@@ -7617,5 +7620,5 @@ if __name__ == '__main__': ...@@ -7617,5 +7620,5 @@ if __name__ == '__main__':
url_template = 'http://%s:%s/' url_template = 'http://%s:%s/'
server = klass((ip, port), TestHandler) server = klass((ip, port), TestHandler)
print url_template % server.server_address[:2] print(url_template % server.server_address[:2])
server.serve_forever() server.serve_forever()
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
# #
############################################################################## ##############################################################################
from __future__ import absolute_import
import json import json
import os import os
......
from __future__ import absolute_import
import glob import glob
import hashlib import hashlib
import json import json
...@@ -8,9 +9,9 @@ import shutil ...@@ -8,9 +9,9 @@ import shutil
import subprocess import subprocess
import tempfile import tempfile
import time import time
import urllib import six.moves.urllib.request, six.moves.urllib.parse, six.moves.urllib.error
import urlparse import six.moves.urllib.parse
from BaseHTTPServer import BaseHTTPRequestHandler from six.moves.BaseHTTPServer import BaseHTTPRequestHandler
from typing import Dict from typing import Dict
import mock import mock
...@@ -28,6 +29,7 @@ from slapos.testing.utils import (CrontabMixin, ManagedHTTPServer, ...@@ -28,6 +29,7 @@ from slapos.testing.utils import (CrontabMixin, ManagedHTTPServer,
findFreeTCPPort) findFreeTCPPort)
from . import ERP5InstanceTestCase, setUpModule from . import ERP5InstanceTestCase, setUpModule
from six.moves import range
setUpModule # pyflakes setUpModule # pyflakes
...@@ -214,7 +216,7 @@ class TestLog(BalancerTestCase, CrontabMixin): ...@@ -214,7 +216,7 @@ class TestLog(BalancerTestCase, CrontabMixin):
def test_access_log_format(self): def test_access_log_format(self):
# type: () -> None # type: () -> None
requests.get( requests.get(
urlparse.urljoin(self.default_balancer_url, '/url_path'), six.moves.urllib.parse.urljoin(self.default_balancer_url, '/url_path'),
verify=False, verify=False,
) )
time.sleep(.5) # wait a bit more until access is logged time.sleep(.5) # wait a bit more until access is logged
...@@ -373,7 +375,7 @@ class TestBalancer(BalancerTestCase): ...@@ -373,7 +375,7 @@ class TestBalancer(BalancerTestCase):
# if backend provides a "SERVERID" cookie, balancer will overwrite it with the # if backend provides a "SERVERID" cookie, balancer will overwrite it with the
# backend selected by balancing algorithm # backend selected by balancing algorithm
self.assertIn( self.assertIn(
requests.get(urlparse.urljoin(self.default_balancer_url, '/set_cookie'), verify=False).cookies['SERVERID'], requests.get(six.moves.urllib.parse.urljoin(self.default_balancer_url, '/set_cookie'), verify=False).cookies['SERVERID'],
('default-0', 'default-1'), ('default-0', 'default-1'),
) )
...@@ -427,18 +429,18 @@ class TestTestRunnerEntryPoints(BalancerTestCase): ...@@ -427,18 +429,18 @@ class TestTestRunnerEntryPoints(BalancerTestCase):
)['default-test-runner-url-list'] )['default-test-runner-url-list']
url_0, url_1, url_2 = test_runner_url_list url_0, url_1, url_2 = test_runner_url_list
self.assertEqual( self.assertEqual(
urlparse.urlparse(url_0).netloc, six.moves.urllib.parse.urlparse(url_0).netloc,
urlparse.urlparse(url_1).netloc) six.moves.urllib.parse.urlparse(url_1).netloc)
self.assertEqual( self.assertEqual(
urlparse.urlparse(url_0).netloc, six.moves.urllib.parse.urlparse(url_0).netloc,
urlparse.urlparse(url_2).netloc) six.moves.urllib.parse.urlparse(url_2).netloc)
path_0 = '/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_0/something'.format( path_0 = '/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_0/something'.format(
netloc=urlparse.urlparse(url_0).netloc) netloc=six.moves.urllib.parse.urlparse(url_0).netloc)
path_1 = '/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_1/something'.format( path_1 = '/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_1/something'.format(
netloc=urlparse.urlparse(url_0).netloc) netloc=six.moves.urllib.parse.urlparse(url_0).netloc)
path_2 = '/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_2/something'.format( path_2 = '/VirtualHostBase/https/{netloc}/VirtualHostRoot/_vh_unit_test_2/something'.format(
netloc=urlparse.urlparse(url_0).netloc) netloc=six.moves.urllib.parse.urlparse(url_0).netloc)
self.assertEqual( self.assertEqual(
{ {
...@@ -516,7 +518,7 @@ class TestHTTP(BalancerTestCase): ...@@ -516,7 +518,7 @@ class TestHTTP(BalancerTestCase):
session.get(self.default_balancer_url).raise_for_status() session.get(self.default_balancer_url).raise_for_status()
new_conn.assert_not_called() new_conn.assert_not_called()
parsed_url = urlparse.urlparse(self.default_balancer_url) parsed_url = six.moves.urllib.parse.urlparse(self.default_balancer_url)
# check that we have an open file for the ip connection # check that we have an open file for the ip connection
self.assertTrue([ self.assertTrue([
c for c in psutil.Process(os.getpid()).connections() c for c in psutil.Process(os.getpid()).connections()
...@@ -588,7 +590,7 @@ class TestContentEncoding(BalancerTestCase): ...@@ -588,7 +590,7 @@ class TestContentEncoding(BalancerTestCase):
'application/x-font-opentype', 'application/x-font-opentype',
'application/wasm',): 'application/wasm',):
resp = requests.get( resp = requests.get(
urlparse.urljoin(self.default_balancer_url, content_type), six.moves.urllib.parse.urljoin(self.default_balancer_url, content_type),
verify=False, verify=False,
headers={"Accept-Encoding": "gzip, deflate",}) headers={"Accept-Encoding": "gzip, deflate",})
self.assertEqual(resp.headers['Content-Type'], content_type) self.assertEqual(resp.headers['Content-Type'], content_type)
...@@ -600,7 +602,7 @@ class TestContentEncoding(BalancerTestCase): ...@@ -600,7 +602,7 @@ class TestContentEncoding(BalancerTestCase):
def test_no_gzip_encoding(self): def test_no_gzip_encoding(self):
# type: () -> None # type: () -> None
resp = requests.get(urlparse.urljoin(self.default_balancer_url, '/image/png'), verify=False) resp = requests.get(six.moves.urllib.parse.urljoin(self.default_balancer_url, '/image/png'), verify=False)
self.assertNotIn('Content-Encoding', resp.headers) self.assertNotIn('Content-Encoding', resp.headers)
self.assertEqual(resp.text, 'OK') self.assertEqual(resp.text, 'OK')
......
...@@ -25,14 +25,15 @@ ...@@ -25,14 +25,15 @@
# #
############################################################################## ##############################################################################
from __future__ import absolute_import
import os import os
import json import json
import glob import glob
import urlparse import six.moves.urllib.parse
import socket import socket
import time import time
import re import re
import BaseHTTPServer import six.moves.BaseHTTPServer
import multiprocessing import multiprocessing
import subprocess import subprocess
...@@ -41,6 +42,9 @@ import requests ...@@ -41,6 +42,9 @@ import requests
from . import ERP5InstanceTestCase from . import ERP5InstanceTestCase
from . import setUpModule from . import setUpModule
import six
from six.moves import map
from six.moves import range
setUpModule # pyflakes setUpModule # pyflakes
...@@ -52,7 +56,7 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -52,7 +56,7 @@ class TestPublishedURLIsReachableMixin(object):
# We access ERP5 trough a "virtual host", which should make # We access ERP5 trough a "virtual host", which should make
# ERP5 produce URLs using https://virtual-host-name:1234/virtual_host_root # ERP5 produce URLs using https://virtual-host-name:1234/virtual_host_root
# as base. # as base.
virtual_host_url = urlparse.urljoin( virtual_host_url = six.moves.urllib.parse.urljoin(
base_url, base_url,
'/VirtualHostBase/https/virtual-host-name:1234/{}/VirtualHostRoot/_vh_virtual_host_root/' '/VirtualHostBase/https/virtual-host-name:1234/{}/VirtualHostRoot/_vh_virtual_host_root/'
.format(site_id)) .format(site_id))
...@@ -80,7 +84,7 @@ class TestPublishedURLIsReachableMixin(object): ...@@ -80,7 +84,7 @@ class TestPublishedURLIsReachableMixin(object):
# login page can be rendered and contain the text "ERP5" # login page can be rendered and contain the text "ERP5"
r = session.get( r = session.get(
urlparse.urljoin(base_url, '{}/login_form'.format(site_id)), six.moves.urllib.parse.urljoin(base_url, '{}/login_form'.format(site_id)),
verify=verify, verify=verify,
allow_redirects=False, allow_redirects=False,
) )
...@@ -172,7 +176,7 @@ class TestApacheBalancerPorts(ERP5InstanceTestCase): ...@@ -172,7 +176,7 @@ class TestApacheBalancerPorts(ERP5InstanceTestCase):
} }
def checkValidHTTPSURL(self, url): def checkValidHTTPSURL(self, url):
parsed = urlparse.urlparse(url) parsed = six.moves.urllib.parse.urlparse(url)
self.assertEqual(parsed.scheme, 'https') self.assertEqual(parsed.scheme, 'https')
self.assertTrue(parsed.hostname) self.assertTrue(parsed.hostname)
self.assertTrue(parsed.port) self.assertTrue(parsed.port)
...@@ -291,7 +295,7 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac ...@@ -291,7 +295,7 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
storage["storage"] = "root" storage["storage"] = "root"
storage["server"] = zeo_addr storage["server"] = zeo_addr
with open('%s/etc/zope-%s.conf' % (partition, zope)) as f: with open('%s/etc/zope-%s.conf' % (partition, zope)) as f:
conf = map(str.strip, f.readlines()) conf = list(map(str.strip, f.readlines()))
i = conf.index("<zodb_db root>") + 1 i = conf.index("<zodb_db root>") + 1
conf = iter(conf[i:conf.index("</zodb_db>", i)]) conf = iter(conf[i:conf.index("</zodb_db>", i)])
for line in conf: for line in conf:
...@@ -300,23 +304,23 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac ...@@ -300,23 +304,23 @@ class TestZopeNodeParameterOverride(ERP5InstanceTestCase, TestPublishedURLIsReac
if line == '</zeoclient>': if line == '</zeoclient>':
break break
checkParameter(line, storage) checkParameter(line, storage)
for k, v in storage.iteritems(): for k, v in six.iteritems(storage):
self.assertIsNone(v, k) self.assertIsNone(v, k)
del storage del storage
else: else:
checkParameter(line, zodb) checkParameter(line, zodb)
for k, v in zodb.iteritems(): for k, v in six.iteritems(zodb):
self.assertIsNone(v, k) self.assertIsNone(v, k)
partition = self.getComputerPartitionPath('zope-a') partition = self.getComputerPartitionPath('zope-a')
for zope in xrange(3): for zope in range(3):
checkConf({ checkConf({
"cache-size-bytes": "20MB", "cache-size-bytes": "20MB",
}, { }, {
"cache-size": "50MB", "cache-size": "50MB",
}) })
partition = self.getComputerPartitionPath('zope-bb') partition = self.getComputerPartitionPath('zope-bb')
for zope in xrange(5): for zope in range(5):
checkConf({ checkConf({
"cache-size-bytes": "500MB" if zope else 1<<20, "cache-size-bytes": "500MB" if zope else 1<<20,
}, { }, {
...@@ -336,7 +340,7 @@ def popenCommunicate(command_list, input_=None, **kwargs): ...@@ -336,7 +340,7 @@ def popenCommunicate(command_list, input_=None, **kwargs):
return result return result
class TestHandler(BaseHTTPServer.BaseHTTPRequestHandler): class TestHandler(six.moves.BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self): def do_GET(self):
self.send_response(200) self.send_response(200)
...@@ -464,7 +468,7 @@ class TestDeploymentScriptInstantiation(ERP5InstanceTestCase): ...@@ -464,7 +468,7 @@ class TestDeploymentScriptInstantiation(ERP5InstanceTestCase):
ip, port = re.search( ip, port = re.search(
r'.*http:\/\/(.*):(\d*)\/.*', portal_slap_line).groups() r'.*http:\/\/(.*):(\d*)\/.*', portal_slap_line).groups()
port = int(port) port = int(port)
server = BaseHTTPServer.HTTPServer((ip, port), TestHandler) server = six.moves.BaseHTTPServer.HTTPServer((ip, port), TestHandler)
server_process = multiprocessing.Process( server_process = multiprocessing.Process(
target=server.serve_forever, name='HTTPServer') target=server.serve_forever, name='HTTPServer')
server_process.start() server_process.start()
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
# #
############################################################################## ##############################################################################
from __future__ import absolute_import
import os import os
import json import json
import glob import glob
import urlparse import six.moves.urllib.parse
import socket import socket
import sys import sys
import time import time
...@@ -80,7 +81,7 @@ class MariaDBTestCase(ERP5InstanceTestCase): ...@@ -80,7 +81,7 @@ class MariaDBTestCase(ERP5InstanceTestCase):
def getDatabaseConnection(self): def getDatabaseConnection(self):
connection_parameter_dict = json.loads( connection_parameter_dict = json.loads(
self.computer_partition.getConnectionParameterDict()['_']) self.computer_partition.getConnectionParameterDict()['_'])
db_url = urlparse.urlparse(connection_parameter_dict['database-list'][0]) db_url = six.moves.urllib.parse.urlparse(connection_parameter_dict['database-list'][0])
self.assertEqual('mysql', db_url.scheme) self.assertEqual('mysql', db_url.scheme)
self.assertTrue(db_url.path.startswith('/')) self.assertTrue(db_url.path.startswith('/'))
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
# See COPYING file for full licensing terms. # See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options. # See https://www.nexedi.com/licensing for rationale and options.
from __future__ import absolute_import
import json import json
import os.path import os.path
import unittest import unittest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment