Use direct references for configuration variables (part 6). (#10916)
This commit is contained in:
@@ -217,7 +217,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
user_id = "@baldrick:matrix.org"
|
||||
macaroon = pymacaroons.Macaroon(
|
||||
location=self.hs.config.server_name,
|
||||
location=self.hs.config.server.server_name,
|
||||
identifier="key",
|
||||
key=self.hs.config.key.macaroon_secret_key,
|
||||
)
|
||||
@@ -239,7 +239,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
user_id = "@baldrick:matrix.org"
|
||||
macaroon = pymacaroons.Macaroon(
|
||||
location=self.hs.config.server_name,
|
||||
location=self.hs.config.server.server_name,
|
||||
identifier="key",
|
||||
key=self.hs.config.key.macaroon_secret_key,
|
||||
)
|
||||
@@ -268,7 +268,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
self.store.get_monthly_active_count = simple_async_mock(lots_of_users)
|
||||
|
||||
e = self.get_failure(self.auth.check_auth_blocking(), ResourceLimitError)
|
||||
self.assertEquals(e.value.admin_contact, self.hs.config.admin_contact)
|
||||
self.assertEquals(e.value.admin_contact, self.hs.config.server.admin_contact)
|
||||
self.assertEquals(e.value.errcode, Codes.RESOURCE_LIMIT_EXCEEDED)
|
||||
self.assertEquals(e.value.code, 403)
|
||||
|
||||
@@ -303,7 +303,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
appservice = ApplicationService(
|
||||
"abcd",
|
||||
self.hs.config.server_name,
|
||||
self.hs.config.server.server_name,
|
||||
id="1234",
|
||||
namespaces={
|
||||
"users": [{"regex": "@_appservice.*:sender", "exclusive": True}]
|
||||
@@ -332,7 +332,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
appservice = ApplicationService(
|
||||
"abcd",
|
||||
self.hs.config.server_name,
|
||||
self.hs.config.server.server_name,
|
||||
id="1234",
|
||||
namespaces={
|
||||
"users": [{"regex": "@_appservice.*:sender", "exclusive": True}]
|
||||
@@ -372,7 +372,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
self.auth_blocking._hs_disabled = True
|
||||
self.auth_blocking._hs_disabled_message = "Reason for being disabled"
|
||||
e = self.get_failure(self.auth.check_auth_blocking(), ResourceLimitError)
|
||||
self.assertEquals(e.value.admin_contact, self.hs.config.admin_contact)
|
||||
self.assertEquals(e.value.admin_contact, self.hs.config.server.admin_contact)
|
||||
self.assertEquals(e.value.errcode, Codes.RESOURCE_LIMIT_EXCEEDED)
|
||||
self.assertEquals(e.value.code, 403)
|
||||
|
||||
@@ -387,7 +387,7 @@ class AuthTestCase(unittest.HomeserverTestCase):
|
||||
self.auth_blocking._hs_disabled = True
|
||||
self.auth_blocking._hs_disabled_message = "Reason for being disabled"
|
||||
e = self.get_failure(self.auth.check_auth_blocking(), ResourceLimitError)
|
||||
self.assertEquals(e.value.admin_contact, self.hs.config.admin_contact)
|
||||
self.assertEquals(e.value.admin_contact, self.hs.config.server.admin_contact)
|
||||
self.assertEquals(e.value.errcode, Codes.RESOURCE_LIMIT_EXCEEDED)
|
||||
self.assertEquals(e.value.code, 403)
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ class StateQueryTests(unittest.FederatingHomeserverTestCase):
|
||||
|
||||
self.assertEqual(
|
||||
channel.json_body["room_version"],
|
||||
self.hs.config.default_room_version.identifier,
|
||||
self.hs.config.server.default_room_version.identifier,
|
||||
)
|
||||
|
||||
members = set(
|
||||
|
||||
@@ -175,20 +175,20 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
|
||||
self.assertTrue(result_token is not None)
|
||||
|
||||
def test_mau_limits_when_disabled(self):
|
||||
self.hs.config.limit_usage_by_mau = False
|
||||
self.hs.config.server.limit_usage_by_mau = False
|
||||
# Ensure does not throw exception
|
||||
self.get_success(self.get_or_create_user(self.requester, "a", "display_name"))
|
||||
|
||||
def test_get_or_create_user_mau_not_blocked(self):
|
||||
self.hs.config.limit_usage_by_mau = True
|
||||
self.hs.config.server.limit_usage_by_mau = True
|
||||
self.store.count_monthly_users = Mock(
|
||||
return_value=make_awaitable(self.hs.config.max_mau_value - 1)
|
||||
return_value=make_awaitable(self.hs.config.server.max_mau_value - 1)
|
||||
)
|
||||
# Ensure does not throw exception
|
||||
self.get_success(self.get_or_create_user(self.requester, "c", "User"))
|
||||
|
||||
def test_get_or_create_user_mau_blocked(self):
|
||||
self.hs.config.limit_usage_by_mau = True
|
||||
self.hs.config.server.limit_usage_by_mau = True
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.lots_of_users)
|
||||
)
|
||||
@@ -198,7 +198,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.hs.config.max_mau_value)
|
||||
return_value=make_awaitable(self.hs.config.server.max_mau_value)
|
||||
)
|
||||
self.get_failure(
|
||||
self.get_or_create_user(self.requester, "b", "display_name"),
|
||||
@@ -206,7 +206,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
def test_register_mau_blocked(self):
|
||||
self.hs.config.limit_usage_by_mau = True
|
||||
self.hs.config.server.limit_usage_by_mau = True
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.lots_of_users)
|
||||
)
|
||||
@@ -215,7 +215,7 @@ class RegistrationTestCase(unittest.HomeserverTestCase):
|
||||
)
|
||||
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.hs.config.max_mau_value)
|
||||
return_value=make_awaitable(self.hs.config.server.max_mau_value)
|
||||
)
|
||||
self.get_failure(
|
||||
self.handler.register_user(localpart="local_part"), ResourceLimitError
|
||||
|
||||
@@ -226,7 +226,7 @@ class FederationClientTests(HomeserverTestCase):
|
||||
"""Ensure that Synapse does not try to connect to blacklisted IPs"""
|
||||
|
||||
# Set up the ip_range blacklist
|
||||
self.hs.config.federation_ip_range_blacklist = IPSet(
|
||||
self.hs.config.server.federation_ip_range_blacklist = IPSet(
|
||||
["127.0.0.0/8", "fe80::/64"]
|
||||
)
|
||||
self.reactor.lookups["internal"] = "127.0.0.1"
|
||||
|
||||
@@ -422,7 +422,7 @@ class UserRegisterTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Set monthly active users to the limit
|
||||
store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.hs.config.max_mau_value)
|
||||
return_value=make_awaitable(self.hs.config.server.max_mau_value)
|
||||
)
|
||||
# Check that the blocking of monthly active users is working as expected
|
||||
# The registration of a new user fails due to the limit
|
||||
@@ -1485,7 +1485,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Set monthly active users to the limit
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.hs.config.max_mau_value)
|
||||
return_value=make_awaitable(self.hs.config.server.max_mau_value)
|
||||
)
|
||||
# Check that the blocking of monthly active users is working as expected
|
||||
# The registration of a new user fails due to the limit
|
||||
@@ -1522,7 +1522,7 @@ class UserRestTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
# Set monthly active users to the limit
|
||||
self.store.get_monthly_active_count = Mock(
|
||||
return_value=make_awaitable(self.hs.config.max_mau_value)
|
||||
return_value=make_awaitable(self.hs.config.server.max_mau_value)
|
||||
)
|
||||
# Check that the blocking of monthly active users is working as expected
|
||||
# The registration of a new user fails due to the limit
|
||||
|
||||
@@ -516,7 +516,7 @@ class WhoamiTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
appservice = ApplicationService(
|
||||
as_token,
|
||||
self.hs.config.server_name,
|
||||
self.hs.config.server.server_name,
|
||||
id="1234",
|
||||
namespaces={"users": [{"regex": user_id, "exclusive": True}]},
|
||||
sender=user_id,
|
||||
|
||||
@@ -55,7 +55,7 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase):
|
||||
self.assertTrue(room_version in KNOWN_ROOM_VERSIONS, "" + room_version)
|
||||
|
||||
self.assertEqual(
|
||||
self.config.default_room_version.identifier,
|
||||
self.config.server.default_room_version.identifier,
|
||||
capabilities["m.room_versions"]["default"],
|
||||
)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class PresenceTestCase(unittest.HomeserverTestCase):
|
||||
PUT to the status endpoint with use_presence enabled will call
|
||||
set_state on the presence handler.
|
||||
"""
|
||||
self.hs.config.use_presence = True
|
||||
self.hs.config.server.use_presence = True
|
||||
|
||||
body = {"presence": "here", "status_msg": "beep boop"}
|
||||
channel = self.make_request(
|
||||
|
||||
@@ -50,7 +50,7 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
appservice = ApplicationService(
|
||||
as_token,
|
||||
self.hs.config.server_name,
|
||||
self.hs.config.server.server_name,
|
||||
id="1234",
|
||||
namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]},
|
||||
sender="@as:test",
|
||||
@@ -74,7 +74,7 @@ class RegisterRestServletTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
appservice = ApplicationService(
|
||||
as_token,
|
||||
self.hs.config.server_name,
|
||||
self.hs.config.server.server_name,
|
||||
id="1234",
|
||||
namespaces={"users": [{"regex": r"@as_user.*", "exclusive": True}]},
|
||||
sender="@as:test",
|
||||
|
||||
@@ -346,7 +346,7 @@ class TestResourceLimitsServerNoticesWithRealRooms(unittest.HomeserverTestCase):
|
||||
invites = []
|
||||
|
||||
# Register as many users as the MAU limit allows.
|
||||
for i in range(self.hs.config.max_mau_value):
|
||||
for i in range(self.hs.config.server.max_mau_value):
|
||||
localpart = "user%d" % i
|
||||
user_id = self.register_user(localpart, "password")
|
||||
tok = self.login(localpart, "password")
|
||||
|
||||
@@ -51,7 +51,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
|
||||
@override_config({"max_mau_value": 3, "mau_limit_reserved_threepids": gen_3pids(3)})
|
||||
def test_initialise_reserved_users(self):
|
||||
threepids = self.hs.config.mau_limits_reserved_threepids
|
||||
threepids = self.hs.config.server.mau_limits_reserved_threepids
|
||||
|
||||
# register three users, of which two have reserved 3pids, and a third
|
||||
# which is a support user.
|
||||
@@ -101,9 +101,9 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
# XXX some of this is redundant. poking things into the config shouldn't
|
||||
# work, and in any case it's not obvious what we expect to happen when
|
||||
# we advance the reactor.
|
||||
self.hs.config.max_mau_value = 0
|
||||
self.hs.config.server.max_mau_value = 0
|
||||
self.reactor.advance(FORTY_DAYS)
|
||||
self.hs.config.max_mau_value = 5
|
||||
self.hs.config.server.max_mau_value = 5
|
||||
|
||||
self.get_success(self.store.reap_monthly_active_users())
|
||||
|
||||
@@ -183,7 +183,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
self.get_success(d)
|
||||
|
||||
count = self.get_success(self.store.get_monthly_active_count())
|
||||
self.assertEqual(count, self.hs.config.max_mau_value)
|
||||
self.assertEqual(count, self.hs.config.server.max_mau_value)
|
||||
|
||||
self.reactor.advance(FORTY_DAYS)
|
||||
|
||||
@@ -199,7 +199,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
def test_reap_monthly_active_users_reserved_users(self):
|
||||
"""Tests that reaping correctly handles reaping where reserved users are
|
||||
present"""
|
||||
threepids = self.hs.config.mau_limits_reserved_threepids
|
||||
threepids = self.hs.config.server.mau_limits_reserved_threepids
|
||||
initial_users = len(threepids)
|
||||
reserved_user_number = initial_users - 1
|
||||
for i in range(initial_users):
|
||||
@@ -234,7 +234,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
self.get_success(d)
|
||||
|
||||
count = self.get_success(self.store.get_monthly_active_count())
|
||||
self.assertEqual(count, self.hs.config.max_mau_value)
|
||||
self.assertEqual(count, self.hs.config.server.max_mau_value)
|
||||
|
||||
def test_populate_monthly_users_is_guest(self):
|
||||
# Test that guest users are not added to mau list
|
||||
@@ -294,7 +294,7 @@ class MonthlyActiveUsersTestCase(unittest.HomeserverTestCase):
|
||||
{"medium": "email", "address": user2_email},
|
||||
]
|
||||
|
||||
self.hs.config.mau_limits_reserved_threepids = threepids
|
||||
self.hs.config.server.mau_limits_reserved_threepids = threepids
|
||||
d = self.store.db_pool.runInteraction(
|
||||
"initialise", self.store._initialise_reserved_users, threepids
|
||||
)
|
||||
|
||||
@@ -165,7 +165,7 @@ class TestMauLimit(unittest.HomeserverTestCase):
|
||||
|
||||
@override_config({"mau_trial_days": 1})
|
||||
def test_trial_users_cant_come_back(self):
|
||||
self.hs.config.mau_trial_days = 1
|
||||
self.hs.config.server.mau_trial_days = 1
|
||||
|
||||
# We should be able to register more than the limit initially
|
||||
token1 = self.create_user("kermit1")
|
||||
|
||||
@@ -232,7 +232,7 @@ class HomeserverTestCase(TestCase):
|
||||
# Honour the `use_frozen_dicts` config option. We have to do this
|
||||
# manually because this is taken care of in the app `start` code, which
|
||||
# we don't run. Plus we want to reset it on tearDown.
|
||||
events.USE_FROZEN_DICTS = self.hs.config.use_frozen_dicts
|
||||
events.USE_FROZEN_DICTS = self.hs.config.server.use_frozen_dicts
|
||||
|
||||
if self.hs is None:
|
||||
raise Exception("No homeserver returned from make_homeserver.")
|
||||
|
||||
Reference in New Issue
Block a user