Get rid of httplib2, use urllib3 instead
httplib2 has been abandonned by its author [1] and is less going
to be updated and maintained than urllib3. So, let's replace httplib2
with urllib3.
Note that this patch mostly rework the unit tests.
I removed the files `tempest.tests.fake_identity` and
`tempest.tests.fake_http` to use their `tempest.tests.lib` counterpart.
Also, I tried to "encapsulated" HTTP calls and use
`tempest/lib/common/http.py` everywhere so that we only import
urllib3 once. This makes us not so dependent on a specific HTTP
library.
[1] http://bitworking.org/news/2016/03/an_update_on_httplib2
Change-Id: Id469e78afdb69a404144568a454d98d20a924231
diff --git a/tempest/tests/lib/fake_identity.py b/tempest/tests/lib/fake_identity.py
index bac2676..5732065 100644
--- a/tempest/tests/lib/fake_identity.py
+++ b/tempest/tests/lib/fake_identity.py
@@ -13,9 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.
-import json
+from oslo_serialization import jsonutils as json
-import httplib2
+from tempest.tests.lib import fake_http
FAKE_AUTH_URL = 'http://fake_uri.com/auth'
@@ -139,16 +139,15 @@
def _fake_v3_response(self, uri, method="GET", body=None, headers=None,
redirections=5, connection_type=None):
fake_headers = {
- "status": "201",
"x-subject-token": TOKEN
}
- return (httplib2.Response(fake_headers),
+ return (fake_http.fake_http_response(fake_headers, status=201),
json.dumps(IDENTITY_V3_RESPONSE))
def _fake_v2_response(self, uri, method="GET", body=None, headers=None,
redirections=5, connection_type=None):
- return (httplib2.Response({"status": "200"}),
+ return (fake_http.fake_http_response({}, status=200),
json.dumps(IDENTITY_V2_RESPONSE))
@@ -161,4 +160,4 @@
"code": "401"
}
}
- return httplib2.Response({"status": "401"}), json.dumps(body)
+ return fake_http.fake_http_response({}, status=401), json.dumps(body)