mirror of https://github.com/zulip/zulip.git
codespell: Correct “requestor” to “requester”.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
8be68c8034
commit
c09e7d6407
|
@ -249,7 +249,7 @@ No changes; feature level used for Zulip 7.0 release.
|
||||||
[`GET /users/me`](/api/get-own-user), [`GET /events`](/api/get-events):
|
[`GET /users/me`](/api/get-own-user), [`GET /events`](/api/get-events):
|
||||||
The `delivery_email` field is always present in user objects, including
|
The `delivery_email` field is always present in user objects, including
|
||||||
the case when a user's `email_address_visibility` is set to everyone.
|
the case when a user's `email_address_visibility` is set to everyone.
|
||||||
The value will be `null` if the requestor does not have access to the
|
The value will be `null` if the requester does not have access to the
|
||||||
user's real email. For bot users, the `delivery_email` field is always
|
user's real email. For bot users, the `delivery_email` field is always
|
||||||
set to the bot user's real email.
|
set to the bot user's real email.
|
||||||
* [`GET /events`](/api/get-events): Event for updating a user's
|
* [`GET /events`](/api/get-events): Event for updating a user's
|
||||||
|
|
|
@ -201,9 +201,9 @@ def read_stripe_fixture(
|
||||||
fixture = orjson.loads(f.read())
|
fixture = orjson.loads(f.read())
|
||||||
# Check for StripeError fixtures
|
# Check for StripeError fixtures
|
||||||
if "json_body" in fixture:
|
if "json_body" in fixture:
|
||||||
requestor = stripe.api_requestor.APIRequestor()
|
requester = stripe.api_requestor.APIRequestor()
|
||||||
# This function will raise the relevant StripeError according to the fixture
|
# This function will raise the relevant StripeError according to the fixture
|
||||||
requestor.interpret_response(
|
requester.interpret_response(
|
||||||
fixture["http_body"], fixture["http_status"], fixture["headers"]
|
fixture["http_body"], fixture["http_status"], fixture["headers"]
|
||||||
)
|
)
|
||||||
return stripe.util.convert_to_stripe_object(fixture)
|
return stripe.util.convert_to_stripe_object(fixture)
|
||||||
|
|
|
@ -455,7 +455,7 @@ def do_login(request: HttpRequest, user_profile: UserProfile) -> None:
|
||||||
and also adds helpful data needed by our server logs.
|
and also adds helpful data needed by our server logs.
|
||||||
"""
|
"""
|
||||||
django_login(request, user_profile)
|
django_login(request, user_profile)
|
||||||
RequestNotes.get_notes(request).requestor_for_logs = user_profile.format_requestor_for_logs()
|
RequestNotes.get_notes(request).requester_for_logs = user_profile.format_requester_for_logs()
|
||||||
process_client(request, user_profile, is_browser_view=True)
|
process_client(request, user_profile, is_browser_view=True)
|
||||||
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
||||||
# Log in with two factor authentication as well.
|
# Log in with two factor authentication as well.
|
||||||
|
@ -930,7 +930,7 @@ def internal_notify_view(
|
||||||
raise RuntimeError("Tornado notify view called with no Tornado handler")
|
raise RuntimeError("Tornado notify view called with no Tornado handler")
|
||||||
if not is_tornado_view and is_tornado_request:
|
if not is_tornado_view and is_tornado_request:
|
||||||
raise RuntimeError("Django notify view called with Tornado handler")
|
raise RuntimeError("Django notify view called with Tornado handler")
|
||||||
request_notes.requestor_for_logs = "internal"
|
request_notes.requester_for_logs = "internal"
|
||||||
return view_func(request, *args, **kwargs)
|
return view_func(request, *args, **kwargs)
|
||||||
|
|
||||||
return _wrapped_func_arguments
|
return _wrapped_func_arguments
|
||||||
|
|
|
@ -57,7 +57,7 @@ class RequestNotes(BaseNotes[HttpRequest, "RequestNotes"]):
|
||||||
client_version: Optional[str] = None
|
client_version: Optional[str] = None
|
||||||
log_data: Optional[MutableMapping[str, Any]] = None
|
log_data: Optional[MutableMapping[str, Any]] = None
|
||||||
rate_limit: Optional[str] = None
|
rate_limit: Optional[str] = None
|
||||||
requestor_for_logs: Optional[str] = None
|
requester_for_logs: Optional[str] = None
|
||||||
# We use realm_cached to indicate whether the realm is cached or not.
|
# We use realm_cached to indicate whether the realm is cached or not.
|
||||||
# Because the default value of realm is None, which can indicate "unset"
|
# Because the default value of realm is None, which can indicate "unset"
|
||||||
# and "nonexistence" at the same time.
|
# and "nonexistence" at the same time.
|
||||||
|
|
|
@ -124,7 +124,7 @@ def write_log_line(
|
||||||
path: str,
|
path: str,
|
||||||
method: str,
|
method: str,
|
||||||
remote_ip: str,
|
remote_ip: str,
|
||||||
requestor_for_logs: str,
|
requester_for_logs: str,
|
||||||
client_name: str,
|
client_name: str,
|
||||||
client_version: Optional[str] = None,
|
client_version: Optional[str] = None,
|
||||||
status_code: int = 200,
|
status_code: int = 200,
|
||||||
|
@ -197,9 +197,9 @@ def write_log_line(
|
||||||
else:
|
else:
|
||||||
extra_request_data = ""
|
extra_request_data = ""
|
||||||
if client_version is None:
|
if client_version is None:
|
||||||
logger_client = f"({requestor_for_logs} via {client_name})"
|
logger_client = f"({requester_for_logs} via {client_name})"
|
||||||
else:
|
else:
|
||||||
logger_client = f"({requestor_for_logs} via {client_name}/{client_version})"
|
logger_client = f"({requester_for_logs} via {client_name}/{client_version})"
|
||||||
logger_timing = f"{format_timedelta(time_delta):>5}{optional_orig_delta}{remote_cache_output}{markdown_output}{db_time_output}{startup_output} {path}"
|
logger_timing = f"{format_timedelta(time_delta):>5}{optional_orig_delta}{remote_cache_output}{markdown_output}{db_time_output}{startup_output} {path}"
|
||||||
logger_line = f"{remote_ip:<15} {method:<7} {status_code:3} {logger_timing}{extra_request_data} {logger_client}"
|
logger_line = f"{remote_ip:<15} {method:<7} {status_code:3} {logger_timing}{extra_request_data} {logger_client}"
|
||||||
if status_code in [200, 304] and method == "GET" and path.startswith("/static"):
|
if status_code in [200, 304] and method == "GET" and path.startswith("/static"):
|
||||||
|
@ -223,7 +223,7 @@ def write_log_line(
|
||||||
error_data = repr(error_content)
|
error_data = repr(error_content)
|
||||||
if len(error_data) > 200:
|
if len(error_data) > 200:
|
||||||
error_data = "[content more than 200 characters]"
|
error_data = "[content more than 200 characters]"
|
||||||
logger.info("status=%3d, data=%s, uid=%s", status_code, error_data, requestor_for_logs)
|
logger.info("status=%3d, data=%s, uid=%s", status_code, error_data, requester_for_logs)
|
||||||
|
|
||||||
|
|
||||||
class RequestContext(MiddlewareMixin):
|
class RequestContext(MiddlewareMixin):
|
||||||
|
@ -337,16 +337,16 @@ class LogRequests(MiddlewareMixin):
|
||||||
|
|
||||||
remote_ip = request.META["REMOTE_ADDR"]
|
remote_ip = request.META["REMOTE_ADDR"]
|
||||||
|
|
||||||
# Get the requestor's identifier and client, if available.
|
# Get the requester's identifier and client, if available.
|
||||||
request_notes = RequestNotes.get_notes(request)
|
request_notes = RequestNotes.get_notes(request)
|
||||||
requestor_for_logs = request_notes.requestor_for_logs
|
requester_for_logs = request_notes.requester_for_logs
|
||||||
if requestor_for_logs is None:
|
if requester_for_logs is None:
|
||||||
if request_notes.remote_server is not None:
|
if request_notes.remote_server is not None:
|
||||||
requestor_for_logs = request_notes.remote_server.format_requestor_for_logs()
|
requester_for_logs = request_notes.remote_server.format_requester_for_logs()
|
||||||
elif request.user.is_authenticated:
|
elif request.user.is_authenticated:
|
||||||
requestor_for_logs = request.user.format_requestor_for_logs()
|
requester_for_logs = request.user.format_requester_for_logs()
|
||||||
else:
|
else:
|
||||||
requestor_for_logs = "unauth@{}".format(get_subdomain(request) or "root")
|
requester_for_logs = "unauth@{}".format(get_subdomain(request) or "root")
|
||||||
|
|
||||||
content = response.content if isinstance(response, HttpResponse) else None
|
content = response.content if isinstance(response, HttpResponse) else None
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ class LogRequests(MiddlewareMixin):
|
||||||
request.path,
|
request.path,
|
||||||
request.method,
|
request.method,
|
||||||
remote_ip,
|
remote_ip,
|
||||||
requestor_for_logs,
|
requester_for_logs,
|
||||||
request_notes.client_name,
|
request_notes.client_name,
|
||||||
client_version=request_notes.client_version,
|
client_version=request_notes.client_version,
|
||||||
status_code=response.status_code,
|
status_code=response.status_code,
|
||||||
|
@ -650,7 +650,7 @@ def validate_scim_bearer_token(request: HttpRequest) -> bool:
|
||||||
|
|
||||||
request_notes = RequestNotes.get_notes(request)
|
request_notes = RequestNotes.get_notes(request)
|
||||||
assert request_notes.realm is not None
|
assert request_notes.realm is not None
|
||||||
request_notes.requestor_for_logs = (
|
request_notes.requester_for_logs = (
|
||||||
f"scim-client:{scim_client_name}:realm:{request_notes.realm.id}"
|
f"scim-client:{scim_client_name}:realm:{request_notes.realm.id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2210,7 +2210,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): # type
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def format_requestor_for_logs(self) -> str:
|
def format_requester_for_logs(self) -> str:
|
||||||
return "{}@{}".format(self.id, self.realm.string_id or "root")
|
return "{}@{}".format(self.id, self.realm.string_id or "root")
|
||||||
|
|
||||||
def set_password(self, password: Optional[str]) -> None:
|
def set_password(self, password: Optional[str]) -> None:
|
||||||
|
|
|
@ -1541,7 +1541,7 @@ class TestInternalNotifyView(ZulipTestCase):
|
||||||
orjson.loads(self.internal_notify(False, request).content).get("msg"),
|
orjson.loads(self.internal_notify(False, request).content).get("msg"),
|
||||||
self.BORING_RESULT,
|
self.BORING_RESULT,
|
||||||
)
|
)
|
||||||
self.assertEqual(RequestNotes.get_notes(request).requestor_for_logs, "internal")
|
self.assertEqual(RequestNotes.get_notes(request).requester_for_logs, "internal")
|
||||||
|
|
||||||
with self.assertRaises(RuntimeError):
|
with self.assertRaises(RuntimeError):
|
||||||
self.internal_notify(True, request)
|
self.internal_notify(True, request)
|
||||||
|
@ -1557,7 +1557,7 @@ class TestInternalNotifyView(ZulipTestCase):
|
||||||
orjson.loads(self.internal_notify(True, request).content).get("msg"),
|
orjson.loads(self.internal_notify(True, request).content).get("msg"),
|
||||||
self.BORING_RESULT,
|
self.BORING_RESULT,
|
||||||
)
|
)
|
||||||
self.assertEqual(RequestNotes.get_notes(request).requestor_for_logs, "internal")
|
self.assertEqual(RequestNotes.get_notes(request).requester_for_logs, "internal")
|
||||||
|
|
||||||
with self.assertRaises(RuntimeError):
|
with self.assertRaises(RuntimeError):
|
||||||
self.internal_notify(False, request)
|
self.internal_notify(False, request)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class SlowQueryTest(ZulipTestCase):
|
||||||
path="/some/endpoint/",
|
path="/some/endpoint/",
|
||||||
method="GET",
|
method="GET",
|
||||||
remote_ip="123.456.789.012",
|
remote_ip="123.456.789.012",
|
||||||
requestor_for_logs="unknown",
|
requester_for_logs="unknown",
|
||||||
client_name="?",
|
client_name="?",
|
||||||
)
|
)
|
||||||
self.assert_length(middleware_normal_logger.output, 1)
|
self.assert_length(middleware_normal_logger.output, 1)
|
||||||
|
@ -240,29 +240,29 @@ class OpenGraphTest(ZulipTestCase):
|
||||||
class LogRequestsTest(ZulipTestCase):
|
class LogRequestsTest(ZulipTestCase):
|
||||||
meta_data = {"REMOTE_ADDR": "127.0.0.1"}
|
meta_data = {"REMOTE_ADDR": "127.0.0.1"}
|
||||||
|
|
||||||
def test_requestor_for_logs_as_user(self) -> None:
|
def test_requester_for_logs_as_user(self) -> None:
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
request = HostRequestMock(user_profile=hamlet, meta_data=self.meta_data)
|
request = HostRequestMock(user_profile=hamlet, meta_data=self.meta_data)
|
||||||
RequestNotes.get_notes(request).log_data = None
|
RequestNotes.get_notes(request).log_data = None
|
||||||
|
|
||||||
with self.assertLogs("zulip.requests", level="INFO") as m:
|
with self.assertLogs("zulip.requests", level="INFO") as m:
|
||||||
LogRequests(lambda _: HttpResponse())(request)
|
LogRequests(lambda _: HttpResponse())(request)
|
||||||
self.assertIn(hamlet.format_requestor_for_logs(), m.output[0])
|
self.assertIn(hamlet.format_requester_for_logs(), m.output[0])
|
||||||
|
|
||||||
def test_requestor_for_logs_as_remote_server(self) -> None:
|
def test_requester_for_logs_as_remote_server(self) -> None:
|
||||||
remote_server = RemoteZulipServer()
|
remote_server = RemoteZulipServer()
|
||||||
request = HostRequestMock(remote_server=remote_server, meta_data=self.meta_data)
|
request = HostRequestMock(remote_server=remote_server, meta_data=self.meta_data)
|
||||||
RequestNotes.get_notes(request).log_data = None
|
RequestNotes.get_notes(request).log_data = None
|
||||||
|
|
||||||
with self.assertLogs("zulip.requests", level="INFO") as m:
|
with self.assertLogs("zulip.requests", level="INFO") as m:
|
||||||
LogRequests(lambda _: HttpResponse())(request)
|
LogRequests(lambda _: HttpResponse())(request)
|
||||||
self.assertIn(remote_server.format_requestor_for_logs(), m.output[0])
|
self.assertIn(remote_server.format_requester_for_logs(), m.output[0])
|
||||||
|
|
||||||
def test_requestor_for_logs_unauthenticated(self) -> None:
|
def test_requester_for_logs_unauthenticated(self) -> None:
|
||||||
request = HostRequestMock(meta_data=self.meta_data)
|
request = HostRequestMock(meta_data=self.meta_data)
|
||||||
RequestNotes.get_notes(request).log_data = None
|
RequestNotes.get_notes(request).log_data = None
|
||||||
|
|
||||||
expected_requestor = "unauth@root"
|
expected_requester = "unauth@root"
|
||||||
with self.assertLogs("zulip.requests", level="INFO") as m:
|
with self.assertLogs("zulip.requests", level="INFO") as m:
|
||||||
LogRequests(lambda _: HttpResponse())(request)
|
LogRequests(lambda _: HttpResponse())(request)
|
||||||
self.assertIn(expected_requestor, m.output[0])
|
self.assertIn(expected_requester, m.output[0])
|
||||||
|
|
|
@ -693,7 +693,7 @@ class TestSCIMUser(SCIMTestCase):
|
||||||
m.output, [f"ERROR:django.request:Not Implemented: /scim/v2/Users/{hamlet.id}"]
|
m.output, [f"ERROR:django.request:Not Implemented: /scim/v2/Users/{hamlet.id}"]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_scim_client_requestor_for_logs(self) -> None:
|
def test_scim_client_requester_for_logs(self) -> None:
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
with self.assertLogs("zulip.requests", level="INFO") as m:
|
with self.assertLogs("zulip.requests", level="INFO") as m:
|
||||||
result = self.client_get(f"/scim/v2/Users/{hamlet.id}", {}, **self.scim_headers())
|
result = self.client_get(f"/scim/v2/Users/{hamlet.id}", {}, **self.scim_headers())
|
||||||
|
|
|
@ -219,7 +219,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
|
||||||
self.assertNotEqual(url_only_url, url)
|
self.assertNotEqual(url_only_url, url)
|
||||||
self.assertIn("user_uploads/temporary/", url_only_url)
|
self.assertIn("user_uploads/temporary/", url_only_url)
|
||||||
self.assertTrue(url_only_url.endswith("zulip.txt"))
|
self.assertTrue(url_only_url.endswith("zulip.txt"))
|
||||||
# The generated URL has a token authorizing the requestor to access the file
|
# The generated URL has a token authorizing the requester to access the file
|
||||||
# without being logged in.
|
# without being logged in.
|
||||||
self.logout()
|
self.logout()
|
||||||
self.assertEqual(self.client_get(url_only_url).getvalue(), b"zulip!")
|
self.assertEqual(self.client_get(url_only_url).getvalue(), b"zulip!")
|
||||||
|
|
|
@ -230,7 +230,7 @@ class S3Test(ZulipTestCase):
|
||||||
self.assertNotEqual(url_only_url, url)
|
self.assertNotEqual(url_only_url, url)
|
||||||
self.assertIn("user_uploads/temporary/", url_only_url)
|
self.assertIn("user_uploads/temporary/", url_only_url)
|
||||||
self.assertTrue(url_only_url.endswith("zulip.txt"))
|
self.assertTrue(url_only_url.endswith("zulip.txt"))
|
||||||
# The generated URL has a token authorizing the requestor to access the file
|
# The generated URL has a token authorizing the requester to access the file
|
||||||
# without being logged in.
|
# without being logged in.
|
||||||
self.logout()
|
self.logout()
|
||||||
with self.settings(DEVELOPMENT=False):
|
with self.settings(DEVELOPMENT=False):
|
||||||
|
|
|
@ -243,8 +243,8 @@ class AsyncDjangoHandler(tornado.web.RequestHandler):
|
||||||
request_notes.log_data = old_request_notes.log_data
|
request_notes.log_data = old_request_notes.log_data
|
||||||
if request_notes.rate_limit is not None:
|
if request_notes.rate_limit is not None:
|
||||||
request_notes.rate_limit = old_request_notes.rate_limit
|
request_notes.rate_limit = old_request_notes.rate_limit
|
||||||
if request_notes.requestor_for_logs is not None:
|
if request_notes.requester_for_logs is not None:
|
||||||
request_notes.requestor_for_logs = old_request_notes.requestor_for_logs
|
request_notes.requester_for_logs = old_request_notes.requester_for_logs
|
||||||
request.user = old_request.user
|
request.user = old_request.user
|
||||||
request_notes.client = old_request_notes.client
|
request_notes.client = old_request_notes.client
|
||||||
request_notes.client_name = old_request_notes.client_name
|
request_notes.client_name = old_request_notes.client_name
|
||||||
|
|
|
@ -81,7 +81,7 @@ def get_events_internal(
|
||||||
request: HttpRequest, user_profile_id: int = REQ(json_validator=check_int)
|
request: HttpRequest, user_profile_id: int = REQ(json_validator=check_int)
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
user_profile = get_user_profile_by_id(user_profile_id)
|
user_profile = get_user_profile_by_id(user_profile_id)
|
||||||
RequestNotes.get_notes(request).requestor_for_logs = user_profile.format_requestor_for_logs()
|
RequestNotes.get_notes(request).requester_for_logs = user_profile.format_requester_for_logs()
|
||||||
assert is_current_port(get_user_tornado_port(user_profile))
|
assert is_current_port(get_user_tornado_port(user_profile))
|
||||||
|
|
||||||
process_client(request, user_profile, client_name="internal")
|
process_client(request, user_profile, client_name="internal")
|
||||||
|
|
|
@ -451,7 +451,7 @@ def finish_mobile_flow(request: HttpRequest, user_profile: UserProfile, otp: str
|
||||||
|
|
||||||
# Mark this request as having a logged-in user for our server logs.
|
# Mark this request as having a logged-in user for our server logs.
|
||||||
process_client(request, user_profile)
|
process_client(request, user_profile)
|
||||||
RequestNotes.get_notes(request).requestor_for_logs = user_profile.format_requestor_for_logs()
|
RequestNotes.get_notes(request).requester_for_logs = user_profile.format_requester_for_logs()
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -971,7 +971,7 @@ def process_api_key_fetch_authenticate_result(
|
||||||
# Mark this request as having a logged-in user for our server logs.
|
# Mark this request as having a logged-in user for our server logs.
|
||||||
assert isinstance(user_profile, UserProfile)
|
assert isinstance(user_profile, UserProfile)
|
||||||
process_client(request, user_profile)
|
process_client(request, user_profile)
|
||||||
RequestNotes.get_notes(request).requestor_for_logs = user_profile.format_requestor_for_logs()
|
RequestNotes.get_notes(request).requester_for_logs = user_profile.format_requester_for_logs()
|
||||||
|
|
||||||
api_key = get_api_key(user_profile)
|
api_key = get_api_key(user_profile)
|
||||||
return api_key
|
return api_key
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ def update_subscription_properties_backend(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
"""
|
"""
|
||||||
This is the entry point to changing subscription properties. This
|
This is the entry point to changing subscription properties. This
|
||||||
is a bulk endpoint: requestors always provide a subscription_data
|
is a bulk endpoint: requesters always provide a subscription_data
|
||||||
list containing dictionaries for each stream of interest.
|
list containing dictionaries for each stream of interest.
|
||||||
|
|
||||||
Requests are of the form:
|
Requests are of the form:
|
||||||
|
|
|
@ -52,7 +52,7 @@ class RemoteZulipServer(models.Model):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.hostname} {str(self.uuid)[0:12]}"
|
return f"{self.hostname} {str(self.uuid)[0:12]}"
|
||||||
|
|
||||||
def format_requestor_for_logs(self) -> str:
|
def format_requester_for_logs(self) -> str:
|
||||||
return "zulip-server:" + str(self.uuid)
|
return "zulip-server:" + str(self.uuid)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue