Remove unused json_request.

- This has been long delegated to python-keystoneclient for auth 2.0.

Change-Id: I92b1fc2db68192cfeefd623c59882f65a4e4405c
This commit is contained in:
Chmouel Boudjnah 2012-11-16 14:47:27 +10:00
parent 5427f7f501
commit 8e63b53a9b
2 changed files with 0 additions and 37 deletions

@ -175,32 +175,6 @@ def http_connection(url, proxy=None):
return parsed, conn
def json_request(method, url, **kwargs):
"""Takes a request in json parse it and return in json"""
kwargs.setdefault('headers', {})
if 'body' in kwargs:
kwargs['headers']['Content-Type'] = 'application/json'
kwargs['body'] = json_dumps(kwargs['body'])
parsed, conn = http_connection(url)
conn.request(method, parsed.path, **kwargs)
resp = conn.getresponse()
body = resp.read()
http_log((url, method,), kwargs, resp, body)
if body:
try:
body = json_loads(body)
except ValueError:
body = None
if not body or resp.status < 200 or resp.status >= 300:
raise ClientException('Auth GET failed', http_scheme=parsed.scheme,
http_host=conn.host,
http_port=conn.port,
http_path=parsed.path,
http_status=resp.status,
http_reason=resp.reason)
return resp, body
def get_auth_1_0(url, user, key, snet):
parsed, conn = http_connection(url)
method = 'GET'

@ -139,17 +139,6 @@ class TestHttpHelpers(MockHttpTest):
url = 'ftp://www.test.com'
self.assertRaises(c.ClientException, c.http_connection, url)
def test_json_request(self):
def read(*args, **kwargs):
body = {'a': '1',
'b': '2'}
return c.json_dumps(body)
c.http_connection = self.fake_http_connection(200, return_read=read)
url = 'http://www.test.com'
_junk, conn = c.json_request('GET', url, body={'username': 'user1',
'password': 'secure'})
self.assertTrue(type(conn) is dict)
# TODO: following tests are placeholders, need more tests, better coverage