Commit 7ccb530a authored by Aurel's avatar Aurel

use better lib for http code

parent 56a8b248
......@@ -23,7 +23,7 @@ from builtins import object
from io import BytesIO as StringIO
import contextlib
import datetime
from six.moves import http_client as httplib
import http.client
import ipaddress
import json
import mock
......@@ -271,7 +271,7 @@ class KedifaMixinCaucase(KedifaMixin):
verify=self.ca_crt_pem, cert=self.client_key_pem)
self.assertEqual(
result.status_code,
six.moves.http_client.CREATED
http.client.CREATED
)
location = result.headers.get('Location', '')
self.assertRegexpMatches(
......@@ -403,7 +403,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
# KeDiFa does not support nothing on / so for now it just raises
# possibly in the future it will become self-describing interface
self.assertEqual(
six.moves.http_client.BAD_REQUEST,
http.client.BAD_REQUEST,
result.status_code
)
self.assertEqual(
......@@ -415,7 +415,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
os.rename(self.logfile, self.logfile + '.rotated')
result = self.requests_get(self.kedifa_url)
self.assertEqual(
six.moves.http_client.BAD_REQUEST,
http.client.BAD_REQUEST,
result.status_code
)
self.assertLastLogEntry('"GET / HTTP/1.1" 400')
......@@ -424,7 +424,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.NOT_FOUND,
http.client.NOT_FOUND,
result.status_code
)
self.assertEqual(
......@@ -438,7 +438,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -494,7 +494,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(six.moves.http_client.UNAUTHORIZED, result.status_code)
self.assertEqual(http.client.UNAUTHORIZED, result.status_code)
self.assertEqual('transport', result.headers.get('WWW-Authenticate'))
self.assertEqual('', result.text)
......@@ -509,7 +509,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -534,7 +534,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -546,7 +546,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
self.put()
result = self.requests_get(self.kedifa_url + self.reference)
self.assertEqual(
six.moves.http_client.UNAUTHORIZED,
http.client.UNAUTHORIZED,
result.status_code
)
self.assertEqual(
......@@ -627,7 +627,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -639,7 +639,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -652,7 +652,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -665,7 +665,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/list')
self.assertEqual(
six.moves.http_client.UNAUTHORIZED,
http.client.UNAUTHORIZED,
result.status_code
)
self.assertEqual(
......@@ -695,7 +695,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -706,7 +706,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -717,7 +717,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/2', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -728,7 +728,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -763,7 +763,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -774,7 +774,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -785,7 +785,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/2', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -796,7 +796,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.NOT_FOUND,
http.client.NOT_FOUND,
result.status_code
)
self.assertEqual(
......@@ -831,7 +831,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/list', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -842,7 +842,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference, cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -853,7 +853,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/2', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -864,7 +864,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/1', cert=self.client_key_pem)
self.assertEqual(
six.moves.http_client.NOT_FOUND,
http.client.NOT_FOUND,
result.status_code
)
self.assertEqual(
......@@ -878,7 +878,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + reference + '/generateauth')
self.assertEqual(
six.moves.http_client.CREATED,
http.client.CREATED,
result.status_code
)
return result.text
......@@ -894,7 +894,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + self.reference + '/generateauth')
self.assertEqual(
six.moves.http_client.FORBIDDEN,
http.client.FORBIDDEN,
result.status_code
)
self.assertEqual('Already exists', result.text)
......@@ -904,7 +904,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(
self.kedifa_url + key + '/generateauth')
self.assertEqual(
six.moves.http_client.NOT_FOUND,
http.client.NOT_FOUND,
result.status_code
)
self.assertEqual(
......@@ -924,7 +924,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
'Content-Type': 'application/x-x509-ca-cert',
})
self.assertEqual(
six.moves.http_client.CREATED,
http.client.CREATED,
result.status_code
)
self.assertEqual(
......@@ -971,7 +971,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem + certificate_pem)
self.assertEqual(
six.moves.http_client.UNPROCESSABLE_ENTITY,
http.client.UNPROCESSABLE_ENTITY,
result.status_code
)
self.assertEqual(
......@@ -988,7 +988,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem + certificate_pem)
self.assertEqual(
six.moves.http_client.UNPROCESSABLE_ENTITY,
http.client.UNPROCESSABLE_ENTITY,
result.status_code
)
self.assertEqual(
......@@ -1002,7 +1002,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem + certificate_pem)
self.assertEqual(
six.moves.http_client.CREATED,
http.client.CREATED,
result.status_code
)
self.assertEqual(
......@@ -1016,7 +1016,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=key_pem)
self.assertEqual(
six.moves.http_client.UNPROCESSABLE_ENTITY,
http.client.UNPROCESSABLE_ENTITY,
result.status_code
)
self.assertEqual(
......@@ -1030,7 +1030,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=certificate_pem)
self.assertEqual(
six.moves.http_client.UNPROCESSABLE_ENTITY,
http.client.UNPROCESSABLE_ENTITY,
result.status_code
)
self.assertEqual(
......@@ -1045,7 +1045,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data=certificate_pem + key_pem)
self.assertEqual(
six.moves.http_client.UNPROCESSABLE_ENTITY,
http.client.UNPROCESSABLE_ENTITY,
result.status_code
)
self.assertEqual(
......@@ -1058,7 +1058,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=%s' % (auth, )
result = self.requests_put(url, data='badcert')
self.assertEqual(
six.moves.http_client.UNPROCESSABLE_ENTITY,
http.client.UNPROCESSABLE_ENTITY,
result.status_code
)
self.assertEqual(
......@@ -1070,7 +1070,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference
result = self.requests_put(url, data=self.pem)
self.assertEqual(
six.moves.http_client.BAD_REQUEST,
http.client.BAD_REQUEST,
result.status_code
)
self.assertEqual(
......@@ -1082,7 +1082,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
url = self.kedifa_url + self.reference + '?auth=wrong'
result = self.requests_put(url, data=self.pem)
self.assertEqual(
six.moves.http_client.UNAUTHORIZED,
http.client.UNAUTHORIZED,
result.status_code
)
self.assertEqual(
......@@ -1146,7 +1146,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
self.assertEqual(1, self._getDBCertificateCount())
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -1170,7 +1170,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
self.assertEqual(1, self._getDBCertificateCount())
self.assertEqual(
six.moves.http_client.OK,
http.client.OK,
result.status_code
)
self.assertEqual(
......@@ -1182,7 +1182,7 @@ class KedifaIntegrationTest(KedifaMixinCaucase, unittest.TestCase):
result = self.requests_get(self.kedifa_url + '/!?&&==')
self.assertEqual(
six.moves.http_client.BAD_REQUEST,
http.client.BAD_REQUEST,
result.status_code
)
self.assertEqual(
......
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