mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
test_auth_backends: Add request parameter to patched_authenticate.
This is required by social-auth-app-django 4.0.0. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
30c6797239
commit
6363c49e3f
@@ -464,7 +464,10 @@ class AuthBackendTest(ZulipTestCase):
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def patched_authenticate(**kwargs: Any) -> Any:
|
def patched_authenticate(
|
||||||
|
request: Optional[HttpResponse] = None,
|
||||||
|
**kwargs: Any,
|
||||||
|
) -> Any:
|
||||||
# This is how we pass the subdomain to the authentication
|
# This is how we pass the subdomain to the authentication
|
||||||
# backend in production code, so we need to do this setup
|
# backend in production code, so we need to do this setup
|
||||||
# here.
|
# here.
|
||||||
@@ -481,7 +484,7 @@ class AuthBackendTest(ZulipTestCase):
|
|||||||
return {'email': user.delivery_email}
|
return {'email': user.delivery_email}
|
||||||
backend.strategy.request_data = return_email
|
backend.strategy.request_data = return_email
|
||||||
|
|
||||||
result = orig_authenticate(backend, **kwargs)
|
result = orig_authenticate(backend, request, **kwargs)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def patched_get_verified_emails(*args: Any, **kwargs: Any) -> Any:
|
def patched_get_verified_emails(*args: Any, **kwargs: Any) -> Any:
|
||||||
@@ -497,12 +500,15 @@ class AuthBackendTest(ZulipTestCase):
|
|||||||
status=details['status'],
|
status=details['status'],
|
||||||
body=details['body'])
|
body=details['body'])
|
||||||
backend_class = backends_to_test[backend_name]['backend']
|
backend_class = backends_to_test[backend_name]['backend']
|
||||||
|
|
||||||
|
# We're creating a new class instance here, so the
|
||||||
|
# monkey-patching of the instance that we're about to
|
||||||
|
# do will be discarded at the end of this test.
|
||||||
backend = backend_class()
|
backend = backend_class()
|
||||||
backend.strategy = DjangoStrategy(storage=BaseDjangoStorage())
|
backend.strategy = DjangoStrategy(storage=BaseDjangoStorage())
|
||||||
|
|
||||||
orig_authenticate = backend_class.authenticate
|
orig_authenticate = backend_class.authenticate
|
||||||
backend.authenticate = patched_authenticate
|
backend.authenticate = patched_authenticate
|
||||||
orig_get_verified_emails = backend_class.get_verified_emails
|
|
||||||
if backend_name == "google":
|
if backend_name == "google":
|
||||||
backend.get_verified_emails = patched_get_verified_emails
|
backend.get_verified_emails = patched_get_verified_emails
|
||||||
|
|
||||||
@@ -520,8 +526,6 @@ class AuthBackendTest(ZulipTestCase):
|
|||||||
self.verify_backend(backend,
|
self.verify_backend(backend,
|
||||||
good_kwargs=good_kwargs,
|
good_kwargs=good_kwargs,
|
||||||
bad_kwargs=bad_kwargs)
|
bad_kwargs=bad_kwargs)
|
||||||
backend.authenticate = orig_authenticate
|
|
||||||
backend.get_verified_emails = orig_get_verified_emails
|
|
||||||
|
|
||||||
class RateLimitAuthenticationTests(ZulipTestCase):
|
class RateLimitAuthenticationTests(ZulipTestCase):
|
||||||
@override_settings(RATE_LIMITING_AUTHENTICATE=True)
|
@override_settings(RATE_LIMITING_AUTHENTICATE=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user