From c09e7d640717e229faaee54e20623c15f1285f32 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 20 Jun 2023 13:52:31 -0700 Subject: [PATCH] =?UTF-8?q?codespell:=20Correct=20=E2=80=9Crequestor?= =?UTF-8?q?=E2=80=9D=20to=20=E2=80=9Crequester=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders Kaseorg --- api_docs/changelog.md | 2 +- corporate/tests/test_stripe.py | 4 ++-- zerver/decorator.py | 4 ++-- zerver/lib/request.py | 2 +- zerver/middleware.py | 24 ++++++++++++------------ zerver/models.py | 2 +- zerver/tests/test_decorators.py | 4 ++-- zerver/tests/test_middleware.py | 16 ++++++++-------- zerver/tests/test_scim.py | 2 +- zerver/tests/test_upload.py | 2 +- zerver/tests/test_upload_s3.py | 2 +- zerver/tornado/handlers.py | 4 ++-- zerver/tornado/views.py | 2 +- zerver/views/auth.py | 4 ++-- zerver/views/streams.py | 2 +- zilencer/models.py | 2 +- 16 files changed, 39 insertions(+), 39 deletions(-) diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 1527899ec0..450b77c27b 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -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 diff --git a/corporate/tests/test_stripe.py b/corporate/tests/test_stripe.py index 34d5c153f8..0b2bc50168 100644 --- a/corporate/tests/test_stripe.py +++ b/corporate/tests/test_stripe.py @@ -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) diff --git a/zerver/decorator.py b/zerver/decorator.py index c633d58dbc..8d3ece157e 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -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 diff --git a/zerver/lib/request.py b/zerver/lib/request.py index 630ab021d6..b48343018a 100644 --- a/zerver/lib/request.py +++ b/zerver/lib/request.py @@ -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. diff --git a/zerver/middleware.py b/zerver/middleware.py index f2d5cbca76..67b19f6103 100644 --- a/zerver/middleware.py +++ b/zerver/middleware.py @@ -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}" ) diff --git a/zerver/models.py b/zerver/models.py index 8b2bbf3f87..ffc29de71e 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -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: diff --git a/zerver/tests/test_decorators.py b/zerver/tests/test_decorators.py index 9d416780f9..a6485c5f5c 100644 --- a/zerver/tests/test_decorators.py +++ b/zerver/tests/test_decorators.py @@ -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) diff --git a/zerver/tests/test_middleware.py b/zerver/tests/test_middleware.py index 17184be8e2..9ac7c60cf0 100644 --- a/zerver/tests/test_middleware.py +++ b/zerver/tests/test_middleware.py @@ -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]) diff --git a/zerver/tests/test_scim.py b/zerver/tests/test_scim.py index 166ac044e2..4cc73363b6 100644 --- a/zerver/tests/test_scim.py +++ b/zerver/tests/test_scim.py @@ -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()) diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.py index 7939282f68..76d2441b88 100644 --- a/zerver/tests/test_upload.py +++ b/zerver/tests/test_upload.py @@ -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!") diff --git a/zerver/tests/test_upload_s3.py b/zerver/tests/test_upload_s3.py index 16fda5daba..005aa5e2ed 100644 --- a/zerver/tests/test_upload_s3.py +++ b/zerver/tests/test_upload_s3.py @@ -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): diff --git a/zerver/tornado/handlers.py b/zerver/tornado/handlers.py index 1b06c8fca8..3082db3df0 100644 --- a/zerver/tornado/handlers.py +++ b/zerver/tornado/handlers.py @@ -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 diff --git a/zerver/tornado/views.py b/zerver/tornado/views.py index 87a7cbb800..1ab11a3c02 100644 --- a/zerver/tornado/views.py +++ b/zerver/tornado/views.py @@ -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") diff --git a/zerver/views/auth.py b/zerver/views/auth.py index 10bb941455..91cb3f74c7 100644 --- a/zerver/views/auth.py +++ b/zerver/views/auth.py @@ -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 diff --git a/zerver/views/streams.py b/zerver/views/streams.py index c443ef6470..c4ae4acb38 100644 --- a/zerver/views/streams.py +++ b/zerver/views/streams.py @@ -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: diff --git a/zilencer/models.py b/zilencer/models.py index 611a2f073b..12a429385a 100644 --- a/zilencer/models.py +++ b/zilencer/models.py @@ -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)