|
| 1 | +package csapi_tests |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/matrix-org/complement/internal/b" |
| 7 | +) |
| 8 | + |
| 9 | +// This test ensures that an authorised (PL 100) user is able to modify the users_default value |
| 10 | +// when that value is equal to the value of authorised user. |
| 11 | +// Regression test for https://github.com/matrix-org/gomatrixserverlib/pull/306 |
| 12 | +func TestDemotingUsersViaUsersDefault(t *testing.T) { |
| 13 | + deployment := Deploy(t, b.BlueprintAlice) |
| 14 | + defer deployment.Destroy(t) |
| 15 | + |
| 16 | + alice := deployment.Client(t, "hs1", "@alice:hs1") |
| 17 | + |
| 18 | + roomID := alice.CreateRoom(t, map[string]interface{}{ |
| 19 | + "preset": "public_chat", |
| 20 | + "power_level_content_override": map[string]interface{}{ |
| 21 | + "users_default": 100, // the default is 0 |
| 22 | + "users": map[string]interface{}{ |
| 23 | + alice.UserID: 100, |
| 24 | + }, |
| 25 | + "events": map[string]int64{}, |
| 26 | + "notifications": map[string]int64{}, |
| 27 | + }, |
| 28 | + }) |
| 29 | + |
| 30 | + alice.SendEventSynced(t, roomID, b.Event{ |
| 31 | + Type: "m.room.power_levels", |
| 32 | + StateKey: b.Ptr(""), |
| 33 | + Content: map[string]interface{}{ |
| 34 | + "users_default": 40, // we change the default to 40. We should be able to do this. |
| 35 | + "users": map[string]interface{}{ |
| 36 | + alice.UserID: 100, |
| 37 | + }, |
| 38 | + "events": map[string]int64{}, |
| 39 | + "notifications": map[string]int64{}, |
| 40 | + }, |
| 41 | + }) |
| 42 | +} |
0 commit comments