codespell: Correct “requestor” to “requester”.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-06-20 13:52:31 -07:00 committed by Anders Kaseorg
parent 8be68c8034
commit c09e7d6407
16 changed files with 39 additions and 39 deletions

View File

@ -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):
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 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
set to the bot user's real email.
* [`GET /events`](/api/get-events): Event for updating a user's

View File

@ -201,9 +201,9 @@ def read_stripe_fixture(
fixture = orjson.loads(f.read())
# Check for StripeError fixtures
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
requestor.interpret_response(
requester.interpret_response(
fixture["http_body"], fixture["http_status"], fixture["headers"]
)
return stripe.util.convert_to_stripe_object(fixture)

View File

@ -455,7 +455,7 @@ def do_login(request: HttpRequest, user_profile: UserProfile) -> None:
and also adds helpful data needed by our server logs.
"""
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)
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
# 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")
if not is_tornado_view and is_tornado_request:
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 _wrapped_func_arguments

View File

@ -57,7 +57,7 @@ class RequestNotes(BaseNotes[HttpRequest, "RequestNotes"]):
client_version: Optional[str] = None
log_data: Optional[MutableMapping[str, Any]] = 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.
# Because the default value of realm is None, which can indicate "unset"
# and "nonexistence" at the same time.

View File

@ -124,7 +124,7 @@ def write_log_line(
path: str,
method: str,
remote_ip: str,
requestor_for_logs: str,
requester_for_logs: str,
client_name: str,
client_version: Optional[str] = None,
status_code: int = 200,
@ -197,9 +197,9 @@ def write_log_line(
else:
extra_request_data = ""
if client_version is None:
logger_client = f"({requestor_for_logs} via {client_name})"
logger_client = f"({requester_for_logs} via {client_name})"
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_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"):
@ -223,7 +223,7 @@ def write_log_line(
error_data = repr(error_content)
if len(error_data) > 200:
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):
@ -337,16 +337,16 @@ class LogRequests(MiddlewareMixin):
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)
requestor_for_logs = request_notes.requestor_for_logs
if requestor_for_logs is None:
requester_for_logs = request_notes.requester_for_logs
if requester_for_logs is 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:
requestor_for_logs = request.user.format_requestor_for_logs()
requester_for_logs = request.user.format_requester_for_logs()
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
@ -357,7 +357,7 @@ class LogRequests(MiddlewareMixin):
request.path,
request.method,
remote_ip,
requestor_for_logs,
requester_for_logs,
request_notes.client_name,
client_version=request_notes.client_version,
status_code=response.status_code,
@ -650,7 +650,7 @@ def validate_scim_bearer_token(request: HttpRequest) -> bool:
request_notes = RequestNotes.get_notes(request)
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}"
)

View File

@ -2210,7 +2210,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings): # type
else:
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")
def set_password(self, password: Optional[str]) -> None:

View File

@ -1541,7 +1541,7 @@ class TestInternalNotifyView(ZulipTestCase):
orjson.loads(self.internal_notify(False, request).content).get("msg"),
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):
self.internal_notify(True, request)
@ -1557,7 +1557,7 @@ class TestInternalNotifyView(ZulipTestCase):
orjson.loads(self.internal_notify(True, request).content).get("msg"),
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):
self.internal_notify(False, request)

View File

@ -48,7 +48,7 @@ class SlowQueryTest(ZulipTestCase):
path="/some/endpoint/",
method="GET",
remote_ip="123.456.789.012",
requestor_for_logs="unknown",
requester_for_logs="unknown",
client_name="?",
)
self.assert_length(middleware_normal_logger.output, 1)
@ -240,29 +240,29 @@ class OpenGraphTest(ZulipTestCase):
class LogRequestsTest(ZulipTestCase):
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")
request = HostRequestMock(user_profile=hamlet, meta_data=self.meta_data)
RequestNotes.get_notes(request).log_data = None
with self.assertLogs("zulip.requests", level="INFO") as m:
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()
request = HostRequestMock(remote_server=remote_server, meta_data=self.meta_data)
RequestNotes.get_notes(request).log_data = None
with self.assertLogs("zulip.requests", level="INFO") as m:
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)
RequestNotes.get_notes(request).log_data = None
expected_requestor = "unauth@root"
expected_requester = "unauth@root"
with self.assertLogs("zulip.requests", level="INFO") as m:
LogRequests(lambda _: HttpResponse())(request)
self.assertIn(expected_requestor, m.output[0])
self.assertIn(expected_requester, m.output[0])

View File

@ -693,7 +693,7 @@ class TestSCIMUser(SCIMTestCase):
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")
with self.assertLogs("zulip.requests", level="INFO") as m:
result = self.client_get(f"/scim/v2/Users/{hamlet.id}", {}, **self.scim_headers())

View File

@ -219,7 +219,7 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):
self.assertNotEqual(url_only_url, url)
self.assertIn("user_uploads/temporary/", url_only_url)
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.
self.logout()
self.assertEqual(self.client_get(url_only_url).getvalue(), b"zulip!")

View File

@ -230,7 +230,7 @@ class S3Test(ZulipTestCase):
self.assertNotEqual(url_only_url, url)
self.assertIn("user_uploads/temporary/", url_only_url)
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.
self.logout()
with self.settings(DEVELOPMENT=False):

View File

@ -243,8 +243,8 @@ class AsyncDjangoHandler(tornado.web.RequestHandler):
request_notes.log_data = old_request_notes.log_data
if request_notes.rate_limit is not None:
request_notes.rate_limit = old_request_notes.rate_limit
if request_notes.requestor_for_logs is not None:
request_notes.requestor_for_logs = old_request_notes.requestor_for_logs
if request_notes.requester_for_logs is not None:
request_notes.requester_for_logs = old_request_notes.requester_for_logs
request.user = old_request.user
request_notes.client = old_request_notes.client
request_notes.client_name = old_request_notes.client_name

View File

@ -81,7 +81,7 @@ def get_events_internal(
request: HttpRequest, user_profile_id: int = REQ(json_validator=check_int)
) -> HttpResponse:
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))
process_client(request, user_profile, client_name="internal")

View File

@ -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.
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
@ -971,7 +971,7 @@ def process_api_key_fetch_authenticate_result(
# Mark this request as having a logged-in user for our server logs.
assert isinstance(user_profile, UserProfile)
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)
return api_key

View File

@ -1021,7 +1021,7 @@ def update_subscription_properties_backend(
) -> HttpResponse:
"""
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.
Requests are of the form:

View File

@ -52,7 +52,7 @@ class RemoteZulipServer(models.Model):
def __str__(self) -> str:
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)