Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Ignore unknown conditions to fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Sep 19, 2022
1 parent e58aa13 commit 7528928
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
8 changes: 1 addition & 7 deletions rust/src/push/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,8 @@ impl PushRuleEvaluator {
) -> Result<bool, Error> {
let known_condition = match condition {
Condition::Known(known) => known,

// XXX This looks incorrect -- we have reached an unknown condition
// kind and are unconditionally returning that it matches. Note that
// it seems possible to provide a condition to the /pushrules
// endpoint with an unknown kind, see
// _rule_tuple_from_request_object.
Condition::Unknown(_) => {
return Ok(true);
return Ok(false);
}
};

Expand Down
3 changes: 0 additions & 3 deletions tests/push/test_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,6 @@ def test_relation_match(self) -> None:
evaluator = self._get_evaluator(
{}, {"m.annotation": {("@user:test", "m.reaction")}}
)
condition = {"kind": "relation_match"}
# Oddly, an unknown condition always matches.
self.assertTrue(evaluator.matches(condition, "@user:test", "foo"))

# A push rule evaluator with the experimental rule enabled.
evaluator = self._get_evaluator(
Expand Down

0 comments on commit 7528928

Please sign in to comment.