Merge "Rename client.py to httpclient.py"
This commit is contained in:
@@ -18,13 +18,13 @@
|
|||||||
import logging
|
import logging
|
||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
from keystoneclient import client
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
from keystoneclient import httpclient
|
||||||
|
|
||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Client(client.HTTPClient):
|
class Client(httpclient.HTTPClient):
|
||||||
"""Client for the OpenStack Keystone pre-version calls API.
|
"""Client for the OpenStack Keystone pre-version calls API.
|
||||||
|
|
||||||
:param string endpoint: A user-supplied endpoint URL for the keystone
|
:param string endpoint: A user-supplied endpoint URL for the keystone
|
||||||
@@ -80,10 +80,10 @@ class Client(client.HTTPClient):
|
|||||||
def _check_keystone_versions(self, url):
|
def _check_keystone_versions(self, url):
|
||||||
"""Calls Keystone URL and detects the available API versions."""
|
"""Calls Keystone URL and detects the available API versions."""
|
||||||
try:
|
try:
|
||||||
httpclient = client.HTTPClient()
|
client = httpclient.HTTPClient()
|
||||||
resp, body = httpclient.request(url, "GET",
|
resp, body = client.request(url, "GET",
|
||||||
headers={'Accept':
|
headers={'Accept':
|
||||||
'application/json'})
|
'application/json'})
|
||||||
# Multiple Choices status code is returned by the root
|
# Multiple Choices status code is returned by the root
|
||||||
# identity endpoint, with references to one or more
|
# identity endpoint, with references to one or more
|
||||||
# Identity API versions -- v3 spec
|
# Identity API versions -- v3 spec
|
||||||
@@ -143,12 +143,12 @@ class Client(client.HTTPClient):
|
|||||||
def _check_keystone_extensions(self, url):
|
def _check_keystone_extensions(self, url):
|
||||||
"""Calls Keystone URL and detects the available extensions."""
|
"""Calls Keystone URL and detects the available extensions."""
|
||||||
try:
|
try:
|
||||||
httpclient = client.HTTPClient()
|
client = httpclient.HTTPClient()
|
||||||
if not url.endswith("/"):
|
if not url.endswith("/"):
|
||||||
url += '/'
|
url += '/'
|
||||||
resp, body = httpclient.request("%sextensions" % url, "GET",
|
resp, body = client.request("%sextensions" % url, "GET",
|
||||||
headers={'Accept':
|
headers={'Accept':
|
||||||
'application/json'})
|
'application/json'})
|
||||||
if resp.status_code in (200, 204): # some cases we get No Content
|
if resp.status_code in (200, 204): # some cases we get No Content
|
||||||
try:
|
try:
|
||||||
results = {}
|
results = {}
|
||||||
|
@@ -14,8 +14,8 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from keystoneclient import client
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
from keystoneclient import httpclient
|
||||||
from keystoneclient.v2_0 import ec2
|
from keystoneclient.v2_0 import ec2
|
||||||
from keystoneclient.v2_0 import endpoints
|
from keystoneclient.v2_0 import endpoints
|
||||||
from keystoneclient.v2_0 import roles
|
from keystoneclient.v2_0 import roles
|
||||||
@@ -28,7 +28,7 @@ from keystoneclient.v2_0 import users
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Client(client.HTTPClient):
|
class Client(httpclient.HTTPClient):
|
||||||
"""Client for the OpenStack Keystone v2.0 API.
|
"""Client for the OpenStack Keystone v2.0 API.
|
||||||
|
|
||||||
:param string username: Username for authentication. (optional)
|
:param string username: Username for authentication. (optional)
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from keystoneclient import client
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
from keystoneclient import httpclient
|
||||||
from keystoneclient.v3 import credentials
|
from keystoneclient.v3 import credentials
|
||||||
from keystoneclient.v3 import domains
|
from keystoneclient.v3 import domains
|
||||||
from keystoneclient.v3 import endpoints
|
from keystoneclient.v3 import endpoints
|
||||||
@@ -31,7 +31,7 @@ from keystoneclient.v3 import users
|
|||||||
_logger = logging.getLogger(__name__)
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Client(client.HTTPClient):
|
class Client(httpclient.HTTPClient):
|
||||||
"""Client for the OpenStack Identity API v3.
|
"""Client for the OpenStack Identity API v3.
|
||||||
|
|
||||||
:param string user_id: User ID for authentication. (optional)
|
:param string user_id: User ID for authentication. (optional)
|
||||||
|
@@ -3,8 +3,8 @@ import mock
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from keystoneclient import client
|
|
||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
|
from keystoneclient import httpclient
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
|
|
||||||
@@ -16,8 +16,8 @@ MOCK_REQUEST = mock.Mock(return_value=(FAKE_RESPONSE))
|
|||||||
|
|
||||||
|
|
||||||
def get_client():
|
def get_client():
|
||||||
cl = client.HTTPClient(username="username", password="password",
|
cl = httpclient.HTTPClient(username="username", password="password",
|
||||||
tenant_id="tenant", auth_url="auth_test")
|
tenant_id="tenant", auth_url="auth_test")
|
||||||
return cl
|
return cl
|
||||||
|
|
||||||
|
|
||||||
@@ -108,9 +108,9 @@ class ClientTest(utils.TestCase):
|
|||||||
|
|
||||||
def test_forwarded_for(self):
|
def test_forwarded_for(self):
|
||||||
ORIGINAL_IP = "10.100.100.1"
|
ORIGINAL_IP = "10.100.100.1"
|
||||||
cl = client.HTTPClient(username="username", password="password",
|
cl = httpclient.HTTPClient(username="username", password="password",
|
||||||
tenant_id="tenant", auth_url="auth_test",
|
tenant_id="tenant", auth_url="auth_test",
|
||||||
original_ip=ORIGINAL_IP)
|
original_ip=ORIGINAL_IP)
|
||||||
|
|
||||||
with mock.patch.object(requests, "request", MOCK_REQUEST):
|
with mock.patch.object(requests, "request", MOCK_REQUEST):
|
||||||
res = cl.request('/', 'GET')
|
res = cl.request('/', 'GET')
|
||||||
|
@@ -3,7 +3,7 @@ import mock
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from keystoneclient import client
|
from keystoneclient import httpclient
|
||||||
from tests import utils
|
from tests import utils
|
||||||
|
|
||||||
|
|
||||||
@@ -15,9 +15,9 @@ MOCK_REQUEST = mock.Mock(return_value=(FAKE_RESPONSE))
|
|||||||
|
|
||||||
|
|
||||||
def get_client():
|
def get_client():
|
||||||
cl = client.HTTPClient(username="username", password="password",
|
cl = httpclient.HTTPClient(username="username", password="password",
|
||||||
tenant_id="tenant", auth_url="auth_test",
|
tenant_id="tenant", auth_url="auth_test",
|
||||||
cacert="ca.pem", key="key.pem", cert="cert.pem")
|
cacert="ca.pem", key="key.pem", cert="cert.pem")
|
||||||
return cl
|
return cl
|
||||||
|
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ class ClientTest(utils.TestCase):
|
|||||||
|
|
||||||
def test_post_auth(self):
|
def test_post_auth(self):
|
||||||
with mock.patch.object(requests, "request", MOCK_REQUEST):
|
with mock.patch.object(requests, "request", MOCK_REQUEST):
|
||||||
cl = client.HTTPClient(
|
cl = httpclient.HTTPClient(
|
||||||
username="username", password="password", tenant_id="tenant",
|
username="username", password="password", tenant_id="tenant",
|
||||||
auth_url="auth_test", cacert="ca.pem", key="key.pem",
|
auth_url="auth_test", cacert="ca.pem", key="key.pem",
|
||||||
cert="cert.pem")
|
cert="cert.pem")
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from keystoneclient import access
|
from keystoneclient import access
|
||||||
from keystoneclient import client
|
from keystoneclient import httpclient
|
||||||
from keystoneclient.openstack.common import timeutils
|
from keystoneclient.openstack.common import timeutils
|
||||||
|
|
||||||
from tests import utils
|
from tests import utils
|
||||||
@@ -58,8 +58,8 @@ class KeyringTest(utils.TestCase):
|
|||||||
Ensure that we get no value back if we don't have use_keyring
|
Ensure that we get no value back if we don't have use_keyring
|
||||||
set in the client.
|
set in the client.
|
||||||
"""
|
"""
|
||||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||||
|
|
||||||
(keyring_key, auth_ref) = cl.get_auth_ref_from_keyring(
|
(keyring_key, auth_ref) = cl.get_auth_ref_from_keyring(
|
||||||
auth_url=AUTH_URL,
|
auth_url=AUTH_URL,
|
||||||
@@ -72,8 +72,8 @@ class KeyringTest(utils.TestCase):
|
|||||||
self.assertIsNone(auth_ref)
|
self.assertIsNone(auth_ref)
|
||||||
|
|
||||||
def test_build_keyring_key(self):
|
def test_build_keyring_key(self):
|
||||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||||
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
tenant_id=TENANT_ID, auth_url=AUTH_URL)
|
||||||
|
|
||||||
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
||||||
username=USERNAME,
|
username=USERNAME,
|
||||||
@@ -86,9 +86,9 @@ class KeyringTest(utils.TestCase):
|
|||||||
(AUTH_URL, TENANT_ID, TENANT, TOKEN, USERNAME))
|
(AUTH_URL, TENANT_ID, TENANT, TOKEN, USERNAME))
|
||||||
|
|
||||||
def test_set_and_get_keyring_expired(self):
|
def test_set_and_get_keyring_expired(self):
|
||||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||||
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
||||||
use_keyring=True)
|
use_keyring=True)
|
||||||
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
||||||
username=USERNAME,
|
username=USERNAME,
|
||||||
tenant_name=TENANT,
|
tenant_name=TENANT,
|
||||||
@@ -108,9 +108,9 @@ class KeyringTest(utils.TestCase):
|
|||||||
self.assertIsNone(auth_ref)
|
self.assertIsNone(auth_ref)
|
||||||
|
|
||||||
def test_set_and_get_keyring(self):
|
def test_set_and_get_keyring(self):
|
||||||
cl = client.HTTPClient(username=USERNAME, password=PASSWORD,
|
cl = httpclient.HTTPClient(username=USERNAME, password=PASSWORD,
|
||||||
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
tenant_id=TENANT_ID, auth_url=AUTH_URL,
|
||||||
use_keyring=True)
|
use_keyring=True)
|
||||||
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
keyring_key = cl._build_keyring_key(auth_url=AUTH_URL,
|
||||||
username=USERNAME,
|
username=USERNAME,
|
||||||
tenant_name=TENANT,
|
tenant_name=TENANT,
|
||||||
|
@@ -5,7 +5,7 @@ import sys
|
|||||||
|
|
||||||
from testtools import matchers
|
from testtools import matchers
|
||||||
|
|
||||||
from keystoneclient import client
|
from keystoneclient import httpclient
|
||||||
|
|
||||||
from tests import utils
|
from tests import utils
|
||||||
from tests.v2_0 import fakes
|
from tests.v2_0 import fakes
|
||||||
@@ -28,11 +28,11 @@ class ShellTests(utils.TestCase):
|
|||||||
|
|
||||||
self.fake_client = fakes.FakeHTTPClient()
|
self.fake_client = fakes.FakeHTTPClient()
|
||||||
self.stubs.Set(
|
self.stubs.Set(
|
||||||
client.HTTPClient, "_cs_request",
|
httpclient.HTTPClient, "_cs_request",
|
||||||
lambda ign_self, *args, **kwargs:
|
lambda ign_self, *args, **kwargs:
|
||||||
self.fake_client._cs_request(*args, **kwargs))
|
self.fake_client._cs_request(*args, **kwargs))
|
||||||
self.stubs.Set(
|
self.stubs.Set(
|
||||||
client.HTTPClient, "authenticate",
|
httpclient.HTTPClient, "authenticate",
|
||||||
lambda cl_obj:
|
lambda cl_obj:
|
||||||
self.fake_client.authenticate(cl_obj))
|
self.fake_client.authenticate(cl_obj))
|
||||||
self.old_environment = os.environ.copy()
|
self.old_environment = os.environ.copy()
|
||||||
|
Reference in New Issue
Block a user