mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-26 20:22:22 +00:00
Merge pull request #860 from negzi/bug_fix_get_or_create_user
Fix a bug caused by a change in auth_handler function
This commit is contained in:
commit
0a43219a27
@ -388,8 +388,8 @@ class RegistrationHandler(BaseHandler):
|
|||||||
|
|
||||||
user = UserID(localpart, self.hs.hostname)
|
user = UserID(localpart, self.hs.hostname)
|
||||||
user_id = user.to_string()
|
user_id = user.to_string()
|
||||||
auth_handler = self.hs.get_handlers().auth_handler
|
token = self.auth_handler().generate_short_term_login_token(
|
||||||
token = auth_handler.generate_short_term_login_token(user_id, duration_seconds)
|
user_id, duration_seconds)
|
||||||
|
|
||||||
if need_register:
|
if need_register:
|
||||||
yield self.store.register(
|
yield self.store.register(
|
||||||
|
@ -41,14 +41,15 @@ class RegistrationTestCase(unittest.TestCase):
|
|||||||
handlers=None,
|
handlers=None,
|
||||||
http_client=None,
|
http_client=None,
|
||||||
expire_access_token=True)
|
expire_access_token=True)
|
||||||
|
self.auth_handler = Mock(
|
||||||
|
generate_short_term_login_token=Mock(return_value='secret'))
|
||||||
self.hs.handlers = RegistrationHandlers(self.hs)
|
self.hs.handlers = RegistrationHandlers(self.hs)
|
||||||
self.handler = self.hs.get_handlers().registration_handler
|
self.handler = self.hs.get_handlers().registration_handler
|
||||||
self.hs.get_handlers().profile_handler = Mock()
|
self.hs.get_handlers().profile_handler = Mock()
|
||||||
self.mock_handler = Mock(spec=[
|
self.mock_handler = Mock(spec=[
|
||||||
"generate_short_term_login_token",
|
"generate_short_term_login_token",
|
||||||
])
|
])
|
||||||
|
self.hs.get_auth_handler = Mock(return_value=self.auth_handler)
|
||||||
self.hs.get_handlers().auth_handler = self.mock_handler
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_user_is_created_and_logged_in_if_doesnt_exist(self):
|
def test_user_is_created_and_logged_in_if_doesnt_exist(self):
|
||||||
@ -56,8 +57,6 @@ class RegistrationTestCase(unittest.TestCase):
|
|||||||
local_part = "someone"
|
local_part = "someone"
|
||||||
display_name = "someone"
|
display_name = "someone"
|
||||||
user_id = "@someone:test"
|
user_id = "@someone:test"
|
||||||
mock_token = self.mock_handler.generate_short_term_login_token
|
|
||||||
mock_token.return_value = 'secret'
|
|
||||||
result_user_id, result_token = yield self.handler.get_or_create_user(
|
result_user_id, result_token = yield self.handler.get_or_create_user(
|
||||||
local_part, display_name, duration_ms)
|
local_part, display_name, duration_ms)
|
||||||
self.assertEquals(result_user_id, user_id)
|
self.assertEquals(result_user_id, user_id)
|
||||||
@ -75,8 +74,6 @@ class RegistrationTestCase(unittest.TestCase):
|
|||||||
local_part = "frank"
|
local_part = "frank"
|
||||||
display_name = "Frank"
|
display_name = "Frank"
|
||||||
user_id = "@frank:test"
|
user_id = "@frank:test"
|
||||||
mock_token = self.mock_handler.generate_short_term_login_token
|
|
||||||
mock_token.return_value = 'secret'
|
|
||||||
result_user_id, result_token = yield self.handler.get_or_create_user(
|
result_user_id, result_token = yield self.handler.get_or_create_user(
|
||||||
local_part, display_name, duration_ms)
|
local_part, display_name, duration_ms)
|
||||||
self.assertEquals(result_user_id, user_id)
|
self.assertEquals(result_user_id, user_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user