Commit bdce9049 authored by Aurel's avatar Aurel

futurize: stage2

parent ae0c991a
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
"""Git implementation of _version.py.""" """Git implementation of _version.py."""
from __future__ import print_function from __future__ import print_function
from builtins import str
from builtins import range
from builtins import object
import errno import errno
import os import os
import re import re
...@@ -31,7 +34,7 @@ def get_keywords(): ...@@ -31,7 +34,7 @@ def get_keywords():
return keywords return keywords
class VersioneerConfig: class VersioneerConfig(object):
"""Container for Versioneer configuration parameters.""" """Container for Versioneer configuration parameters."""
......
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
# 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 standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import object
from cryptography import x509 from cryptography import x509
from cryptography.hazmat.primitives.serialization import Encoding from cryptography.hazmat.primitives.serialization import Encoding
from threading import local from threading import local
...@@ -33,7 +38,7 @@ import signal ...@@ -33,7 +38,7 @@ import signal
import sqlite3 import sqlite3
import ssl import ssl
import string import string
import urlparse import urllib.parse
import logging import logging
import logging.handlers import logging.handlers
...@@ -361,7 +366,7 @@ class Kedifa(object): ...@@ -361,7 +366,7 @@ class Kedifa(object):
parameters = {} parameters = {}
if qs: if qs:
try: try:
parameters = urlparse.parse_qs(qs, strict_parsing=True) parameters = urllib.parse.parse_qs(qs, strict_parsing=True)
except ValueError: except ValueError:
start_response('400 Bad Request', headers_text_plain) start_response('400 Bad Request', headers_text_plain)
return ('Query string %r was not correct.' % (qs, ),) return ('Query string %r was not correct.' % (qs, ),)
......
...@@ -19,8 +19,10 @@ from __future__ import absolute_import ...@@ -19,8 +19,10 @@ from __future__ import absolute_import
# 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 standard_library
standard_library.install_aliases()
import argparse import argparse
import httplib import http.client
import requests import requests
import sys import sys
...@@ -125,7 +127,7 @@ def getter(*args): ...@@ -125,7 +127,7 @@ def getter(*args):
print('%r not downloaded, problem %s' % (url, e)) print('%r not downloaded, problem %s' % (url, e))
sys.exit(1) sys.exit(1)
else: else:
if response.status_code != httplib.OK: if response.status_code != http.client.OK:
print('%r not downloaded, HTTP code %s' % ( print('%r not downloaded, HTTP code %s' % (
url, response.status_code)) url, response.status_code))
sys.exit(1) sys.exit(1)
......
...@@ -18,10 +18,15 @@ from __future__ import absolute_import ...@@ -18,10 +18,15 @@ from __future__ import absolute_import
# 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 standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import object
from io import StringIO from io import StringIO
import contextlib import contextlib
import datetime import datetime
import httplib import http.client
import ipaddress import ipaddress
import json import json
import mock import mock
...@@ -80,7 +85,7 @@ class KedifaMixinCaucase(KedifaMixin): ...@@ -80,7 +85,7 @@ class KedifaMixinCaucase(KedifaMixin):
format=serialization.PrivateFormat.TraditionalOpenSSL, format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.NoEncryption() encryption_algorithm=serialization.NoEncryption()
) )
return key, key_pem return key, key_pem.decode("ascii")
def generateCSR(self, ip): def generateCSR(self, ip):
key_pem_file = os.path.join(self.testdir, '%s-key.pem' % (ip,)) key_pem_file = os.path.join(self.testdir, '%s-key.pem' % (ip,))
...@@ -99,7 +104,7 @@ class KedifaMixinCaucase(KedifaMixin): ...@@ -99,7 +104,7 @@ class KedifaMixinCaucase(KedifaMixin):
critical=False, critical=False,
).sign(key, hashes.SHA256(), default_backend()) ).sign(key, hashes.SHA256(), default_backend())
with open(csr_pem_file, 'w') as out: with open(csr_pem_file, 'wb') as out:
out.write(csr.public_bytes(serialization.Encoding.PEM)) out.write(csr.public_bytes(serialization.Encoding.PEM))
return key_pem_file, csr_pem_file return key_pem_file, csr_pem_file
...@@ -189,7 +194,7 @@ class KedifaMixinCaucase(KedifaMixin): ...@@ -189,7 +194,7 @@ class KedifaMixinCaucase(KedifaMixin):
) )
self.cas = cas.split() self.cas = cas.split()
kedifa_key_pem, csr_file = self.generateCSR(unicode(common_name)) kedifa_key_pem, csr_file = self.generateCSR(str(common_name))
out = StringIO() out = StringIO()
err = StringIO() err = StringIO()
caucase.cli.main( caucase.cli.main(
...@@ -264,7 +269,7 @@ class KedifaMixinCaucase(KedifaMixin): ...@@ -264,7 +269,7 @@ class KedifaMixinCaucase(KedifaMixin):
verify=self.ca_crt_pem, cert=self.client_key_pem) verify=self.ca_crt_pem, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
result.status_code, result.status_code,
httplib.CREATED http.client.CREATED
) )
location = result.headers.get('Location', '') location = result.headers.get('Location', '')
self.assertRegexpMatches( self.assertRegexpMatches(
...@@ -369,7 +374,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -369,7 +374,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
# KeDiFa does not support nothing on / so for now it just raises # KeDiFa does not support nothing on / so for now it just raises
# possibly in the future it will become self-describing interface # possibly in the future it will become self-describing interface
self.assertEqual( self.assertEqual(
httplib.BAD_REQUEST, http.client.BAD_REQUEST,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -381,7 +386,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -381,7 +386,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
os.rename(self.logfile, self.logfile + '.rotated') os.rename(self.logfile, self.logfile + '.rotated')
result = self.requests_get(self.kedifa_url) result = self.requests_get(self.kedifa_url)
self.assertEqual( self.assertEqual(
httplib.BAD_REQUEST, http.client.BAD_REQUEST,
result.status_code result.status_code
) )
self.assertLastLogEntry('"GET / HTTP/1.1" 400') self.assertLastLogEntry('"GET / HTTP/1.1" 400')
...@@ -390,7 +395,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -390,7 +395,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.NOT_FOUND, http.client.NOT_FOUND,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -404,7 +409,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -404,7 +409,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -460,7 +465,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -460,7 +465,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(httplib.UNAUTHORIZED, result.status_code) self.assertEqual(http.client.UNAUTHORIZED, result.status_code)
self.assertEqual('transport', result.headers.get('WWW-Authenticate')) self.assertEqual('transport', result.headers.get('WWW-Authenticate'))
self.assertEqual('', result.text) self.assertEqual('', result.text)
...@@ -475,7 +480,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -475,7 +480,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -500,7 +505,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -500,7 +505,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -512,7 +517,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -512,7 +517,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
self.put() self.put()
result = self.requests_get(self.kedifa_url + self.reference) result = self.requests_get(self.kedifa_url + self.reference)
self.assertEqual( self.assertEqual(
httplib.UNAUTHORIZED, http.client.UNAUTHORIZED,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -593,7 +598,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -593,7 +598,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem) self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -605,7 +610,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -605,7 +610,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem) self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -618,7 +623,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -618,7 +623,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem) self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -631,7 +636,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -631,7 +636,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/list') self.kedifa_url + self.reference + '/list')
self.assertEqual( self.assertEqual(
httplib.UNAUTHORIZED, http.client.UNAUTHORIZED,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -661,7 +666,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -661,7 +666,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem) self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -672,7 +677,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -672,7 +677,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -683,7 +688,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -683,7 +688,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/2', cert=self.client_key_pem) self.kedifa_url + self.reference + '/2', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -694,7 +699,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -694,7 +699,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem) self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -729,7 +734,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -729,7 +734,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem) self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -740,7 +745,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -740,7 +745,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -751,7 +756,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -751,7 +756,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/2', cert=self.client_key_pem) self.kedifa_url + self.reference + '/2', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -762,7 +767,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -762,7 +767,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem) self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.NOT_FOUND, http.client.NOT_FOUND,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -797,7 +802,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -797,7 +802,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem) self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -808,7 +813,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -808,7 +813,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem) self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -819,7 +824,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -819,7 +824,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/2', cert=self.client_key_pem) self.kedifa_url + self.reference + '/2', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -830,7 +835,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -830,7 +835,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem) self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual( self.assertEqual(
httplib.NOT_FOUND, http.client.NOT_FOUND,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -844,7 +849,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -844,7 +849,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + reference + '/generateauth') self.kedifa_url + reference + '/generateauth')
self.assertEqual( self.assertEqual(
httplib.CREATED, http.client.CREATED,
result.status_code result.status_code
) )
return result.text return result.text
...@@ -860,7 +865,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -860,7 +865,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + self.reference + '/generateauth') self.kedifa_url + self.reference + '/generateauth')
self.assertEqual( self.assertEqual(
httplib.FORBIDDEN, http.client.FORBIDDEN,
result.status_code result.status_code
) )
self.assertEqual('Already exists', result.text) self.assertEqual('Already exists', result.text)
...@@ -870,7 +875,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -870,7 +875,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get( result = self.requests_get(
self.kedifa_url + key + '/generateauth') self.kedifa_url + key + '/generateauth')
self.assertEqual( self.assertEqual(
httplib.NOT_FOUND, http.client.NOT_FOUND,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -890,7 +895,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -890,7 +895,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
'Content-Type': 'application/x-x509-ca-cert', 'Content-Type': 'application/x-x509-ca-cert',
}) })
self.assertEqual( self.assertEqual(
httplib.CREATED, http.client.CREATED,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -937,7 +942,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -937,7 +942,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem + certificate_pem) result = self.requests_put(url, data=key_pem + certificate_pem)
self.assertEqual( self.assertEqual(
httplib.UNPROCESSABLE_ENTITY, http.client.UNPROCESSABLE_ENTITY,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -954,7 +959,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -954,7 +959,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem + certificate_pem) result = self.requests_put(url, data=key_pem + certificate_pem)
self.assertEqual( self.assertEqual(
httplib.UNPROCESSABLE_ENTITY, http.client.UNPROCESSABLE_ENTITY,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -968,7 +973,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -968,7 +973,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem + certificate_pem) result = self.requests_put(url, data=key_pem + certificate_pem)
self.assertEqual( self.assertEqual(
httplib.CREATED, http.client.CREATED,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -982,7 +987,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -982,7 +987,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem) result = self.requests_put(url, data=key_pem)
self.assertEqual( self.assertEqual(
httplib.UNPROCESSABLE_ENTITY, http.client.UNPROCESSABLE_ENTITY,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -996,7 +1001,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -996,7 +1001,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=certificate_pem) result = self.requests_put(url, data=certificate_pem)
self.assertEqual( self.assertEqual(
httplib.UNPROCESSABLE_ENTITY, http.client.UNPROCESSABLE_ENTITY,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1011,7 +1016,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1011,7 +1016,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=certificate_pem + key_pem) result = self.requests_put(url, data=certificate_pem + key_pem)
self.assertEqual( self.assertEqual(
httplib.UNPROCESSABLE_ENTITY, http.client.UNPROCESSABLE_ENTITY,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1024,7 +1029,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1024,7 +1029,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, ) url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data='badcert') result = self.requests_put(url, data='badcert')
self.assertEqual( self.assertEqual(
httplib.UNPROCESSABLE_ENTITY, http.client.UNPROCESSABLE_ENTITY,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1036,7 +1041,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1036,7 +1041,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference url = self.kedifa_url + self.reference
result = self.requests_put(url, data=self.pem) result = self.requests_put(url, data=self.pem)
self.assertEqual( self.assertEqual(
httplib.BAD_REQUEST, http.client.BAD_REQUEST,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1048,7 +1053,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1048,7 +1053,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=wrong' url = self.kedifa_url + self.reference + '?auth=wrong'
result = self.requests_put(url, data=self.pem) result = self.requests_put(url, data=self.pem)
self.assertEqual( self.assertEqual(
httplib.UNAUTHORIZED, http.client.UNAUTHORIZED,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1112,7 +1117,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1112,7 +1117,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
self.assertEqual(1, self._getDBCertificateCount()) self.assertEqual(1, self._getDBCertificateCount())
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1136,7 +1141,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1136,7 +1141,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
self.assertEqual(1, self._getDBCertificateCount()) self.assertEqual(1, self._getDBCertificateCount())
self.assertEqual( self.assertEqual(
httplib.OK, http.client.OK,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
...@@ -1148,7 +1153,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase): ...@@ -1148,7 +1153,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(self.kedifa_url + '/!?&&==') result = self.requests_get(self.kedifa_url + '/!?&&==')
self.assertEqual( self.assertEqual(
httplib.BAD_REQUEST, http.client.BAD_REQUEST,
result.status_code result.status_code
) )
self.assertEqual( self.assertEqual(
......
from __future__ import print_function from __future__ import print_function
import httplib from future import standard_library
standard_library.install_aliases()
from builtins import object
import http.client
import json import json
import os import os
import requests import requests
...@@ -57,7 +60,7 @@ class Updater(object): ...@@ -57,7 +60,7 @@ class Updater(object):
print('Certificate %r: problem with %r not downloaded: %s' % ( print('Certificate %r: problem with %r not downloaded: %s' % (
certificate_file, url, e)) certificate_file, url, e))
else: else:
if response.status_code != httplib.OK: if response.status_code != http.client.OK:
print('Certificate %r: %r not downloaded, HTTP code %s' % ( print('Certificate %r: %r not downloaded, HTTP code %s' % (
certificate_file, url, response.status_code)) certificate_file, url, response.status_code))
else: else:
...@@ -146,7 +149,7 @@ class Updater(object): ...@@ -146,7 +149,7 @@ class Updater(object):
self.master_certificate_file): self.master_certificate_file):
master_content = open(self.master_certificate_file, 'r').read() master_content = open(self.master_certificate_file, 'r').read()
for certificate, (_, fallback) in prepare_mapping.items(): for certificate, (_, fallback) in list(prepare_mapping.items()):
if os.path.exists(certificate): if os.path.exists(certificate):
continue continue
if fallback and os.path.exists(fallback): if fallback and os.path.exists(fallback):
...@@ -176,7 +179,7 @@ class Updater(object): ...@@ -176,7 +179,7 @@ class Updater(object):
except IOError: except IOError:
pass pass
for certificate_file in self.mapping.keys(): for certificate_file in list(self.mapping.keys()):
if self.updateCertificate(certificate_file, master_content): if self.updateCertificate(certificate_file, master_content):
updated = True updated = True
......
...@@ -277,6 +277,11 @@ https://creativecommons.org/publicdomain/zero/1.0/ . ...@@ -277,6 +277,11 @@ https://creativecommons.org/publicdomain/zero/1.0/ .
""" """
from __future__ import print_function from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import str
from builtins import range
from builtins import object
try: try:
import configparser import configparser
except ImportError: except ImportError:
...@@ -289,7 +294,7 @@ import subprocess ...@@ -289,7 +294,7 @@ import subprocess
import sys import sys
class VersioneerConfig: class VersioneerConfig(object):
"""Container for Versioneer configuration parameters.""" """Container for Versioneer configuration parameters."""
......
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