mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-18 17:10:43 +03:00
pep8 style fixes
This commit is contained in:
parent
488ed3e444
commit
1e8cfc9e77
2 changed files with 44 additions and 40 deletions
|
@ -35,6 +35,8 @@ spam_checker:
|
|||
|
||||
Don't forget to consider if you can invite users from your own domain.
|
||||
"""
|
||||
|
||||
|
||||
class DomainRuleChecker(object):
|
||||
|
||||
def __init__(self, config):
|
||||
|
|
|
@ -24,73 +24,75 @@ class DomainRuleCheckerTestCase(unittest.TestCase):
|
|||
|
||||
def test_allowed(self):
|
||||
config = {
|
||||
"default": False,
|
||||
"domain_mapping": {
|
||||
"source_one": [ "target_one", "target_two" ],
|
||||
"source_two": [ "target_two" ]
|
||||
}
|
||||
"default": False,
|
||||
"domain_mapping": {
|
||||
"source_one": ["target_one", "target_two"],
|
||||
"source_two": ["target_two"]
|
||||
}
|
||||
}
|
||||
check = DomainRuleChecker(config)
|
||||
self.assertTrue(check.user_may_invite("test:source_one","test:target_one", "room"))
|
||||
self.assertTrue(check.user_may_invite("test:source_one","test:target_two", "room"))
|
||||
self.assertTrue(check.user_may_invite("test:source_two","test:target_two", "room"))
|
||||
|
||||
self.assertTrue(check.user_may_invite("test:source_one",
|
||||
"test:target_one", "room"))
|
||||
self.assertTrue(check.user_may_invite("test:source_one",
|
||||
"test:target_two", "room"))
|
||||
self.assertTrue(check.user_may_invite("test:source_two",
|
||||
"test:target_two", "room"))
|
||||
|
||||
def test_disallowed(self):
|
||||
config = {
|
||||
"default": True,
|
||||
"domain_mapping": {
|
||||
"source_one": [ "target_one", "target_two" ],
|
||||
"source_two": [ "target_two" ]
|
||||
"source_one": ["target_one", "target_two"],
|
||||
"source_two": ["target_two"]
|
||||
}
|
||||
}
|
||||
check = DomainRuleChecker(config)
|
||||
self.assertFalse(check.user_may_invite("test:source_one","test:target_three", "room"))
|
||||
self.assertFalse(check.user_may_invite("test:source_two","test:target_three", "room"))
|
||||
self.assertFalse(check.user_may_invite("test:source_two","test:target_one", "room"))
|
||||
|
||||
self.assertFalse(check.user_may_invite("test:source_one",
|
||||
"test:target_three", "room"))
|
||||
self.assertFalse(check.user_may_invite("test:source_two",
|
||||
"test:target_three", "room"))
|
||||
self.assertFalse(check.user_may_invite("test:source_two",
|
||||
"test:target_one", "room"))
|
||||
|
||||
def test_default_allow(self):
|
||||
config = {
|
||||
"default": True,
|
||||
"domain_mapping": {
|
||||
"source_one": [ "target_one", "target_two" ],
|
||||
"source_two": [ "target_two" ]
|
||||
}
|
||||
"default": True,
|
||||
"domain_mapping": {
|
||||
"source_one": ["target_one", "target_two"],
|
||||
"source_two": ["target_two"]
|
||||
}
|
||||
}
|
||||
check = DomainRuleChecker(config)
|
||||
self.assertTrue(check.user_may_invite("test:source_three","test:target_one", "room"))
|
||||
self.assertTrue(check.user_may_invite("test:source_three",
|
||||
"test:target_one", "room"))
|
||||
|
||||
def test_default_deny(self):
|
||||
config = {
|
||||
"default": False,
|
||||
"domain_mapping": {
|
||||
"source_one": [ "target_one", "target_two" ],
|
||||
"source_two": [ "target_two" ]
|
||||
}
|
||||
"default": False,
|
||||
"domain_mapping": {
|
||||
"source_one": ["target_one", "target_two"],
|
||||
"source_two": ["target_two"]
|
||||
}
|
||||
}
|
||||
check = DomainRuleChecker(config)
|
||||
self.assertFalse(check.user_may_invite("test:source_three","test:target_one", "room"))
|
||||
|
||||
self.assertFalse(check.user_may_invite("test:source_three",
|
||||
"test:target_one", "room"))
|
||||
|
||||
def test_config_parse(self):
|
||||
config = {
|
||||
"default": False,
|
||||
"domain_mapping": {
|
||||
"source_one": [ "target_one", "target_two" ],
|
||||
"source_two": [ "target_two" ]
|
||||
}
|
||||
"default": False,
|
||||
"domain_mapping": {
|
||||
"source_one": ["target_one", "target_two"],
|
||||
"source_two": ["target_two"]
|
||||
}
|
||||
}
|
||||
self.assertEquals(config, DomainRuleChecker.parse_config(config))
|
||||
|
||||
|
||||
def test_config_parse_failure(self):
|
||||
config = {
|
||||
"domain_mapping": {
|
||||
"source_one": [ "target_one", "target_two" ],
|
||||
"source_two": [ "target_two" ]
|
||||
}
|
||||
"domain_mapping": {
|
||||
"source_one": ["target_one", "target_two"],
|
||||
"source_two": ["target_two"]
|
||||
}
|
||||
}
|
||||
self.assertRaises(ConfigError, DomainRuleChecker.parse_config, config)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue