Resolve misc deprecation warnings
These were highlighted by the new 'WarningsFixture'. Change-Id: I07beae9c9e518eeaae66d8d6accfdd16753de152 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
f1e03aadae
commit
61927304d4
@ -233,7 +233,7 @@ class ACLMixin(object):
|
||||
if not ctxt:
|
||||
return {}
|
||||
acl_dict = {acl.operation: acl.operation for acl in acl_list
|
||||
if ctxt.user in acl.to_dict_fields().get('users', [])}
|
||||
if ctxt.user_id in acl.to_dict_fields().get('users', [])}
|
||||
co_dict = {'%s_project_access' % acl.operation: acl.project_access for
|
||||
acl in acl_list if acl.project_access is not None}
|
||||
if not co_dict:
|
||||
|
@ -185,7 +185,7 @@ class ContainersController(controllers.ACLMixin):
|
||||
data = api.load_body(pecan.request, validator=self.validator)
|
||||
ctxt = controllers._get_barbican_context(pecan.request)
|
||||
if ctxt: # in authenticated pipleline case, always use auth token user
|
||||
data['creator_id'] = ctxt.user
|
||||
data['creator_id'] = ctxt.user_id
|
||||
|
||||
self.quota_enforcer.enforce(project)
|
||||
|
||||
|
@ -188,7 +188,7 @@ class OrdersController(controllers.ACLMixin):
|
||||
request_id = None
|
||||
ctxt = controllers._get_barbican_context(pecan.request)
|
||||
if ctxt:
|
||||
new_order.creator_id = ctxt.user
|
||||
new_order.creator_id = ctxt.user_id
|
||||
request_id = ctxt.request_id
|
||||
|
||||
self.order_repo.create_from(new_order)
|
||||
|
@ -398,7 +398,7 @@ class SecretsController(controllers.ACLMixin):
|
||||
ctxt = controllers._get_barbican_context(pecan.request)
|
||||
user_id = None
|
||||
if ctxt:
|
||||
user_id = ctxt.user
|
||||
user_id = ctxt.user_id
|
||||
|
||||
result = self.secret_repo.get_secret_list(
|
||||
external_project_id,
|
||||
@ -455,7 +455,7 @@ class SecretsController(controllers.ACLMixin):
|
||||
'false').lower() == 'true'
|
||||
ctxt = controllers._get_barbican_context(pecan.request)
|
||||
if ctxt: # in authenticated pipleline case, always use auth token user
|
||||
data['creator_id'] = ctxt.user
|
||||
data['creator_id'] = ctxt.user_id
|
||||
|
||||
secret_model = models.Secret(data)
|
||||
|
||||
|
@ -76,7 +76,7 @@ class ContextMiddleware(BaseContextMiddleware):
|
||||
|
||||
def _get_anonymous_context(self):
|
||||
kwargs = {
|
||||
'user': None,
|
||||
'user_id': None,
|
||||
'tenant': None,
|
||||
'is_admin': False,
|
||||
'read_only': True,
|
||||
@ -121,7 +121,7 @@ class UnauthenticatedContextMiddleware(BaseContextMiddleware):
|
||||
roles = [config_admin_role]
|
||||
|
||||
kwargs = {
|
||||
'user': req.headers.get('X-User-Id'),
|
||||
'user_id': req.headers.get('X-User-Id'),
|
||||
'domain': req.headers.get('X-Domain-Id'),
|
||||
'user_domain': req.headers.get('X-User-Domain-Id'),
|
||||
'project_domain': req.headers.get('X-Project-Domain-Id'),
|
||||
|
@ -176,7 +176,8 @@ def _get_engine(engine):
|
||||
# connection_dict = sqlalchemy.engine.url.make_url(_CONNECTION)
|
||||
|
||||
engine_args = {
|
||||
'idle_timeout': CONF.sql_idle_timeout}
|
||||
'connection_recycle_time': CONF.sql_idle_timeout,
|
||||
}
|
||||
if CONF.sql_pool_size:
|
||||
engine_args['max_pool_size'] = CONF.sql_pool_size
|
||||
if CONF.sql_pool_max_overflow:
|
||||
|
@ -29,7 +29,7 @@ class TestACLsWithContextMixin(test_policy.BaseTestCase):
|
||||
# define creator user for new secret entry.
|
||||
app.extra_environ = {
|
||||
'barbican.context': self._build_context(self.project_id,
|
||||
user=creator_user_id)
|
||||
user_id=creator_user_id)
|
||||
}
|
||||
secret_id, _ = create_secret(app)
|
||||
return secret_id
|
||||
@ -39,7 +39,7 @@ class TestACLsWithContextMixin(test_policy.BaseTestCase):
|
||||
# define creator user for new container entry.
|
||||
app.extra_environ = {
|
||||
'barbican.context': self._build_context(self.project_id,
|
||||
user=creator_user_id)
|
||||
user_id=creator_user_id)
|
||||
}
|
||||
container_id, _ = create_container(app)
|
||||
return container_id
|
||||
@ -56,7 +56,7 @@ class TestACLsWithContextMixin(test_policy.BaseTestCase):
|
||||
policy_enforcer = self.policy_enforcer if enforce_policy else None
|
||||
app.extra_environ = {
|
||||
'barbican.context': self._build_context(
|
||||
self.project_id, roles=roles, user=user,
|
||||
self.project_id, roles=roles, user_id=user,
|
||||
is_admin=False, policy_enforcer=policy_enforcer)
|
||||
}
|
||||
resp = None
|
||||
|
@ -35,7 +35,7 @@ class TestUnauthenticatedContextMiddleware(utils.BaseTestCase):
|
||||
rc.assert_called_with(
|
||||
project_id='trace',
|
||||
is_admin=True,
|
||||
user=None,
|
||||
user_id=None,
|
||||
roles=['admin'],
|
||||
request_id=request.request_id,
|
||||
project_domain=None,
|
||||
@ -53,7 +53,7 @@ class TestUnauthenticatedContextMiddleware(utils.BaseTestCase):
|
||||
rc.assert_called_with(
|
||||
project_id='trace',
|
||||
is_admin=False,
|
||||
user=None,
|
||||
user_id=None,
|
||||
roles=['something'],
|
||||
request_id=request.request_id,
|
||||
project_domain=None,
|
||||
|
@ -254,7 +254,7 @@ class WhenTestingGetEnginePrivate(utils.BaseTestCase):
|
||||
engine.connect.assert_called_once_with()
|
||||
mock_create_engine.assert_called_once_with(
|
||||
'connection',
|
||||
idle_timeout=3600,
|
||||
connection_recycle_time=3600,
|
||||
max_pool_size=repositories.CONF.sql_pool_size,
|
||||
max_overflow=repositories.CONF.sql_pool_max_overflow
|
||||
)
|
||||
@ -278,7 +278,7 @@ class WhenTestingGetEnginePrivate(utils.BaseTestCase):
|
||||
engine.connect.assert_called_once_with()
|
||||
mock_create_engine.assert_called_once_with(
|
||||
'connection',
|
||||
idle_timeout=3600,
|
||||
connection_recycle_time=3600,
|
||||
max_pool_size=22,
|
||||
max_overflow=11
|
||||
)
|
||||
|
@ -61,11 +61,13 @@ class BarbicanAPIBaseTestCase(oslotest.BaseTestCase):
|
||||
"""Base TestCase for all tests needing to interact with a Barbican app."""
|
||||
root_controller = None
|
||||
|
||||
def _build_context(self, project_id, roles=None, user=None, is_admin=True,
|
||||
policy_enforcer=None):
|
||||
def _build_context(
|
||||
self, project_id, roles=None, user_id=None, is_admin=True,
|
||||
policy_enforcer=None,
|
||||
):
|
||||
context = barbican.context.RequestContext(
|
||||
roles=roles,
|
||||
user=user,
|
||||
user_id=user_id,
|
||||
project_id=project_id,
|
||||
is_admin=is_admin
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user