summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Johnson <johnsomor@gmail.com>2021-07-14 22:50:06 +0000
committerHervé Beraud <hberaud@redhat.com>2021-10-25 15:39:59 +0200
commiteff2f2f57248f17189d088901f39dc4ab7b0afe3 (patch)
treedf32fa2e5734bcc4e79a1183ea92cbf2ce71dd4c
parent5835e5d8e4d82b8200c1d00cd65ac72c4f646899 (diff)
downloadoslo-context-stable/victoria.tar.gz
Fix context from_dict() for system_scopevictoria-em3.1.2stable/victoria
A previous patch[1] added "system_scope" to the context for to_dict() but the from_dict() method was not updated. This caused the system_scope to always be None. This patch corrects that by adding "system_scope" to the list of values that may need to be extracted from the context dict. [1] https://review.opendev.org/c/openstack/oslo.context/+/530509 Change-Id: Ica23d5c4183a692de3cb65a7ad72b19f47988ca6 (cherry picked from commit 8290621b058081754db55c2584c00b8b166369aa) (cherry picked from commit 7187c672d41fc54a0368b766c0fa7a59677964d8) (cherry picked from commit b124eb7df2617be56a23819f670bd6e054f87ce7)
-rw-r--r--oslo_context/context.py1
-rw-r--r--oslo_context/tests/test_context.py4
-rw-r--r--releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml4
3 files changed, 8 insertions, 1 deletions
diff --git a/oslo_context/context.py b/oslo_context/context.py
index 172d8ca..3e44f41 100644
--- a/oslo_context/context.py
+++ b/oslo_context/context.py
@@ -419,6 +419,7 @@ class RequestContext(object):
values.get('project_domain_name'))
kwargs.setdefault('is_admin_project',
values.get('is_admin_project', True))
+ kwargs.setdefault('system_scope', values.get('system_scope'))
for key in cls.FROM_DICT_EXTRA_KEYS:
kwargs.setdefault(key, values.get(key))
return cls(**kwargs)
diff --git a/oslo_context/tests/test_context.py b/oslo_context/tests/test_context.py
index fa44763..ef19369 100644
--- a/oslo_context/tests/test_context.py
+++ b/oslo_context/tests/test_context.py
@@ -143,7 +143,8 @@ class ContextTest(test_base.BaseTestCase):
"request_id": "request1",
"global_request_id": "req-uuid",
"resource_uuid": "instance1",
- "extra_data": "foo"
+ "extra_data": "foo",
+ "system_scope": "all"
}
ctx = context.RequestContext.from_dict(dct)
self.assertEqual(dct['auth_token'], ctx.auth_token)
@@ -163,6 +164,7 @@ class ContextTest(test_base.BaseTestCase):
self.assertEqual(dct['domain_name'], ctx.domain_name)
self.assertEqual(dct['user_domain_name'], ctx.user_domain_name)
self.assertEqual(dct['project_domain_name'], ctx.project_domain_name)
+ self.assertEqual(dct['system_scope'], ctx.system_scope)
def test_from_dict_unknown_keys(self):
dct = {
diff --git a/releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml b/releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml
new file mode 100644
index 0000000..6d18376
--- /dev/null
+++ b/releasenotes/notes/Fix-system-scope-from_dict-29615af90723ba4d.yaml
@@ -0,0 +1,4 @@
+---
+fixes:
+ - |
+ Fixes context from_dict() to properly handle system_scope.