This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Wrap register_device coroutine in an ensureDeferred #7684
Merged
anoadragon453
merged 5 commits into
release-v1.15.1
from
anoa/register_device_async_fix
Jun 16, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c902149
Wrap register_device call in ensureDeferred
anoadragon453 f38ef15
Changelog
anoadragon453 4a07f25
Mention release instead of PR number in newsfile
anoadragon453 44361d3
Add initial unit tests for ModuleApi
anoadragon453 1263968
Small refactor of the fix for consistency
anoadragon453 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix a bug that would crash Synapse on start when using certain password auth providers. Broke in release v1.15.0. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright 2020 The Matrix.org Foundation C.I.C. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from synapse.module_api import ModuleApi | ||
|
||
from tests.unittest import HomeserverTestCase | ||
|
||
|
||
class ModuleApiTestCase(HomeserverTestCase): | ||
def prepare(self, reactor, clock, homeserver): | ||
self.store = homeserver.get_datastore() | ||
self.module_api = ModuleApi(homeserver, homeserver.get_auth_handler()) | ||
|
||
def test_can_register_user(self): | ||
"""Tests that an external module can register a user""" | ||
# Register a new user | ||
user_id, access_token = self.get_success( | ||
self.module_api.register( | ||
"bob", displayname="Bobberino", emails=["bob@bobinator.bob"] | ||
) | ||
) | ||
|
||
# Check that the new user exists with all provided attributes | ||
self.assertEqual(user_id, "@bob:test") | ||
self.assertTrue(access_token) | ||
self.assertTrue(self.store.get_user_by_id(user_id)) | ||
|
||
# Check that the email was assigned | ||
emails = self.get_success(self.store.user_get_threepids(user_id)) | ||
self.assertEqual(len(emails), 1) | ||
|
||
email = emails[0] | ||
self.assertEqual(email["medium"], "email") | ||
self.assertEqual(email["address"], "bob@bobinator.bob") | ||
|
||
# Should these be 0? | ||
self.assertEqual(email["validated_at"], 0) | ||
self.assertEqual(email["added_at"], 0) | ||
|
||
# Check that the displayname was assigned | ||
displayname = self.get_success(self.store.get_profile_displayname("bob")) | ||
self.assertEqual(displayname, "Bobberino") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like
added_at
at least shouldn't be, but this is probably out of scope for this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unrelated to these changes, yes. Maybe make a note somewhere to look back at this? (File an issue?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7699