@@ -261,12 +261,12 @@ func (c *CSAPI) GetAllPushRules(t ct.TestLike) gjson.Result {
261
261
return gjson .ParseBytes (pushRulesBytes )
262
262
}
263
263
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.
265
265
// A parsed gjson result is returned. Fails the test if the query to server returns a non-2xx status code.
266
266
//
267
267
// Example of checking that a global underride rule contains the expected actions:
268
268
//
269
- // containsDisplayNameRule := c.GetPushRule (t, "global", "underride", ".m.rule.contains_display_name")
269
+ // containsDisplayNameRule := c.MustGetPushRule (t, "global", "underride", ".m.rule.contains_display_name")
270
270
// must.MatchGJSON(
271
271
// t,
272
272
// containsDisplayNameRule,
@@ -276,14 +276,23 @@ func (c *CSAPI) GetAllPushRules(t ct.TestLike) gjson.Result {
276
276
// map[string]interface{}{"set_tweak": "highlight"},
277
277
// }),
278
278
// )
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 {
280
280
t .Helper ()
281
281
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
+
283
285
pushRuleBytes := ParseJSON (t , res )
284
286
return gjson .ParseBytes (pushRuleBytes )
285
287
}
286
288
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
+
287
296
// SetPushRule creates a new push rule on the user, or modifies an existing one.
288
297
// If `before` or `after` parameters are not set to an empty string, their values
289
298
// 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
310
319
return c .MustDo (t , "PUT" , []string {"_matrix" , "client" , "v3" , "pushrules" , scope , kind , ruleID }, WithJSONBody (t , body ), WithQueries (queryParams ))
311
320
}
312
321
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
+
313
330
// Unsafe_SendEventUnsynced sends `e` into the room. This function is UNSAFE as it does not wait
314
331
// for the event to be fully processed. This can cause flakey tests. Prefer `SendEventSynced`.
315
332
// Returns the event ID of the sent event.
0 commit comments