diff options
author | Richard van der Hoff <richard@matrix.org> | 2018-09-04 01:23:18 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2018-09-05 13:08:07 +0100 |
commit | c127c8d0421f0228a46ebbe280c9537e8d8ea42b (patch) | |
tree | 2ff022ac3ebbd4df9e12c3153875eb3b6c361b25 /tests/utils.py | |
parent | Check that signatures on events are valid (diff) | |
download | synapse-c127c8d0421f0228a46ebbe280c9537e8d8ea42b.tar.xz |
Fix origin handling for pushed transactions
Use the actual origin for push transactions, rather than whatever the remote server claimed.
Diffstat (limited to '')
-rw-r--r-- | tests/utils.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/utils.py b/tests/utils.py index bb0fc74054..8de2898b2f 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -306,7 +306,10 @@ class MockHttpResource(HttpServer): @patch('twisted.web.http.Request') @defer.inlineCallbacks - def trigger(self, http_method, path, content, mock_request, federation_auth=False): + def trigger( + self, http_method, path, content, mock_request, + federation_auth_origin=None, + ): """ Fire an HTTP event. Args: @@ -315,6 +318,7 @@ class MockHttpResource(HttpServer): content : The HTTP body mock_request : Mocked request to pass to the event so it can get content. + federation_auth_origin (bytes|None): domain to authenticate as, for federation Returns: A tuple of (code, response) Raises: @@ -335,8 +339,10 @@ class MockHttpResource(HttpServer): mock_request.getClientIP.return_value = "-" headers = {} - if federation_auth: - headers[b"Authorization"] = [b"X-Matrix origin=test,key=,sig="] + if federation_auth_origin is not None: + headers[b"Authorization"] = [ + b"X-Matrix origin=%s,key=,sig=" % (federation_auth_origin, ) + ] mock_request.requestHeaders.getRawHeaders = mock_getRawHeaders(headers) # return the right path if the event requires it |