@@ -261,12 +261,12 @@ func (c *CSAPI) GetAllPushRules(t ct.TestLike) gjson.Result {
261261 return gjson .ParseBytes (pushRulesBytes )
262262}
263263
264- // GetPushRule queries the contents of a client's push rule by scope, kind and rule ID.
264+ // MustGetPushRule queries the contents of a client's push rule by scope, kind and rule ID.
265265// A parsed gjson result is returned. Fails the test if the query to server returns a non-2xx status code.
266266//
267267// Example of checking that a global underride rule contains the expected actions:
268268//
269- // containsDisplayNameRule := c.GetPushRule (t, "global", "underride", ".m.rule.contains_display_name")
269+ // containsDisplayNameRule := c.MustGetPushRule (t, "global", "underride", ".m.rule.contains_display_name")
270270// must.MatchGJSON(
271271// t,
272272// containsDisplayNameRule,
@@ -276,14 +276,23 @@ func (c *CSAPI) GetAllPushRules(t ct.TestLike) gjson.Result {
276276// map[string]interface{}{"set_tweak": "highlight"},
277277// }),
278278// )
279- func (c * CSAPI ) GetPushRule (t ct.TestLike , scope string , kind string , ruleID string ) gjson.Result {
279+ func (c * CSAPI ) MustGetPushRule (t ct.TestLike , scope string , kind string , ruleID string ) gjson.Result {
280280 t .Helper ()
281281
282- res := c .MustDo (t , "GET" , []string {"_matrix" , "client" , "v3" , "pushrules" , scope , kind , ruleID })
282+ res := c .GetPushRule (t , scope , kind , ruleID )
283+ mustRespond2xx (t , res )
284+
283285 pushRuleBytes := ParseJSON (t , res )
284286 return gjson .ParseBytes (pushRuleBytes )
285287}
286288
289+ // GetPushRule queries the contents of a client's push rule by scope, kind and rule ID.
290+ func (c * CSAPI ) GetPushRule (t ct.TestLike , scope string , kind string , ruleID string ) * http.Response {
291+ t .Helper ()
292+
293+ return c .Do (t , "GET" , []string {"_matrix" , "client" , "v3" , "pushrules" , scope , kind , ruleID })
294+ }
295+
287296// SetPushRule creates a new push rule on the user, or modifies an existing one.
288297// If `before` or `after` parameters are not set to an empty string, their values
289298// will be set as the `before` and `after` query parameters respectively on the
@@ -310,6 +319,14 @@ func (c *CSAPI) SetPushRule(t ct.TestLike, scope string, kind string, ruleID str
310319 return c .MustDo (t , "PUT" , []string {"_matrix" , "client" , "v3" , "pushrules" , scope , kind , ruleID }, WithJSONBody (t , body ), WithQueries (queryParams ))
311320}
312321
322+ // MustDisablePushRule disables a push rule on the user.
323+ // Fails the test if response is non-2xx.
324+ func (c * CSAPI ) MustDisablePushRule (t ct.TestLike , scope string , kind string , ruleID string ) {
325+ c .MustDo (t , "PUT" , []string {"_matrix" , "client" , "v3" , "pushrules" , scope , kind , ruleID , "enabled" }, WithJSONBody (t , map [string ]interface {}{
326+ "enabled" : false ,
327+ }))
328+ }
329+
313330// Unsafe_SendEventUnsynced sends `e` into the room. This function is UNSAFE as it does not wait
314331// for the event to be fully processed. This can cause flakey tests. Prefer `SendEventSynced`.
315332// Returns the event ID of the sent event.
0 commit comments