Remove usage of deprecated RequestContext attributes

These attributes were deprecated in oslo.context 2.6.0 .

Change-Id: Iadb5fb54f82b9368242d59cc4843b26b7e99b385
This commit is contained in:
Takashi Kajinami 2024-09-18 12:11:02 +09:00
parent abd5c21ccd
commit a69fba56b0

View File

@ -71,7 +71,7 @@ def _fake_context():
ctxt = context.RequestContext(user_id="myuser", ctxt = context.RequestContext(user_id="myuser",
user_name="myuser", user_name="myuser",
system_scope="myscope", system_scope="myscope",
domain="mydomain", domain_id="mydomain",
project_id="mytenant", project_id="mytenant",
project_name="mytenant", project_name="mytenant",
project_domain_id="mydomain", project_domain_id="mydomain",
@ -940,8 +940,9 @@ class ContextFormatterTestCase(LogTestBase):
message = 'test' message = 'test'
self.log.info(message, context=ctxt) self.log.info(message, context=ctxt)
expected = ("HAS CONTEXT [%s %s %s %s %s %s %s]: %s\n" % expected = ("HAS CONTEXT [%s %s %s %s %s %s %s]: %s\n" %
(ctxt.request_id, ctxt.user, ctxt.project_id, ctxt.domain, (ctxt.request_id, ctxt.user_id, ctxt.project_id,
ctxt.system_scope, ctxt.user_domain, ctxt.project_domain, ctxt.domain_id, ctxt.system_scope,
ctxt.user_domain_id, ctxt.project_domain_id,
str(message))) str(message)))
self.assertEqual(expected, self.stream.getvalue()) self.assertEqual(expected, self.stream.getvalue())
@ -969,7 +970,7 @@ class ContextFormatterTestCase(LogTestBase):
message = 'test' message = 'test'
self.log.info(message, context=ctxt) self.log.info(message, context=ctxt)
expected = ("HAS CONTEXT [%s %s %s]: %s\n" % expected = ("HAS CONTEXT [%s %s %s]: %s\n" %
(ctxt.request_id, ctxt.user, ctxt.project_id, (ctxt.request_id, ctxt.user_id, ctxt.project_id,
str(message))) str(message)))
self.assertEqual(expected, self.stream.getvalue()) self.assertEqual(expected, self.stream.getvalue())
@ -1275,9 +1276,9 @@ class DomainTestCase(LogTestBase):
ctxt = _fake_context() ctxt = _fake_context()
user_identity = (self.CONF.logging_user_identity_format % user_identity = (self.CONF.logging_user_identity_format %
ctxt.get_logging_values()) ctxt.get_logging_values())
self.assertIn(ctxt.domain, user_identity) self.assertIn(ctxt.domain_id, user_identity)
self.assertIn(ctxt.project_domain, user_identity) self.assertIn(ctxt.project_domain_id, user_identity)
self.assertIn(ctxt.user_domain, user_identity) self.assertIn(ctxt.user_domain_id, user_identity)
self._validate_keys(ctxt, ('[%s]: %s' % self._validate_keys(ctxt, ('[%s]: %s' %
(ctxt.request_id, user_identity))) (ctxt.request_id, user_identity)))