mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-15 20:38:46 -05:00
Run Black on the tests again (#5170)
This commit is contained in:
parent
d9a02d1201
commit
b36c82576e
54 changed files with 818 additions and 1158 deletions
|
|
@ -45,13 +45,7 @@ class ConfigGenerationTestCase(unittest.TestCase):
|
|||
)
|
||||
|
||||
self.assertSetEqual(
|
||||
set(
|
||||
[
|
||||
"homeserver.yaml",
|
||||
"lemurs.win.log.config",
|
||||
"lemurs.win.signing.key",
|
||||
]
|
||||
),
|
||||
set(["homeserver.yaml", "lemurs.win.log.config", "lemurs.win.signing.key"]),
|
||||
set(os.listdir(self.dir)),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ from tests import unittest
|
|||
|
||||
class RoomDirectoryConfigTestCase(unittest.TestCase):
|
||||
def test_alias_creation_acl(self):
|
||||
config = yaml.safe_load("""
|
||||
config = yaml.safe_load(
|
||||
"""
|
||||
alias_creation_rules:
|
||||
- user_id: "*bob*"
|
||||
alias: "*"
|
||||
|
|
@ -38,43 +39,49 @@ class RoomDirectoryConfigTestCase(unittest.TestCase):
|
|||
action: "allow"
|
||||
|
||||
room_list_publication_rules: []
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
rd_config = RoomDirectoryConfig()
|
||||
rd_config.read_config(config)
|
||||
|
||||
self.assertFalse(rd_config.is_alias_creation_allowed(
|
||||
user_id="@bob:example.com",
|
||||
room_id="!test",
|
||||
alias="#test:example.com",
|
||||
))
|
||||
self.assertFalse(
|
||||
rd_config.is_alias_creation_allowed(
|
||||
user_id="@bob:example.com", room_id="!test", alias="#test:example.com"
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_alias_creation_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
alias="#unofficial_st:example.com",
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_alias_creation_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
alias="#unofficial_st:example.com",
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_alias_creation_allowed(
|
||||
user_id="@foobar:example.com",
|
||||
room_id="!test",
|
||||
alias="#test:example.com",
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_alias_creation_allowed(
|
||||
user_id="@foobar:example.com",
|
||||
room_id="!test",
|
||||
alias="#test:example.com",
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_alias_creation_allowed(
|
||||
user_id="@gah:example.com",
|
||||
room_id="!test",
|
||||
alias="#goo:example.com",
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_alias_creation_allowed(
|
||||
user_id="@gah:example.com", room_id="!test", alias="#goo:example.com"
|
||||
)
|
||||
)
|
||||
|
||||
self.assertFalse(rd_config.is_alias_creation_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
alias="#test:example.com",
|
||||
))
|
||||
self.assertFalse(
|
||||
rd_config.is_alias_creation_allowed(
|
||||
user_id="@test:example.com", room_id="!test", alias="#test:example.com"
|
||||
)
|
||||
)
|
||||
|
||||
def test_room_publish_acl(self):
|
||||
config = yaml.safe_load("""
|
||||
config = yaml.safe_load(
|
||||
"""
|
||||
alias_creation_rules: []
|
||||
|
||||
room_list_publication_rules:
|
||||
|
|
@ -92,55 +99,66 @@ class RoomDirectoryConfigTestCase(unittest.TestCase):
|
|||
action: "allow"
|
||||
- room_id: "!test-deny"
|
||||
action: "deny"
|
||||
""")
|
||||
"""
|
||||
)
|
||||
|
||||
rd_config = RoomDirectoryConfig()
|
||||
rd_config.read_config(config)
|
||||
|
||||
self.assertFalse(rd_config.is_publishing_room_allowed(
|
||||
user_id="@bob:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#test:example.com"],
|
||||
))
|
||||
self.assertFalse(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@bob:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#test:example.com"],
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_publishing_room_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#unofficial_st:example.com"],
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#unofficial_st:example.com"],
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_publishing_room_allowed(
|
||||
user_id="@foobar:example.com",
|
||||
room_id="!test",
|
||||
aliases=[],
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@foobar:example.com", room_id="!test", aliases=[]
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_publishing_room_allowed(
|
||||
user_id="@gah:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#goo:example.com"],
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@gah:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#goo:example.com"],
|
||||
)
|
||||
)
|
||||
|
||||
self.assertFalse(rd_config.is_publishing_room_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#test:example.com"],
|
||||
))
|
||||
self.assertFalse(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#test:example.com"],
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_publishing_room_allowed(
|
||||
user_id="@foobar:example.com",
|
||||
room_id="!test-deny",
|
||||
aliases=[],
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@foobar:example.com", room_id="!test-deny", aliases=[]
|
||||
)
|
||||
)
|
||||
|
||||
self.assertFalse(rd_config.is_publishing_room_allowed(
|
||||
user_id="@gah:example.com",
|
||||
room_id="!test-deny",
|
||||
aliases=[],
|
||||
))
|
||||
self.assertFalse(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@gah:example.com", room_id="!test-deny", aliases=[]
|
||||
)
|
||||
)
|
||||
|
||||
self.assertTrue(rd_config.is_publishing_room_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#unofficial_st:example.com", "#blah:example.com"],
|
||||
))
|
||||
self.assertTrue(
|
||||
rd_config.is_publishing_room_allowed(
|
||||
user_id="@test:example.com",
|
||||
room_id="!test",
|
||||
aliases=["#unofficial_st:example.com", "#blah:example.com"],
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ from tests import unittest
|
|||
|
||||
|
||||
class ServerConfigTestCase(unittest.TestCase):
|
||||
|
||||
def test_is_threepid_reserved(self):
|
||||
user1 = {'medium': 'email', 'address': 'user1@example.com'}
|
||||
user2 = {'medium': 'email', 'address': 'user2@example.com'}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class TestConfig(TlsConfig):
|
|||
|
||||
|
||||
class TLSConfigTests(TestCase):
|
||||
|
||||
def test_warn_self_signed(self):
|
||||
"""
|
||||
Synapse will give a warning when it loads a self-signed certificate.
|
||||
|
|
@ -34,7 +33,8 @@ class TLSConfigTests(TestCase):
|
|||
config_dir = self.mktemp()
|
||||
os.mkdir(config_dir)
|
||||
with open(os.path.join(config_dir, "cert.pem"), 'w') as f:
|
||||
f.write("""-----BEGIN CERTIFICATE-----
|
||||
f.write(
|
||||
"""-----BEGIN CERTIFICATE-----
|
||||
MIID6DCCAtACAws9CjANBgkqhkiG9w0BAQUFADCBtzELMAkGA1UEBhMCVFIxDzAN
|
||||
BgNVBAgMBsOHb3J1bTEUMBIGA1UEBwwLQmHFn21ha8OnxLExEjAQBgNVBAMMCWxv
|
||||
Y2FsaG9zdDEcMBoGA1UECgwTVHdpc3RlZCBNYXRyaXggTGFiczEkMCIGA1UECwwb
|
||||
|
|
@ -56,11 +56,12 @@ I8OtG1xGwcok53lyDuuUUDexnK4O5BkjKiVlNPg4HPim5Kuj2hRNFfNt/F2BVIlj
|
|||
iZupikC5MT1LQaRwidkSNxCku1TfAyueiBwhLnFwTmIGNnhuDCutEVAD9kFmcJN2
|
||||
SznugAcPk4doX2+rL+ila+ThqgPzIkwTUHtnmjI0TI6xsDUlXz5S3UyudrE2Qsfz
|
||||
s4niecZKPBizL6aucT59CsunNmmb5Glq8rlAcU+1ZTZZzGYqVYhF6axB9Qg=
|
||||
-----END CERTIFICATE-----""")
|
||||
-----END CERTIFICATE-----"""
|
||||
)
|
||||
|
||||
config = {
|
||||
"tls_certificate_path": os.path.join(config_dir, "cert.pem"),
|
||||
"tls_fingerprints": []
|
||||
"tls_fingerprints": [],
|
||||
}
|
||||
|
||||
t = TestConfig()
|
||||
|
|
@ -75,5 +76,5 @@ s4niecZKPBizL6aucT59CsunNmmb5Glq8rlAcU+1ZTZZzGYqVYhF6axB9Qg=
|
|||
"Self-signed TLS certificates will not be accepted by "
|
||||
"Synapse 1.0. Please either provide a valid certificate, "
|
||||
"or use Synapse's ACME support to provision one."
|
||||
)
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue