Use keystone group for loading auth params
This really needs to come from mistral-extra. Change-Id: I8c1ff35df46347c2f247f74720942f9884908449 Partial-Bug: #1595084 Partial-Bug: #1761050
This commit is contained in:
parent
2dfed4e87a
commit
0f17aecbe9
|
@ -54,8 +54,9 @@ class TestActionsBase(tests_base.TestCase):
|
||||||
cache_key
|
cache_key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch("tripleo_common.utils.keystone.get_session_and_auth")
|
||||||
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
||||||
def test_cache_set(self, mock_conn, mock_endpoint):
|
def test_cache_set(self, mock_conn, mock_keystone, mock_endpoint):
|
||||||
mock_ctx = mock.Mock()
|
mock_ctx = mock.Mock()
|
||||||
mock_swift = mock.Mock()
|
mock_swift = mock.Mock()
|
||||||
mock_conn.return_value = mock_swift
|
mock_conn.return_value = mock_swift
|
||||||
|
@ -74,8 +75,9 @@ class TestActionsBase(tests_base.TestCase):
|
||||||
)
|
)
|
||||||
mock_swift.delete_object.assert_not_called()
|
mock_swift.delete_object.assert_not_called()
|
||||||
|
|
||||||
|
@mock.patch("tripleo_common.utils.keystone.get_session_and_auth")
|
||||||
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
||||||
def test_cache_set_none(self, mock_conn, mock_endpoint):
|
def test_cache_set_none(self, mock_conn, mock_keystone, mock_endpoint):
|
||||||
mock_ctx = mock.Mock()
|
mock_ctx = mock.Mock()
|
||||||
mock_swift = mock.Mock()
|
mock_swift = mock.Mock()
|
||||||
mock_conn.return_value = mock_swift
|
mock_conn.return_value = mock_swift
|
||||||
|
@ -92,8 +94,9 @@ class TestActionsBase(tests_base.TestCase):
|
||||||
cache_key
|
cache_key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch("tripleo_common.utils.keystone.get_session_and_auth")
|
||||||
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
||||||
def test_cache_get_filled(self, mock_conn, mock_endpoint):
|
def test_cache_get_filled(self, mock_conn, mock_keystone, mock_endpoint):
|
||||||
mock_ctx = mock.Mock()
|
mock_ctx = mock.Mock()
|
||||||
mock_swift = mock.Mock()
|
mock_swift = mock.Mock()
|
||||||
mock_conn.return_value = mock_swift
|
mock_conn.return_value = mock_swift
|
||||||
|
@ -106,8 +109,9 @@ class TestActionsBase(tests_base.TestCase):
|
||||||
result = self.action.cache_get(mock_ctx, container, key)
|
result = self.action.cache_get(mock_ctx, container, key)
|
||||||
self.assertEqual(result, {"foo": 1})
|
self.assertEqual(result, {"foo": 1})
|
||||||
|
|
||||||
|
@mock.patch("tripleo_common.utils.keystone.get_session_and_auth")
|
||||||
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
||||||
def test_cache_empty(self, mock_conn, mock_endpoint):
|
def test_cache_empty(self, mock_conn, mock_keystone, mock_endpoint):
|
||||||
mock_ctx = mock.Mock()
|
mock_ctx = mock.Mock()
|
||||||
mock_swift = mock.Mock()
|
mock_swift = mock.Mock()
|
||||||
mock_conn.return_value = mock_swift
|
mock_conn.return_value = mock_swift
|
||||||
|
@ -130,8 +134,9 @@ class TestActionsBase(tests_base.TestCase):
|
||||||
cache_key
|
cache_key
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@mock.patch("tripleo_common.utils.keystone.get_session_and_auth")
|
||||||
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
@mock.patch("tripleo_common.actions.base.swift_client.Connection")
|
||||||
def test_cache_delete(self, mock_conn, mock_endpoint):
|
def test_cache_delete(self, mock_conn, mock_keystone, mock_endpoint):
|
||||||
mock_ctx = mock.Mock()
|
mock_ctx = mock.Mock()
|
||||||
mock_swift = mock.Mock()
|
mock_swift = mock.Mock()
|
||||||
mock_conn.return_value = mock_swift
|
mock_conn.return_value = mock_swift
|
||||||
|
|
|
@ -63,26 +63,44 @@ def get_session_and_auth(context, **kwargs):
|
||||||
if not context:
|
if not context:
|
||||||
raise AssertionError('context is mandatory')
|
raise AssertionError('context is mandatory')
|
||||||
|
|
||||||
project_endpoint = get_endpoint_for_project(context, **kwargs)
|
if context.trust_id:
|
||||||
endpoint = format_url(
|
kwargs['project_name'] = None
|
||||||
project_endpoint.url,
|
kwargs['project_domain_name'] = None
|
||||||
{
|
kwargs['project_id'] = None
|
||||||
'tenant_id': context.project_id,
|
kwargs['trust_id'] = context.trust_id
|
||||||
'project_id': context.project_id
|
kwargs.pop('service_name')
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
auth = Token(endpoint=endpoint, token=context.auth_token)
|
auth = loading.load_auth_from_conf_options(
|
||||||
|
CONF,
|
||||||
|
'keystone_authtoken',
|
||||||
|
**kwargs
|
||||||
|
)
|
||||||
|
session = loading.load_session_from_conf_options(
|
||||||
|
CONF,
|
||||||
|
'keystone',
|
||||||
|
auth=auth
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
project_endpoint = get_endpoint_for_project(context, **kwargs)
|
||||||
|
endpoint = format_url(
|
||||||
|
project_endpoint.url,
|
||||||
|
{
|
||||||
|
'tenant_id': context.project_id,
|
||||||
|
'project_id': context.project_id
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
auth_uri = context.auth_uri or CONF.keystone_authtoken.auth_uri
|
auth = Token(endpoint=endpoint, token=context.auth_token)
|
||||||
ks_auth = Token(
|
|
||||||
endpoint=auth_uri,
|
auth_uri = context.auth_uri or CONF.keystone_authtoken.auth_uri
|
||||||
token=context.auth_token
|
ks_auth = Token(
|
||||||
)
|
endpoint=auth_uri,
|
||||||
session = ks_session.Session(
|
token=context.auth_token
|
||||||
auth=ks_auth,
|
)
|
||||||
verify=_determine_verify(context)
|
session = ks_session.Session(
|
||||||
)
|
auth=ks_auth,
|
||||||
|
verify=_determine_verify(context)
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"session": session,
|
"session": session,
|
||||||
|
@ -117,6 +135,8 @@ def _admin_client(trust_id=None):
|
||||||
if trust_id:
|
if trust_id:
|
||||||
# Remove project_name and project_id, since we need a trust scoped
|
# Remove project_name and project_id, since we need a trust scoped
|
||||||
# auth object
|
# auth object
|
||||||
|
kwargs['domain_id'] = None
|
||||||
|
kwargs['domain_name'] = None
|
||||||
kwargs['project_name'] = None
|
kwargs['project_name'] = None
|
||||||
kwargs['project_domain_name'] = None
|
kwargs['project_domain_name'] = None
|
||||||
kwargs['project_id'] = None
|
kwargs['project_id'] = None
|
||||||
|
@ -129,7 +149,7 @@ def _admin_client(trust_id=None):
|
||||||
)
|
)
|
||||||
sess = loading.load_session_from_conf_options(
|
sess = loading.load_session_from_conf_options(
|
||||||
CONF,
|
CONF,
|
||||||
'keystone_authtoken',
|
'keystone',
|
||||||
auth=auth
|
auth=auth
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue