mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-28 13:02:08 -04:00
check_valid_filter using JSONSchema
* add invalid filter tests Signed-off-by: pik <alexander.maznev@gmail.com>
This commit is contained in:
parent
59358cd3e7
commit
e56c79c114
2 changed files with 175 additions and 94 deletions
|
@ -23,6 +23,7 @@ from tests.utils import (
|
|||
|
||||
from synapse.api.filtering import Filter
|
||||
from synapse.events import FrozenEvent
|
||||
from synapse.api.errors import SynapseError
|
||||
|
||||
user_localpart = "test_user"
|
||||
|
||||
|
@ -34,7 +35,6 @@ def MockEvent(**kwargs):
|
|||
kwargs["type"] = "fake_type"
|
||||
return FrozenEvent(kwargs)
|
||||
|
||||
|
||||
class FilteringTestCase(unittest.TestCase):
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
@ -54,6 +54,22 @@ class FilteringTestCase(unittest.TestCase):
|
|||
|
||||
self.datastore = hs.get_datastore()
|
||||
|
||||
def test_errors_on_invalid_filters(self):
|
||||
invalid_filters = [
|
||||
{ "boom": {} },
|
||||
{ "account_data": "Hello World" },
|
||||
{ "event_fields": ["\\foo"] },
|
||||
{ "room": { "timeline" : { "limit" : 0 }, "state": { "not_bars": ["*"]} } },
|
||||
]
|
||||
for filter in invalid_filters:
|
||||
with self.assertRaises(SynapseError) as check_filter_error:
|
||||
self.filtering.check_valid_filter(filter)
|
||||
self.assertIsInstance(check_filter_error.exception, SynapseError)
|
||||
|
||||
def test_limits_are_applied(self):
|
||||
#TODO
|
||||
pass
|
||||
|
||||
def test_definition_types_works_with_literals(self):
|
||||
definition = {
|
||||
"types": ["m.room.message", "org.matrix.foo.bar"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue