Fix tests by mandating AS have sender.
We require application services to be configured with a sender, so we may as well require it when creating an ApplicationService object.pull/8616/head
parent
49bb079d87
commit
492e15e3b6
|
@ -52,11 +52,12 @@ class ApplicationService:
|
||||||
self,
|
self,
|
||||||
token,
|
token,
|
||||||
hostname,
|
hostname,
|
||||||
|
*,
|
||||||
|
id,
|
||||||
|
sender,
|
||||||
url=None,
|
url=None,
|
||||||
namespaces=None,
|
namespaces=None,
|
||||||
hs_token=None,
|
hs_token=None,
|
||||||
sender=None,
|
|
||||||
id=None,
|
|
||||||
protocols=None,
|
protocols=None,
|
||||||
rate_limited=True,
|
rate_limited=True,
|
||||||
ip_range_whitelist=None,
|
ip_range_whitelist=None,
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TestRatelimiter(unittest.TestCase):
|
||||||
|
|
||||||
def test_allowed_appservice_ratelimited_via_can_requester_do_action(self):
|
def test_allowed_appservice_ratelimited_via_can_requester_do_action(self):
|
||||||
appservice = ApplicationService(
|
appservice = ApplicationService(
|
||||||
None, "example.com", id="foo", rate_limited=True,
|
None, "example.com", id="foo", rate_limited=True, sender="@as:example.com",
|
||||||
)
|
)
|
||||||
as_requester = create_requester("@user:example.com", app_service=appservice)
|
as_requester = create_requester("@user:example.com", app_service=appservice)
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class TestRatelimiter(unittest.TestCase):
|
||||||
|
|
||||||
def test_allowed_appservice_via_can_requester_do_action(self):
|
def test_allowed_appservice_via_can_requester_do_action(self):
|
||||||
appservice = ApplicationService(
|
appservice = ApplicationService(
|
||||||
None, "example.com", id="foo", rate_limited=False,
|
None, "example.com", id="foo", rate_limited=False, sender="@as:example.com",
|
||||||
)
|
)
|
||||||
as_requester = create_requester("@user:example.com", app_service=appservice)
|
as_requester = create_requester("@user:example.com", app_service=appservice)
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ class ApplicationServiceTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.service = ApplicationService(
|
self.service = ApplicationService(
|
||||||
id="unique_identifier",
|
id="unique_identifier",
|
||||||
|
sender="@as:test",
|
||||||
url="some_url",
|
url="some_url",
|
||||||
token="some_token",
|
token="some_token",
|
||||||
hostname="matrix.org", # only used by get_groups_for_user
|
hostname="matrix.org", # only used by get_groups_for_user
|
||||||
|
|
|
@ -55,6 +55,7 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
||||||
self.hs.config.server_name,
|
self.hs.config.server_name,
|
||||||
id="1234",
|
id="1234",
|
||||||
namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]},
|
namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]},
|
||||||
|
sender="@as:test",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.hs.get_datastore().services_cache.append(appservice)
|
self.hs.get_datastore().services_cache.append(appservice)
|
||||||
|
|
Loading…
Reference in New Issue