Add pushrules tests (#3044)

partly takes care of https://github.com/matrix-org/dendrite/issues/2870
by making sure that rule IDs don't start with a dot.

Co-authored-by: kegsay <kegan@matrix.org>
This commit is contained in:
Till 2023-04-14 13:35:27 +02:00 committed by GitHub
parent ca63b414da
commit c45d8cd688
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 430 additions and 68 deletions

View file

@ -10,6 +10,10 @@ import (
func ValidateRule(kind Kind, rule *Rule) []error {
var errs []error
if len(rule.RuleID) > 0 && rule.RuleID[:1] == "." {
errs = append(errs, fmt.Errorf("invalid rule ID: rule can not start with a dot"))
}
if !validRuleIDRE.MatchString(rule.RuleID) {
errs = append(errs, fmt.Errorf("invalid rule ID: %s", rule.RuleID))
}