Merge "Remove warnings for dropped context arguments"
This commit is contained in:
commit
5d8257cabd
manila
@ -20,15 +20,12 @@
|
||||
import copy
|
||||
|
||||
from oslo_context import context
|
||||
from oslo_log import log
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from manila.i18n import _, _LW
|
||||
from manila.i18n import _
|
||||
from manila import policy
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class RequestContext(context.RequestContext):
|
||||
"""Security context and request information.
|
||||
@ -71,10 +68,6 @@ class RequestContext(context.RequestContext):
|
||||
overwrite=overwrite,
|
||||
roles=roles)
|
||||
|
||||
kwargs.pop('user_identity', None)
|
||||
if kwargs:
|
||||
LOG.warning(_LW('Arguments dropped when creating context: %s.'),
|
||||
str(kwargs))
|
||||
self.user_id = self.user
|
||||
self.project_id = self.tenant
|
||||
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
|
||||
from manila import context
|
||||
from manila import test
|
||||
|
||||
@ -66,59 +64,6 @@ class ContextTestCase(test.TestCase):
|
||||
'read_deleted',
|
||||
True)
|
||||
|
||||
def test_extra_args_to_context_get_logged(self):
|
||||
info = {}
|
||||
|
||||
def fake_warn(log_msg, other_args):
|
||||
info['log_msg'] = log_msg % other_args
|
||||
|
||||
self.mock_object(context.LOG, 'warning', fake_warn)
|
||||
|
||||
c = context.RequestContext('user',
|
||||
'project',
|
||||
extra_arg1='meow',
|
||||
extra_arg2='wuff',
|
||||
user='user',
|
||||
tenant='project')
|
||||
self.assertTrue(c)
|
||||
self.assertIn("'extra_arg1': 'meow'", info['log_msg'])
|
||||
self.assertIn("'extra_arg2': 'wuff'", info['log_msg'])
|
||||
# user and tenant kwargs get popped off before we log anything
|
||||
self.assertNotIn("'user': 'user'", info['log_msg'])
|
||||
self.assertNotIn("'tenant': 'project'", info['log_msg'])
|
||||
|
||||
def test_normal_kwargs_are_used_so_not_logged(self):
|
||||
|
||||
mock_log = self.mock_object(context.LOG, 'warning', mock.Mock())
|
||||
|
||||
# Supply the kwargs normally supplied to RequestContext
|
||||
# for scheduler and share service.
|
||||
context.RequestContext('user',
|
||||
'project',
|
||||
is_admin=None,
|
||||
read_deleted="no",
|
||||
roles=None,
|
||||
remote_address=None,
|
||||
timestamp=None,
|
||||
request_id=None,
|
||||
auth_token=None,
|
||||
overwrite=True,
|
||||
quota_class=None,
|
||||
service_catalog=None,
|
||||
read_only=False,
|
||||
domain=None,
|
||||
show_deleted=False,
|
||||
user_identity='- - - - -',
|
||||
project_domain=None,
|
||||
resource_uuid=None,
|
||||
user_domain=None,
|
||||
user='user',
|
||||
tenant='project')
|
||||
|
||||
# Assert that there is no log warning that there were
|
||||
# extra kwargs that were dropped.
|
||||
self.assertEqual(0, mock_log.call_count)
|
||||
|
||||
def test_to_dict_works_w_missing_manila_context_attributes(self):
|
||||
manila_context_attributes = ['user_id', 'project_id', 'read_deleted',
|
||||
'remote_address', 'timestamp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user