Introduce a Requester object

This tracks data about the entity which made the request. This is
instead of passing around a tuple, which requires call-site
modifications every time a new piece of optional context is passed
around.

I tried to introduce a User object. I gave up.
This commit is contained in:
Daniel Wagner-Hall 2016-01-11 15:29:57 +00:00
parent fcbe63eaad
commit 2110e35fd6
24 changed files with 178 additions and 144 deletions

View file

@ -14,16 +14,15 @@
# limitations under the License.
"""Tests REST events for /profile paths."""
from tests import unittest
from twisted.internet import defer
from mock import Mock, NonCallableMock
from mock import Mock
from ....utils import MockHttpResource, setup_test_homeserver
from synapse.api.errors import SynapseError, AuthError
from synapse.types import UserID
from synapse.types import Requester, UserID
from synapse.rest.client.v1 import profile
@ -53,7 +52,7 @@ class ProfileTestCase(unittest.TestCase):
)
def _get_user_by_req(request=None, allow_guest=False):
return (UserID.from_string(myid), "", False)
return Requester(UserID.from_string(myid), "", False)
hs.get_v1auth().get_user_by_req = _get_user_by_req