diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-09-03 22:48:22 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-09-03 22:48:22 +0000 |
commit | 6231459156c7ffcea574efb2e01ce0b5ec78d9ac (patch) | |
tree | 483e0c248a78f66f4c313102029e1b41a4fec1f8 | |
parent | 1bff68f9b8d8f6bed843d910fb4e1b69b64ded7a (diff) | |
parent | 1697fd7198eadf314243f55a4da095871c1b9a7c (diff) | |
download | python-keystoneclient-6231459156c7ffcea574efb2e01ce0b5ec78d9ac.tar.gz |
Merge "Deprecate create Discover without session"1.7.0
-rw-r--r-- | keystoneclient/discover.py | 46 | ||||
-rw-r--r-- | keystoneclient/tests/unit/test_discovery.py | 46 |
2 files changed, 64 insertions, 28 deletions
diff --git a/keystoneclient/discover.py b/keystoneclient/discover.py index f3f250f..62aec44 100644 --- a/keystoneclient/discover.py +++ b/keystoneclient/discover.py @@ -11,6 +11,7 @@ # under the License. import logging +import warnings from debtcollector import removals import six @@ -96,6 +97,12 @@ class Discover(_discover.Discover): In the event that auth_url and endpoint is provided then auth_url will be used in accordance with how the client operates. + .. warning:: + + Creating an instance of this class without using the session argument + is deprecated as of the 1.7.0 release and may be removed in the 2.0.0 + release. + :param session: A session object that will be used for communication. Clients will also be constructed with this session. :type session: keystoneclient.session.Session @@ -105,35 +112,38 @@ class Discover(_discover.Discover): service. (optional) :param string original_ip: The original IP of the requesting user which will be sent to identity service in a - 'Forwarded' header. (optional) DEPRECATED: use - the session object. This is ignored if a session - is provided. + 'Forwarded' header. (optional) This is ignored + if a session is provided. Deprecated as of the + 1.7.0 release and may be removed in the 2.0.0 + release. :param boolean debug: Enables debug logging of all request and responses to the identity service. default False (optional) - DEPRECATED: use the session object. This is ignored - if a session is provided. + This is ignored if a session is provided. Deprecated + as of the 1.7.0 release and may be removed in the + 2.0.0 release. :param string cacert: Path to the Privacy Enhanced Mail (PEM) file which contains the trusted authority X.509 certificates needed to established SSL connection with the - identity service. (optional) DEPRECATED: use the - session object. This is ignored if a session is - provided. + identity service. (optional) This is ignored if a + session is provided. Deprecated as of the 1.7.0 + release and may be removed in the 2.0.0 release. :param string key: Path to the Privacy Enhanced Mail (PEM) file which contains the unencrypted client private key needed to established two-way SSL connection with the identity - service. (optional) DEPRECATED: use the session object. - This is ignored if a session is provided. + service. (optional) This is ignored if a session is + provided. Deprecated as of the 1.7.0 release and may be + removed in the 2.0.0 release. :param string cert: Path to the Privacy Enhanced Mail (PEM) file which contains the corresponding X.509 client certificate needed to established two-way SSL connection with the - identity service. (optional) DEPRECATED: use the - session object. This is ignored if a session is - provided. + identity service. (optional) This is ignored if a + session is provided. Deprecated as of the 1.7.0 release + and may be removed in the 2.0.0 release. :param boolean insecure: Does not perform X.509 certificate validation when establishing SSL connection with identity service. - default: False (optional) DEPRECATED: use the - session object. This is ignored if a session is - provided. + default: False (optional) This is ignored if a + session is provided. Deprecated as of the 1.7.0 + release and may be removed in the 2.0.0 release. :param bool authenticated: Should a token be used to perform the initial discovery operations. default: None (attach a token if an auth plugin is available). @@ -143,6 +153,10 @@ class Discover(_discover.Discover): @utils.positional(2) def __init__(self, session=None, authenticated=None, **kwargs): if not session: + warnings.warn( + 'Constructing a Discover instance without using a session is ' + 'deprecated as of the 1.7.0 release and may be removed in the ' + '2.0.0 release.', DeprecationWarning) session = client_session.Session._construct(kwargs) kwargs['session'] = session diff --git a/keystoneclient/tests/unit/test_discovery.py b/keystoneclient/tests/unit/test_discovery.py index 34901ba..4ae0fef 100644 --- a/keystoneclient/tests/unit/test_discovery.py +++ b/keystoneclient/tests/unit/test_discovery.py @@ -484,8 +484,10 @@ class ClientDiscoveryTests(utils.TestCase): text=V3_AUTH_RESPONSE, headers={'X-Subject-Token': V3_TOKEN}) - disc = discover.Discover(auth_url=BASE_URL, debug=False, - username='foo') + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL, debug=False, + username='foo') client = disc.create_client(debug=True, password='bar') self.assertIsInstance(client, v3_client.Client) @@ -498,7 +500,9 @@ class ClientDiscoveryTests(utils.TestCase): self.requests_mock.get(BASE_URL, status_code=300, text=V3_VERSION_ENTRY) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) with self.deprecations.expect_deprecations_here(): versions = disc.available_versions() @@ -515,7 +519,9 @@ class ClientDiscoveryTests(utils.TestCase): versions.add_version(V4_VERSION) self.requests_mock.get(BASE_URL, status_code=300, json=versions) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) self.assertRaises(exceptions.DiscoveryFailure, disc.create_client, version=4) @@ -523,7 +529,9 @@ class ClientDiscoveryTests(utils.TestCase): versions = fixture.DiscoveryList(v2=True, v3=False) self.requests_mock.get(BASE_URL, status_code=300, json=versions) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) self.assertRaises(exceptions.DiscoveryFailure, disc.create_client, version=(3, 0)) @@ -558,7 +566,9 @@ class DiscoverQueryTests(utils.TestCase): def test_available_keystone_data(self): self.requests_mock.get(BASE_URL, status_code=300, text=V3_VERSION_LIST) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) versions = disc.version_data() self.assertEqual((2, 0), versions[0]['version']) @@ -589,7 +599,9 @@ class DiscoverQueryTests(utils.TestCase): v1_url = "%sv1/" % BASE_URL v2_url = "%sv2/" % BASE_URL - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) versions = disc.version_data() self.assertEqual((1, 0), versions[0]['version']) @@ -620,7 +632,9 @@ class DiscoverQueryTests(utils.TestCase): v1_url = "%sv1/" % BASE_URL v2_url = "%sv2/" % BASE_URL - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) versions = disc.version_data() self.assertEqual((1, 0), versions[0]['version']) @@ -666,7 +680,9 @@ class DiscoverQueryTests(utils.TestCase): text = jsonutils.dumps({'versions': version_list}) self.requests_mock.get(BASE_URL, text=text) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) # deprecated is allowed by default versions = disc.version_data(allow_deprecated=False) @@ -688,7 +704,9 @@ class DiscoverQueryTests(utils.TestCase): text = jsonutils.dumps({'versions': version_list}) self.requests_mock.get(BASE_URL, text=text) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) versions = disc.version_data() self.assertEqual(0, len(versions)) @@ -704,7 +722,9 @@ class DiscoverQueryTests(utils.TestCase): version_list = fixture.DiscoveryList(BASE_URL, v2=False, v3_status=status) self.requests_mock.get(BASE_URL, json=version_list) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) versions = disc.version_data() self.assertEqual(0, len(versions)) @@ -734,7 +754,9 @@ class DiscoverQueryTests(utils.TestCase): text = jsonutils.dumps({'versions': version_list}) self.requests_mock.get(BASE_URL, text=text) - disc = discover.Discover(auth_url=BASE_URL) + # Creating Discover not using session is deprecated. + with self.deprecations.expect_deprecations_here(): + disc = discover.Discover(auth_url=BASE_URL) # raw_version_data will return all choices, even invalid ones versions = disc.raw_version_data() |