Use singletons for handlers.

pull/8800/head
Patrick Cloke 2020-12-01 12:51:05 -05:00
parent 6a581821d7
commit ef2e79f2d1
2 changed files with 8 additions and 9 deletions

View File

@ -23,7 +23,7 @@ import pymacaroons
from twisted.python.failure import Failure
from twisted.web._newclient import ResponseDone
from synapse.handlers.oidc_handler import OidcError, OidcHandler, OidcMappingProvider
from synapse.handlers.oidc_handler import OidcError, OidcMappingProvider
from synapse.handlers.sso import MappingException
from synapse.types import UserID
@ -155,13 +155,14 @@ class OidcHandlerTestCase(HomeserverTestCase):
config=config,
)
self.handler = OidcHandler(hs)
self.handler = hs.get_oidc_handler()
sso_handler = hs.get_sso_handler()
# Mock the render error method.
self.render_error = Mock(return_value=None)
self.handler._sso_handler.render_error = self.render_error
sso_handler.render_error = self.render_error
# Reduce the number of attempts when generating MXIDs.
self.handler._sso_handler._MAP_USERNAME_RETRIES = 3
sso_handler._MAP_USERNAME_RETRIES = 3
return hs

View File

@ -14,7 +14,6 @@
import attr
from synapse.handlers.saml_handler import SamlHandler
from synapse.handlers.sso import MappingException
from tests.unittest import HomeserverTestCase
@ -63,15 +62,14 @@ class SamlHandlerTestCase(HomeserverTestCase):
config["saml2_config"] = saml_config
hs = self.setup_test_homeserver(
http_client=self.http_client,
proxied_http_client=self.http_client,
config=config,
)
self.handler = SamlHandler(hs)
self.handler = hs.get_saml_handler()
# Reduce the number of attempts when generating MXIDs.
self.handler._sso_handler._MAP_USERNAME_RETRIES = 3
sso_handler = hs.get_sso_handler()
sso_handler._MAP_USERNAME_RETRIES = 3
return hs