Merge branch 'develop' into anoa/trailing_slashes_client

This commit is contained in:
Andrew Morgan 2019-03-11 17:44:29 +00:00
commit f18dca26da
5 changed files with 14 additions and 12 deletions

1
changelog.d/4793.feature Normal file
View File

@ -0,0 +1 @@
Synapse is now permissive about trailing slashes on some of its federation endpoints, allowing zero or more to be present.

1
changelog.d/4847.misc Normal file
View File

@ -0,0 +1 @@
Correctly log expected errors when fetching server keys.

View File

@ -686,9 +686,9 @@ def _handle_key_deferred(verify_request):
try: try:
with PreserveLoggingContext(): with PreserveLoggingContext():
_, key_id, verify_key = yield verify_request.deferred _, key_id, verify_key = yield verify_request.deferred
except (IOError, RequestSendFailed) as e: except KeyLookupError as e:
logger.warn( logger.warn(
"Got IOError when downloading keys for %s: %s %s", "Failed to download keys for %s: %s %s",
server_name, type(e).__name__, str(e), server_name, type(e).__name__, str(e),
) )
raise SynapseError( raise SynapseError(

View File

@ -312,7 +312,7 @@ class BaseFederationServlet(object):
class FederationSendServlet(BaseFederationServlet): class FederationSendServlet(BaseFederationServlet):
PATH = "/send/(?P<transaction_id>[^/]*)/" PATH = "/send/(?P<transaction_id>[^/]*)/?"
def __init__(self, handler, server_name, **kwargs): def __init__(self, handler, server_name, **kwargs):
super(FederationSendServlet, self).__init__( super(FederationSendServlet, self).__init__(
@ -378,7 +378,7 @@ class FederationSendServlet(BaseFederationServlet):
class FederationEventServlet(BaseFederationServlet): class FederationEventServlet(BaseFederationServlet):
PATH = "/event/(?P<event_id>[^/]*)/" PATH = "/event/(?P<event_id>[^/]*)/?"
# This is when someone asks for a data item for a given server data_id pair. # This is when someone asks for a data item for a given server data_id pair.
def on_GET(self, origin, content, query, event_id): def on_GET(self, origin, content, query, event_id):
@ -386,7 +386,7 @@ class FederationEventServlet(BaseFederationServlet):
class FederationStateServlet(BaseFederationServlet): class FederationStateServlet(BaseFederationServlet):
PATH = "/state/(?P<context>[^/]*)/" PATH = "/state/(?P<context>[^/]*)/?"
# This is when someone asks for all data for a given context. # This is when someone asks for all data for a given context.
def on_GET(self, origin, content, query, context): def on_GET(self, origin, content, query, context):
@ -398,7 +398,7 @@ class FederationStateServlet(BaseFederationServlet):
class FederationStateIdsServlet(BaseFederationServlet): class FederationStateIdsServlet(BaseFederationServlet):
PATH = "/state_ids/(?P<room_id>[^/]*)/" PATH = "/state_ids/(?P<room_id>[^/]*)/?"
def on_GET(self, origin, content, query, room_id): def on_GET(self, origin, content, query, room_id):
return self.handler.on_state_ids_request( return self.handler.on_state_ids_request(
@ -409,7 +409,7 @@ class FederationStateIdsServlet(BaseFederationServlet):
class FederationBackfillServlet(BaseFederationServlet): class FederationBackfillServlet(BaseFederationServlet):
PATH = "/backfill/(?P<context>[^/]*)/" PATH = "/backfill/(?P<context>[^/]*)/?"
def on_GET(self, origin, content, query, context): def on_GET(self, origin, content, query, context):
versions = [x.decode('ascii') for x in query[b"v"]] versions = [x.decode('ascii') for x in query[b"v"]]
@ -1080,7 +1080,7 @@ class FederationGroupsCategoriesServlet(BaseFederationServlet):
"""Get all categories for a group """Get all categories for a group
""" """
PATH = ( PATH = (
"/groups/(?P<group_id>[^/]*)/categories/" "/groups/(?P<group_id>[^/]*)/categories/?"
) )
@defer.inlineCallbacks @defer.inlineCallbacks
@ -1150,7 +1150,7 @@ class FederationGroupsRolesServlet(BaseFederationServlet):
"""Get roles in a group """Get roles in a group
""" """
PATH = ( PATH = (
"/groups/(?P<group_id>[^/]*)/roles/" "/groups/(?P<group_id>[^/]*)/roles/?"
) )
@defer.inlineCallbacks @defer.inlineCallbacks

View File

@ -180,7 +180,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
put_json = self.hs.get_http_client().put_json put_json = self.hs.get_http_client().put_json
put_json.assert_called_once_with( put_json.assert_called_once_with(
"farm", "farm",
path="/_matrix/federation/v1/send/1000000/", path="/_matrix/federation/v1/send/1000000",
data=_expect_edu_transaction( data=_expect_edu_transaction(
"m.typing", "m.typing",
content={ content={
@ -201,7 +201,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
(request, channel) = self.make_request( (request, channel) = self.make_request(
"PUT", "PUT",
"/_matrix/federation/v1/send/1000000/", "/_matrix/federation/v1/send/1000000",
_make_edu_transaction_json( _make_edu_transaction_json(
"m.typing", "m.typing",
content={ content={
@ -257,7 +257,7 @@ class TypingNotificationsTestCase(unittest.HomeserverTestCase):
put_json = self.hs.get_http_client().put_json put_json = self.hs.get_http_client().put_json
put_json.assert_called_once_with( put_json.assert_called_once_with(
"farm", "farm",
path="/_matrix/federation/v1/send/1000000/", path="/_matrix/federation/v1/send/1000000",
data=_expect_edu_transaction( data=_expect_edu_transaction(
"m.typing", "m.typing",
content={ content={