Merge "context.elevated() should use copy.deepcopy()"
This commit is contained in:
commit
3ec9917581
@ -149,7 +149,7 @@ class RequestContext(object):
|
||||
|
||||
def elevated(self, read_deleted=None, overwrite=False):
|
||||
"""Return a version of this context with admin flag set."""
|
||||
context = copy.copy(self)
|
||||
context = self.deepcopy()
|
||||
context.is_admin = True
|
||||
|
||||
if 'admin' not in context.roles:
|
||||
|
@ -54,6 +54,16 @@ class ContextTestCase(test.TestCase):
|
||||
'read_deleted',
|
||||
True)
|
||||
|
||||
def test_request_context_elevated(self):
|
||||
user_context = context.RequestContext(
|
||||
'fake_user', 'fake_project', admin=False)
|
||||
self.assertFalse(user_context.is_admin)
|
||||
admin_context = user_context.elevated()
|
||||
self.assertFalse(user_context.is_admin)
|
||||
self.assertTrue(admin_context.is_admin)
|
||||
self.assertFalse('admin' in user_context.roles)
|
||||
self.assertTrue('admin' in admin_context.roles)
|
||||
|
||||
def test_service_catalog_nova_and_swift(self):
|
||||
service_catalog = [
|
||||
{u'type': u'compute', u'name': u'nova'},
|
||||
|
Loading…
Reference in New Issue
Block a user