summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Bryant <corey.bryant@canonical.com>2015-09-25 15:42:49 -0400
committerSteve Martinelli <stevemar@ca.ibm.com>2015-10-02 04:12:47 +0000
commit91c9b924d1297a0d72a1d1dd51b0d09d4d047df0 (patch)
tree1d599521040994e5129c90938787a34ab36c49be
parent28138b588224c6b0503620ac2e24bd37dad25370 (diff)
downloadpython-keystoneclient-91c9b924d1297a0d72a1d1dd51b0d09d4d047df0.tar.gz
HTTPClient/region_name deprecation test updates
Creating an HTTPClient without a session is deprecated and the ServiceCatalog's region_name parameter is also deprecated. This follows suite with the following commits to update tests to handle deprecation warnings: 803eb235d50daad27074198effc98ca536f1550f 42bd016e1f0e011ba745dba243e62401298e324c Change-Id: I1c5a3dc2c8448873696262ca951c58666c692a61 Closes-Bug: #1499790 (cherry picked from commit 5dea3b22fcc672f3e3405f5abec471929c501c0a)
-rw-r--r--keystoneclient/tests/unit/v2_0/test_auth.py10
-rw-r--r--keystoneclient/tests/unit/v2_0/test_client.py102
-rw-r--r--keystoneclient/tests/unit/v2_0/test_discovery.py8
-rw-r--r--keystoneclient/tests/unit/v2_0/test_service_catalog.py4
-rw-r--r--keystoneclient/tests/unit/v2_0/test_tenants.py8
-rw-r--r--keystoneclient/tests/unit/v2_0/test_tokens.py8
-rw-r--r--keystoneclient/tests/unit/v3/test_auth.py114
-rw-r--r--keystoneclient/tests/unit/v3/test_client.py104
-rw-r--r--keystoneclient/tests/unit/v3/test_discover.py4
-rw-r--r--keystoneclient/tests/unit/v3/test_service_catalog.py6
10 files changed, 226 insertions, 142 deletions
diff --git a/keystoneclient/tests/unit/v2_0/test_auth.py b/keystoneclient/tests/unit/v2_0/test_auth.py
index c72ecc9..a10fd96 100644
--- a/keystoneclient/tests/unit/v2_0/test_auth.py
+++ b/keystoneclient/tests/unit/v2_0/test_auth.py
@@ -67,10 +67,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(response_list=[{'json': resp_a, 'headers': headers},
{'json': resp_b, 'headers': headers}])
- cs = client.Client(project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL,
- username=self.TEST_USER,
- password=self.TEST_TOKEN)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL,
+ username=self.TEST_USER,
+ password=self.TEST_TOKEN)
self.assertEqual(cs.management_url,
self.TEST_RESPONSE_DICT["access"]["serviceCatalog"][3]
diff --git a/keystoneclient/tests/unit/v2_0/test_client.py b/keystoneclient/tests/unit/v2_0/test_client.py
index 447c750..0ef2f6f 100644
--- a/keystoneclient/tests/unit/v2_0/test_client.py
+++ b/keystoneclient/tests/unit/v2_0/test_client.py
@@ -30,9 +30,11 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.unscoped_token()
self.stub_auth(json=token)
- c = client.Client(username='exampleuser',
- password='password',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(username='exampleuser',
+ password='password',
+ auth_url=self.TEST_URL)
self.assertIsNotNone(c.auth_ref)
with self.deprecations.expect_deprecations_here():
self.assertFalse(c.auth_ref.scoped)
@@ -47,10 +49,12 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.project_scoped_token()
self.stub_auth(json=token)
- c = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
self.assertIsNotNone(c.auth_ref)
with self.deprecations.expect_deprecations_here():
self.assertTrue(c.auth_ref.scoped)
@@ -65,12 +69,16 @@ class KeystoneClientTest(utils.TestCase):
def test_auth_ref_load(self):
self.stub_auth(json=client_fixtures.project_scoped_token())
- cl = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
cache = json.dumps(cl.auth_ref)
- new_client = client.Client(auth_ref=json.loads(cache))
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ new_client = client.Client(auth_ref=json.loads(cache))
self.assertIsNotNone(new_client.auth_ref)
with self.deprecations.expect_deprecations_here():
self.assertTrue(new_client.auth_ref.scoped)
@@ -86,14 +94,18 @@ class KeystoneClientTest(utils.TestCase):
def test_auth_ref_load_with_overridden_arguments(self):
self.stub_auth(json=client_fixtures.project_scoped_token())
- cl = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
cache = json.dumps(cl.auth_ref)
new_auth_url = "http://new-public:5000/v2.0"
- new_client = client.Client(auth_ref=json.loads(cache),
- auth_url=new_auth_url)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ new_client = client.Client(auth_ref=json.loads(cache),
+ auth_url=new_auth_url)
self.assertIsNotNone(new_client.auth_ref)
with self.deprecations.expect_deprecations_here():
self.assertTrue(new_client.auth_ref.scoped)
@@ -108,10 +120,12 @@ class KeystoneClientTest(utils.TestCase):
'http://admin:35357/v2.0')
def test_init_err_no_auth_url(self):
- self.assertRaises(exceptions.AuthorizationFailure,
- client.Client,
- username='exampleuser',
- password='password')
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ self.assertRaises(exceptions.AuthorizationFailure,
+ client.Client,
+ username='exampleuser',
+ password='password')
def test_management_url_is_updated(self):
first = fixture.V2Token()
@@ -131,10 +145,12 @@ class KeystoneClientTest(utils.TestCase):
self.stub_auth(response_list=[{'json': first}, {'json': second}])
- cl = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
self.assertEqual(cl.management_url, admin_url)
cl.authenticate()
@@ -145,27 +161,33 @@ class KeystoneClientTest(utils.TestCase):
# removed ASAP, however must remain compatible.
self.stub_auth(json=client_fixtures.auth_response_body())
- cl = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL,
- region_name='North')
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL,
+ region_name='North')
self.assertEqual(cl.service_catalog.url_for(service_type='image'),
'https://image.north.host/v1/')
- cl = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL,
- region_name='South')
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL,
+ region_name='South')
self.assertEqual(cl.service_catalog.url_for(service_type='image'),
'https://image.south.host/v1/')
def test_client_without_auth_params(self):
- self.assertRaises(exceptions.AuthorizationFailure,
- client.Client,
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ self.assertRaises(exceptions.AuthorizationFailure,
+ client.Client,
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
def test_client_params(self):
opts = {'auth': token_endpoint.Token('a', 'b'),
diff --git a/keystoneclient/tests/unit/v2_0/test_discovery.py b/keystoneclient/tests/unit/v2_0/test_discovery.py
index 348038a..5afe59a 100644
--- a/keystoneclient/tests/unit/v2_0/test_discovery.py
+++ b/keystoneclient/tests/unit/v2_0/test_discovery.py
@@ -55,7 +55,9 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):
self.stub_url('GET', base_url=self.TEST_ROOT_URL,
json=self.TEST_RESPONSE_DICT)
- cs = client.Client()
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client()
versions = cs.discover(self.TEST_ROOT_URL)
self.assertIsInstance(versions, dict)
self.assertIn('message', versions)
@@ -69,7 +71,9 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):
self.stub_url('GET', base_url="http://localhost:35357/",
json=self.TEST_RESPONSE_DICT)
- cs = client.Client()
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client()
versions = cs.discover()
self.assertIsInstance(versions, dict)
self.assertIn('message', versions)
diff --git a/keystoneclient/tests/unit/v2_0/test_service_catalog.py b/keystoneclient/tests/unit/v2_0/test_service_catalog.py
index 1ea3e05..bb2b3ef 100644
--- a/keystoneclient/tests/unit/v2_0/test_service_catalog.py
+++ b/keystoneclient/tests/unit/v2_0/test_service_catalog.py
@@ -57,7 +57,9 @@ class ServiceCatalogTest(utils.TestCase):
self.assertEqual(url, "https://image.north.host/v1/")
self.AUTH_RESPONSE_BODY['access']['region_name'] = "South"
- auth_ref = access.AccessInfo.factory(None, self.AUTH_RESPONSE_BODY)
+ # Setting region_name on the catalog is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ auth_ref = access.AccessInfo.factory(None, self.AUTH_RESPONSE_BODY)
sc = auth_ref.service_catalog
url = sc.url_for(service_type='image', endpoint_type='internalURL')
diff --git a/keystoneclient/tests/unit/v2_0/test_tenants.py b/keystoneclient/tests/unit/v2_0/test_tenants.py
index 62ca398..279a8fd 100644
--- a/keystoneclient/tests/unit/v2_0/test_tenants.py
+++ b/keystoneclient/tests/unit/v2_0/test_tenants.py
@@ -351,9 +351,11 @@ class TenantTests(utils.TestCase):
self.stub_url('GET', ['tenants'], base_url=new_auth_url,
json=self.TEST_TENANTS)
- c = client.Client(username=self.TEST_USER,
- auth_url=new_auth_url,
- password=uuid.uuid4().hex)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(username=self.TEST_USER,
+ auth_url=new_auth_url,
+ password=uuid.uuid4().hex)
self.assertIsNone(c.management_url)
tenant_list = c.tenants.list()
diff --git a/keystoneclient/tests/unit/v2_0/test_tokens.py b/keystoneclient/tests/unit/v2_0/test_tokens.py
index d60f0f8..968080b 100644
--- a/keystoneclient/tests/unit/v2_0/test_tokens.py
+++ b/keystoneclient/tests/unit/v2_0/test_tokens.py
@@ -152,9 +152,11 @@ class TokenTests(utils.TestCase):
token_fixture = fixture.V2Token()
self.stub_auth(base_url=new_auth_url, json=token_fixture)
- c = client.Client(username=self.TEST_USER,
- auth_url=new_auth_url,
- password=uuid.uuid4().hex)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(username=self.TEST_USER,
+ auth_url=new_auth_url,
+ password=uuid.uuid4().hex)
self.assertIsNone(c.management_url)
diff --git a/keystoneclient/tests/unit/v3/test_auth.py b/keystoneclient/tests/unit/v3/test_auth.py
index 8352528..211633b 100644
--- a/keystoneclient/tests/unit/v3/test_auth.py
+++ b/keystoneclient/tests/unit/v3/test_auth.py
@@ -86,10 +86,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT, subject_token=TEST_TOKEN)
- cs = client.Client(user_id=self.TEST_USER,
- password=self.TEST_TOKEN,
- project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(user_id=self.TEST_USER,
+ password=self.TEST_TOKEN,
+ project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_token, TEST_TOKEN)
self.assertRequestBodyIs(json=self.TEST_REQUEST_BODY)
@@ -105,11 +107,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
# where with assertRaises(exceptions.Unauthorized): doesn't work
# right
def client_create_wrapper():
- client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
- username=self.TEST_USER,
- password="bad_key",
- project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
+ username=self.TEST_USER,
+ password="bad_key",
+ project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL)
self.assertRaises(exceptions.Unauthorized, client_create_wrapper)
self.assertRequestBodyIs(json=self.TEST_REQUEST_BODY)
@@ -121,11 +125,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT,
base_url=self.TEST_ADMIN_URL)
- cs = client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
- username=self.TEST_USER,
- password=self.TEST_TOKEN,
- project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
+ username=self.TEST_USER,
+ password=self.TEST_TOKEN,
+ project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.management_url,
self.TEST_RESPONSE_DICT["token"]["catalog"][3]
@@ -136,11 +142,13 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
def test_authenticate_success_domain_username_password_scoped(self):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
- username=self.TEST_USER,
- password=self.TEST_TOKEN,
- project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
+ username=self.TEST_USER,
+ password=self.TEST_TOKEN,
+ project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.management_url,
self.TEST_RESPONSE_DICT["token"]["catalog"][3]
['endpoints'][2]["url"])
@@ -166,10 +174,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(user_id=self.TEST_USER,
- password=self.TEST_TOKEN,
- domain_id=self.TEST_DOMAIN_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(user_id=self.TEST_USER,
+ password=self.TEST_TOKEN,
+ domain_id=self.TEST_DOMAIN_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_domain_id,
self.TEST_DOMAIN_ID)
self.assertEqual(cs.management_url,
@@ -187,10 +197,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(user_id=self.TEST_USER,
- password=self.TEST_TOKEN,
- project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(user_id=self.TEST_USER,
+ password=self.TEST_TOKEN,
+ project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_tenant_id,
self.TEST_TENANT_ID)
self.assertEqual(cs.management_url,
@@ -206,10 +218,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
- username=self.TEST_USER,
- password=self.TEST_TOKEN,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(user_domain_name=self.TEST_DOMAIN_NAME,
+ username=self.TEST_USER,
+ password=self.TEST_TOKEN,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_token,
self.TEST_RESPONSE_HEADERS["X-Subject-Token"])
self.assertFalse('catalog' in cs.service_catalog.catalog)
@@ -224,8 +238,10 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_url('GET', [fake_url], json=fake_resp,
base_url=self.TEST_ADMIN_IDENTITY_ENDPOINT)
- cl = client.Client(auth_url=self.TEST_URL,
- token=fake_token)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(auth_url=self.TEST_URL,
+ token=fake_token)
body = jsonutils.loads(self.requests_mock.last_request.body)
self.assertEqual(body['auth']['identity']['token']['id'], fake_token)
@@ -258,9 +274,11 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(token=self.TEST_TOKEN,
- domain_id=self.TEST_DOMAIN_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(token=self.TEST_TOKEN,
+ domain_id=self.TEST_DOMAIN_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_domain_id,
self.TEST_DOMAIN_ID)
self.assertEqual(cs.management_url,
@@ -280,9 +298,11 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(token=self.TEST_TOKEN,
- project_id=self.TEST_TENANT_ID,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(token=self.TEST_TOKEN,
+ project_id=self.TEST_TENANT_ID,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_tenant_id,
self.TEST_TENANT_ID)
self.assertEqual(cs.management_url,
@@ -304,8 +324,10 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_auth(json=self.TEST_RESPONSE_DICT)
- cs = client.Client(token=self.TEST_TOKEN,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client(token=self.TEST_TOKEN,
+ auth_url=self.TEST_URL)
self.assertEqual(cs.auth_token,
self.TEST_RESPONSE_HEADERS["X-Subject-Token"])
self.assertFalse('catalog' in cs.service_catalog.catalog)
@@ -320,10 +342,12 @@ class AuthenticateAgainstKeystoneTests(utils.TestCase):
self.stub_url('GET', [fake_url], json=fake_resp,
base_url=self.TEST_ADMIN_IDENTITY_ENDPOINT)
- cl = client.Client(username='exampleuser',
- password='password',
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
self.assertEqual(cl.auth_token, self.TEST_TOKEN)
diff --git a/keystoneclient/tests/unit/v3/test_client.py b/keystoneclient/tests/unit/v3/test_client.py
index 82e0798..e35810e 100644
--- a/keystoneclient/tests/unit/v3/test_client.py
+++ b/keystoneclient/tests/unit/v3/test_client.py
@@ -30,10 +30,12 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.unscoped_token()
self.stub_auth(json=token)
- c = client.Client(user_domain_name=token.user_domain_name,
- username=token.user_name,
- password='password',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(user_domain_name=token.user_domain_name,
+ username=token.user_name,
+ password='password',
+ auth_url=self.TEST_URL)
self.assertIsNotNone(c.auth_ref)
self.assertFalse(c.auth_ref.domain_scoped)
self.assertFalse(c.auth_ref.project_scoped)
@@ -47,10 +49,12 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.domain_scoped_token()
self.stub_auth(json=token)
- c = client.Client(user_id=token.user_id,
- password='password',
- domain_name=token.domain_name,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(user_id=token.user_id,
+ password='password',
+ domain_name=token.domain_name,
+ auth_url=self.TEST_URL)
self.assertIsNotNone(c.auth_ref)
self.assertTrue(c.auth_ref.domain_scoped)
self.assertFalse(c.auth_ref.project_scoped)
@@ -61,11 +65,13 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.project_scoped_token()
self.stub_auth(json=token),
- c = client.Client(user_id=token.user_id,
- password='password',
- user_domain_name=token.user_domain_name,
- project_name=token.project_name,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(user_id=token.user_id,
+ password='password',
+ user_domain_name=token.user_domain_name,
+ project_name=token.project_name,
+ auth_url=self.TEST_URL)
self.assertIsNotNone(c.auth_ref)
self.assertFalse(c.auth_ref.domain_scoped)
self.assertTrue(c.auth_ref.project_scoped)
@@ -78,12 +84,16 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.project_scoped_token()
self.stub_auth(json=token)
- c = client.Client(user_id=token.user_id,
- password='password',
- project_id=token.project_id,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(user_id=token.user_id,
+ password='password',
+ project_id=token.project_id,
+ auth_url=self.TEST_URL)
cache = json.dumps(c.auth_ref)
- new_client = client.Client(auth_ref=json.loads(cache))
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ new_client = client.Client(auth_ref=json.loads(cache))
self.assertIsNotNone(new_client.auth_ref)
self.assertFalse(new_client.auth_ref.domain_scoped)
self.assertTrue(new_client.auth_ref.project_scoped)
@@ -108,13 +118,17 @@ class KeystoneClientTest(utils.TestCase):
self.stub_auth(json=first)
self.stub_auth(json=second, base_url=new_auth_url)
- c = client.Client(user_id=user_id,
- password='password',
- project_id=project_id,
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(user_id=user_id,
+ password='password',
+ project_id=project_id,
+ auth_url=self.TEST_URL)
cache = json.dumps(c.auth_ref)
- new_client = client.Client(auth_ref=json.loads(cache),
- auth_url=new_auth_url)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ new_client = client.Client(auth_ref=json.loads(cache),
+ auth_url=new_auth_url)
self.assertIsNotNone(new_client.auth_ref)
self.assertFalse(new_client.auth_ref.domain_scoped)
self.assertTrue(new_client.auth_ref.project_scoped)
@@ -128,11 +142,13 @@ class KeystoneClientTest(utils.TestCase):
token = client_fixtures.trust_token()
self.stub_auth(json=token)
- c = client.Client(user_domain_name=token.user_domain_name,
- username=token.user_name,
- password='password',
- auth_url=self.TEST_URL,
- trust_id=token.trust_id)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ c = client.Client(user_domain_name=token.user_domain_name,
+ username=token.user_name,
+ password='password',
+ auth_url=self.TEST_URL,
+ trust_id=token.trust_id)
self.assertIsNotNone(c.auth_ref)
self.assertFalse(c.auth_ref.domain_scoped)
self.assertFalse(c.auth_ref.project_scoped)
@@ -143,10 +159,12 @@ class KeystoneClientTest(utils.TestCase):
self.assertEqual(token.user_id, c.auth_user_id)
def test_init_err_no_auth_url(self):
- self.assertRaises(exceptions.AuthorizationFailure,
- client.Client,
- username='exampleuser',
- password='password')
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ self.assertRaises(exceptions.AuthorizationFailure,
+ client.Client,
+ username='exampleuser',
+ password='password')
def _management_url_is_updated(self, fixture, **kwargs):
second = copy.deepcopy(fixture)
@@ -171,10 +189,12 @@ class KeystoneClientTest(utils.TestCase):
self.stub_auth(response_list=[{'json': fixture}, {'json': second}])
- cl = client.Client(username='exampleuser',
- password='password',
- auth_url=self.TEST_URL,
- **kwargs)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cl = client.Client(username='exampleuser',
+ password='password',
+ auth_url=self.TEST_URL,
+ **kwargs)
self.assertEqual(cl.management_url, first_url)
cl.authenticate()
@@ -212,10 +232,12 @@ class KeystoneClientTest(utils.TestCase):
'http://glance.south.host/glanceapi/public')
def test_client_without_auth_params(self):
- self.assertRaises(exceptions.AuthorizationFailure,
- client.Client,
- project_name='exampleproject',
- auth_url=self.TEST_URL)
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ self.assertRaises(exceptions.AuthorizationFailure,
+ client.Client,
+ project_name='exampleproject',
+ auth_url=self.TEST_URL)
def test_client_params(self):
opts = {'auth': token_endpoint.Token('a', 'b'),
diff --git a/keystoneclient/tests/unit/v3/test_discover.py b/keystoneclient/tests/unit/v3/test_discover.py
index ae88bb4..898d46b 100644
--- a/keystoneclient/tests/unit/v3/test_discover.py
+++ b/keystoneclient/tests/unit/v3/test_discover.py
@@ -65,7 +65,9 @@ class DiscoverKeystoneTests(utils.UnauthenticatedTestCase):
status_code=300,
json=self.TEST_RESPONSE_DICT)
- cs = client.Client()
+ # Creating a HTTPClient not using session is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ cs = client.Client()
versions = cs.discover()
self.assertIsInstance(versions, dict)
self.assertIn('message', versions)
diff --git a/keystoneclient/tests/unit/v3/test_service_catalog.py b/keystoneclient/tests/unit/v3/test_service_catalog.py
index f1bb08f..0e7d55c 100644
--- a/keystoneclient/tests/unit/v3/test_service_catalog.py
+++ b/keystoneclient/tests/unit/v3/test_service_catalog.py
@@ -76,8 +76,10 @@ class ServiceCatalogTest(utils.TestCase):
self.assertEqual(url, "http://glance.north.host/glanceapi/public")
self.AUTH_RESPONSE_BODY['token']['region_name'] = "South"
- auth_ref = access.AccessInfo.factory(self.RESPONSE,
- self.AUTH_RESPONSE_BODY)
+ # Setting region_name on the catalog is deprecated.
+ with self.deprecations.expect_deprecations_here():
+ auth_ref = access.AccessInfo.factory(self.RESPONSE,
+ self.AUTH_RESPONSE_BODY)
sc = auth_ref.service_catalog
url = sc.url_for(service_type='image', endpoint_type='internal')
self.assertEqual(url, "http://glance.south.host/glanceapi/internal")