mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-09-08 11:42:02 +00:00
block sync if auth checks fail
This commit is contained in:
parent
3dce9050cf
commit
69ce057ea6
@ -209,14 +209,12 @@ class SyncHandler(object):
|
|||||||
Deferred[SyncResult]
|
Deferred[SyncResult]
|
||||||
"""
|
"""
|
||||||
yield self.auth.check_auth_blocking()
|
yield self.auth.check_auth_blocking()
|
||||||
|
res = yield self.response_cache.wrap(
|
||||||
defer.returnValue(
|
|
||||||
self.response_cache.wrap(
|
|
||||||
sync_config.request_key,
|
sync_config.request_key,
|
||||||
self._wait_for_sync_for_user,
|
self._wait_for_sync_for_user,
|
||||||
sync_config, since_token, timeout, full_state,
|
sync_config, since_token, timeout, full_state,
|
||||||
)
|
)
|
||||||
)
|
defer.returnValue(res)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _wait_for_sync_for_user(self, sync_config, since_token, timeout,
|
def _wait_for_sync_for_user(self, sync_config, since_token, timeout,
|
||||||
|
@ -14,11 +14,14 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
|
from synapse.api.errors import AuthError
|
||||||
|
from synapse.api.filtering import DEFAULT_FILTER_COLLECTION
|
||||||
|
from synapse.handlers.sync import SyncConfig, SyncHandler
|
||||||
|
from synapse.types import UserID
|
||||||
|
|
||||||
import tests.unittest
|
import tests.unittest
|
||||||
import tests.utils
|
import tests.utils
|
||||||
from tests.utils import setup_test_homeserver
|
from tests.utils import setup_test_homeserver
|
||||||
from synapse.handlers.sync import SyncHandler, SyncConfig
|
|
||||||
from synapse.types import UserID
|
|
||||||
|
|
||||||
|
|
||||||
class SyncTestCase(tests.unittest.TestCase):
|
class SyncTestCase(tests.unittest.TestCase):
|
||||||
@ -33,10 +36,14 @@ class SyncTestCase(tests.unittest.TestCase):
|
|||||||
def test_wait_for_sync_for_user_auth_blocking(self):
|
def test_wait_for_sync_for_user_auth_blocking(self):
|
||||||
sync_config = SyncConfig(
|
sync_config = SyncConfig(
|
||||||
user=UserID("@user", "server"),
|
user=UserID("@user", "server"),
|
||||||
filter_collection=None,
|
filter_collection=DEFAULT_FILTER_COLLECTION,
|
||||||
is_guest=False,
|
is_guest=False,
|
||||||
request_key="request_key",
|
request_key="request_key",
|
||||||
device_id="device_id",
|
device_id="device_id",
|
||||||
)
|
)
|
||||||
res = yield self.sync_handler.wait_for_sync_for_user(sync_config)
|
# Ensure that an exception is not thrown
|
||||||
print res
|
yield self.sync_handler.wait_for_sync_for_user(sync_config)
|
||||||
|
self.hs.config.hs_disabled = True
|
||||||
|
|
||||||
|
with self.assertRaises(AuthError):
|
||||||
|
yield self.sync_handler.wait_for_sync_for_user(sync_config)
|
||||||
|
Loading…
Reference in New Issue
Block a user