Deprecate Session
Deprecate the keystoneclient Session object in favour of keystoneauth's Session. Change-Id: I26e000d626a466f63d10d2a961adc698f8de0636 Implements: bp deprecate-to-ksa
This commit is contained in:
@@ -132,6 +132,12 @@ class Session(object):
|
||||
def __init__(self, auth=None, session=None, original_ip=None, verify=True,
|
||||
cert=None, timeout=None, user_agent=None,
|
||||
redirect=_DEFAULT_REDIRECT_LIMIT):
|
||||
warnings.warn(
|
||||
'keystoneclient.session.Session is deprecated as of the 2.1.0 '
|
||||
'release in favor of keystoneauth1.session.Session. It will be '
|
||||
'removed in future releases.',
|
||||
DeprecationWarning)
|
||||
|
||||
if not session:
|
||||
session = requests.Session()
|
||||
# Use TCPKeepAliveAdapter to fix bug 1323862
|
||||
|
@@ -24,7 +24,8 @@ class AccessInfoPluginTests(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(AccessInfoPluginTests, self).setUp()
|
||||
self.session = session.Session()
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.session = session.Session()
|
||||
self.auth_token = uuid.uuid4().hex
|
||||
|
||||
def _plugin(self, **kwargs):
|
||||
|
@@ -41,6 +41,7 @@ class CommonIdentityTests(object):
|
||||
|
||||
def setUp(self):
|
||||
super(CommonIdentityTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
self.TEST_URL = '%s%s' % (self.TEST_ROOT_URL, self.version)
|
||||
self.TEST_ADMIN_URL = '%s%s' % (self.TEST_ROOT_ADMIN_URL, self.version)
|
||||
@@ -316,6 +317,10 @@ class CatalogHackTests(utils.TestCase):
|
||||
V2_URL = BASE_URL + 'v2.0'
|
||||
V3_URL = BASE_URL + 'v3'
|
||||
|
||||
def setUp(self):
|
||||
super(CatalogHackTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def test_getting_endpoints(self):
|
||||
disc = fixture.DiscoveryList(href=self.BASE_URL)
|
||||
self.stub_url('GET',
|
||||
@@ -443,7 +448,9 @@ class GenericAuthPluginTests(utils.TestCase):
|
||||
def setUp(self):
|
||||
super(GenericAuthPluginTests, self).setUp()
|
||||
self.auth = GenericPlugin()
|
||||
self.session = session.Session(auth=self.auth)
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.session = session.Session(auth=self.auth)
|
||||
|
||||
def test_setting_headers(self):
|
||||
text = uuid.uuid4().hex
|
||||
|
@@ -80,6 +80,7 @@ class V2IdentityPlugin(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(V2IdentityPlugin, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
self.TEST_RESPONSE_DICT = {
|
||||
"access": {
|
||||
"token": {
|
||||
|
@@ -120,6 +120,8 @@ class V3IdentityPlugin(utils.TestCase):
|
||||
self.TEST_DISCOVERY_RESPONSE = {
|
||||
'versions': {'values': [fixture.V3Discovery(self.TEST_URL)]}}
|
||||
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
self.TEST_RESPONSE_DICT = {
|
||||
"token": {
|
||||
"methods": [
|
||||
|
@@ -75,8 +75,8 @@ class V3FederatedPlugin(utils.TestCase):
|
||||
self.assertEqual(self.token_url, plugin.federated_token_url)
|
||||
|
||||
def test_unscoped_behaviour(self):
|
||||
sess = session.Session(auth=self.get_plugin())
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
sess = session.Session(auth=self.get_plugin())
|
||||
self.assertEqual(self.unscoped_token_id, sess.get_token())
|
||||
|
||||
self.assertTrue(self.unscoped_mock.called)
|
||||
@@ -84,8 +84,8 @@ class V3FederatedPlugin(utils.TestCase):
|
||||
|
||||
def test_scoped_behaviour(self):
|
||||
auth = self.get_plugin(project_id=self.scoped_token.project_id)
|
||||
sess = session.Session(auth=auth)
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
sess = session.Session(auth=auth)
|
||||
self.assertEqual(self.scoped_token_id, sess.get_token())
|
||||
|
||||
self.assertTrue(self.unscoped_mock.called)
|
||||
|
@@ -22,6 +22,10 @@ class TokenEndpointTest(utils.TestCase):
|
||||
TEST_TOKEN = 'aToken'
|
||||
TEST_URL = 'http://server/prefix'
|
||||
|
||||
def setUp(self):
|
||||
super(TokenEndpointTest, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def test_basic_case(self):
|
||||
self.requests_mock.get(self.TEST_URL, text='body')
|
||||
|
||||
|
@@ -106,7 +106,9 @@ class GenericPluginTestCase(utils.TestCase):
|
||||
self.token_v2 = fixture.V2Token()
|
||||
self.token_v3 = fixture.V3Token()
|
||||
self.token_v3_id = uuid.uuid4().hex
|
||||
self.session = session.Session()
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.session = session.Session()
|
||||
|
||||
self.stub_url('POST', ['v2.0', 'tokens'], json=self.token_v2)
|
||||
self.stub_url('POST', ['v3', 'auth', 'tokens'],
|
||||
|
@@ -95,7 +95,10 @@ class KscSessionV2(BaseV2):
|
||||
a = ksc_identity.V2Password(username=uuid.uuid4().hex,
|
||||
password=uuid.uuid4().hex,
|
||||
auth_url=self.TEST_URL)
|
||||
s = ksc_session.Session(auth=a)
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
s = ksc_session.Session(auth=a)
|
||||
|
||||
return v2_client.Client(session=s)
|
||||
|
||||
|
||||
@@ -166,7 +169,10 @@ class KscSessionV3(BaseV3):
|
||||
password=uuid.uuid4().hex,
|
||||
user_domain_id=uuid.uuid4().hex,
|
||||
auth_url=self.TEST_URL)
|
||||
s = ksc_session.Session(auth=a)
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
s = ksc_session.Session(auth=a)
|
||||
|
||||
return v3_client.Client(session=s)
|
||||
|
||||
|
||||
|
@@ -234,6 +234,10 @@ V2_VERSION_ENTRY = _create_single_version(V2_VERSION)
|
||||
|
||||
class AvailableVersionsTests(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(AvailableVersionsTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def test_available_versions_basics(self):
|
||||
examples = {'keystone': V3_VERSION_LIST,
|
||||
'cinder': jsonutils.dumps(CINDER_EXAMPLES),
|
||||
@@ -310,6 +314,10 @@ class AvailableVersionsTests(utils.TestCase):
|
||||
|
||||
class ClientDiscoveryTests(utils.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ClientDiscoveryTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def assertCreatesV3(self, **kwargs):
|
||||
self.requests_mock.post('%s/auth/tokens' % V3_URL,
|
||||
text=V3_AUTH_RESPONSE,
|
||||
@@ -543,7 +551,9 @@ class ClientDiscoveryTests(utils.TestCase):
|
||||
|
||||
url = 'http://testurl'
|
||||
a = token_endpoint.Token(url, token)
|
||||
s = session.Session(auth=a)
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
s = session.Session(auth=a)
|
||||
|
||||
# will default to true as there is a plugin on the session
|
||||
discover.Discover(s, auth_url=BASE_URL, **kwargs)
|
||||
|
@@ -35,6 +35,10 @@ class SessionTests(utils.TestCase):
|
||||
|
||||
TEST_URL = 'http://127.0.0.1:5000/'
|
||||
|
||||
def setUp(self):
|
||||
super(SessionTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def test_get(self):
|
||||
session = client_session.Session()
|
||||
self.stub_url('GET', text='response')
|
||||
@@ -327,6 +331,10 @@ class RedirectTests(utils.TestCase):
|
||||
DEFAULT_REDIRECT_BODY = 'Redirect'
|
||||
DEFAULT_RESP_BODY = 'Found'
|
||||
|
||||
def setUp(self):
|
||||
super(RedirectTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def setup_redirects(self, method='GET', status_code=305,
|
||||
redirect_kwargs=None, final_kwargs=None):
|
||||
redirect_kwargs = redirect_kwargs or {}
|
||||
@@ -501,6 +509,10 @@ class SessionAuthTests(utils.TestCase):
|
||||
TEST_URL = 'http://127.0.0.1:5000/'
|
||||
TEST_JSON = {'hello': 'world'}
|
||||
|
||||
def setUp(self):
|
||||
super(SessionAuthTests, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def stub_service_url(self, service_type, interface, path,
|
||||
method='GET', **kwargs):
|
||||
base_url = AuthPlugin.SERVICE_URLS[service_type][interface]
|
||||
@@ -749,6 +761,10 @@ class AdapterTest(utils.TestCase):
|
||||
|
||||
TEST_URL = CalledAuthPlugin.ENDPOINT
|
||||
|
||||
def setUp(self):
|
||||
super(AdapterTest, self).setUp()
|
||||
self.deprecations.expect_deprecations()
|
||||
|
||||
def _create_loaded_adapter(self):
|
||||
auth = CalledAuthPlugin()
|
||||
sess = client_session.Session()
|
||||
@@ -870,8 +886,7 @@ class AdapterTest(utils.TestCase):
|
||||
sess = client_session.Session()
|
||||
adpt = adapter.Adapter(sess, auth=auth)
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.assertEqual(self.TEST_TOKEN, adpt.get_token())
|
||||
self.assertEqual(self.TEST_TOKEN, adpt.get_token())
|
||||
self.assertTrue(auth.get_token_called)
|
||||
|
||||
def test_adapter_connect_retries(self):
|
||||
@@ -947,10 +962,11 @@ class ConfLoadingTests(utils.TestCase):
|
||||
self.conf_fixture.config(**kwargs)
|
||||
|
||||
def get_session(self, **kwargs):
|
||||
return client_session.Session.load_from_conf_options(
|
||||
self.conf_fixture.conf,
|
||||
self.GROUP,
|
||||
**kwargs)
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
return client_session.Session.load_from_conf_options(
|
||||
self.conf_fixture.conf,
|
||||
self.GROUP,
|
||||
**kwargs)
|
||||
|
||||
def test_insecure_timeout(self):
|
||||
self.config(insecure=True, timeout=5)
|
||||
@@ -1000,7 +1016,8 @@ class CliLoadingTests(utils.TestCase):
|
||||
|
||||
def get_session(self, val, **kwargs):
|
||||
args = self.parser.parse_args(val.split())
|
||||
return client_session.Session.load_from_cli_options(args, **kwargs)
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
return client_session.Session.load_from_cli_options(args, **kwargs)
|
||||
|
||||
def test_insecure_timeout(self):
|
||||
s = self.get_session('--insecure --timeout 5.5')
|
||||
|
@@ -190,6 +190,9 @@ class KeystoneClientTest(utils.TestCase):
|
||||
auth_url=self.TEST_URL)
|
||||
|
||||
def test_client_params(self):
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
sess = session.Session()
|
||||
|
||||
opts = {'auth': token_endpoint.Token('a', 'b'),
|
||||
'connect_retries': 50,
|
||||
'endpoint_override': uuid.uuid4().hex,
|
||||
@@ -199,7 +202,6 @@ class KeystoneClientTest(utils.TestCase):
|
||||
'user_agent': uuid.uuid4().hex,
|
||||
}
|
||||
|
||||
sess = session.Session()
|
||||
cl = client.Client(session=sess, **opts)
|
||||
|
||||
for k, v in six.iteritems(opts):
|
||||
|
@@ -64,7 +64,8 @@ class AuthenticateOIDCTests(utils.TestCase):
|
||||
self.conf_fixture = self.useFixture(config.Config())
|
||||
conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)
|
||||
|
||||
self.session = session.Session()
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.session = session.Session()
|
||||
|
||||
self.IDENTITY_PROVIDER = 'bluepages'
|
||||
self.PROTOCOL = 'oidc'
|
||||
|
@@ -66,7 +66,8 @@ class AuthenticateviaSAML2Tests(utils.TestCase):
|
||||
self.conf_fixture = self.useFixture(config.Config())
|
||||
conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)
|
||||
|
||||
self.session = session.Session()
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.session = session.Session()
|
||||
|
||||
self.ECP_SP_EMPTY_REQUEST_HEADERS = {
|
||||
'Accept': 'text/html; application/vnd.paos+xml',
|
||||
@@ -440,7 +441,9 @@ class AuthenticateviaADFSTests(utils.TestCase):
|
||||
|
||||
self.conf_fixture = self.useFixture(config.Config())
|
||||
conf.register_conf_options(self.conf_fixture.conf, group=self.GROUP)
|
||||
self.session = session.Session(session=requests.Session())
|
||||
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
self.session = session.Session(session=requests.Session())
|
||||
|
||||
self.IDENTITY_PROVIDER = 'adfs'
|
||||
self.IDENTITY_PROVIDER_URL = ('http://adfs.local/adfs/service/trust/13'
|
||||
|
@@ -249,7 +249,9 @@ class KeystoneClientTest(utils.TestCase):
|
||||
'user_agent': uuid.uuid4().hex,
|
||||
}
|
||||
|
||||
sess = session.Session()
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
sess = session.Session()
|
||||
|
||||
cl = client.Client(session=sess, **opts)
|
||||
|
||||
for k, v in six.iteritems(opts):
|
||||
|
@@ -251,8 +251,8 @@ class AuthenticateWithOAuthTests(utils.TestCase, TokenTests):
|
||||
consumer_secret=consumer_secret,
|
||||
access_key=access_key,
|
||||
access_secret=access_secret)
|
||||
s = session.Session(auth=a)
|
||||
with self.deprecations.expect_deprecations_here():
|
||||
s = session.Session(auth=a)
|
||||
t = s.get_token()
|
||||
self.assertEqual(self.TEST_TOKEN, t)
|
||||
|
||||
|
Reference in New Issue
Block a user