From 6ec9a3a28fb2baec9afb4fc8b9974a5f5d6525fc Mon Sep 17 00:00:00 2001 From: strawberry Date: Mon, 9 Dec 2024 13:02:39 -0500 Subject: [PATCH 1/3] remove pointless invalid join_authorised_via_users_server field due to strict ruma parsing requirements Signed-off-by: strawberry --- tests/restricted_rooms_test.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/restricted_rooms_test.go b/tests/restricted_rooms_test.go index 4d31f169..64d170fd 100644 --- a/tests/restricted_rooms_test.go +++ b/tests/restricted_rooms_test.go @@ -99,8 +99,6 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a Content: map[string]interface{}{ "membership": "join", "displayname": "Bobby", - // This should be ignored since this is a join -> join transition. - "join_authorised_via_users_server": "unused", }, }, ) From 14cc5be797b774f1a2b9f826f38181066d4952b8 Mon Sep 17 00:00:00 2001 From: strawberry Date: Sun, 15 Dec 2024 17:59:56 -0500 Subject: [PATCH 2/3] add back join_authorised_via_users_server correctly formatted Signed-off-by: strawberry --- tests/restricted_rooms_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/restricted_rooms_test.go b/tests/restricted_rooms_test.go index 64d170fd..bc98d6bc 100644 --- a/tests/restricted_rooms_test.go +++ b/tests/restricted_rooms_test.go @@ -99,6 +99,8 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a Content: map[string]interface{}{ "membership": "join", "displayname": "Bobby", + // This should be ignored by the server since this is a join -> join transition + "join_authorised_via_users_server": "@unused:unused.local", }, }, ) From 4830c39010a0a9393d462201c8897f3da860875c Mon Sep 17 00:00:00 2001 From: morguldir Date: Tue, 31 Dec 2024 07:35:50 +0100 Subject: [PATCH 3/3] make restricted room join tests fail earlier when something goes wrong Signed-off-by: morguldir --- tests/restricted_rooms_test.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/restricted_rooms_test.go b/tests/restricted_rooms_test.go index bc98d6bc..24bb4644 100644 --- a/tests/restricted_rooms_test.go +++ b/tests/restricted_rooms_test.go @@ -64,7 +64,7 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a t.Run("Join should succeed when joined to allowed room", func(t *testing.T) { // Join the allowed room. - bob.JoinRoom(t, allowed_room, []string{"hs1"}) + bob.MustJoinRoom(t, allowed_room, []string{"hs1"}) // Confirm that we joined the allowed room by changing displayname and // waiting for confirmation in the /sync response. (This is an attempt @@ -86,7 +86,7 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a ) // We should now be able to join the restricted room. - bob.JoinRoom(t, room, []string{"hs1"}) + bob.MustJoinRoom(t, room, []string{"hs1"}) // Joining the same room again should work fine (e.g. to change your display name). bob.SendEventSynced( @@ -114,6 +114,15 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a // Wait until Alice sees Bob leave the allowed room. This ensures that Alice's HS // has processed the leave before Bob tries rejoining, so that it rejects his // attempt to join the room. + alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHas( + room, func(ev gjson.Result) bool { + if ev.Get("type").Str != "m.room.member" || ev.Get("sender").Str != bob.UserID { + return false + } + + return ev.Get("content").Get("membership").Str == "leave" + })) + alice.MustSyncUntil(t, client.SyncReq{}, client.SyncTimelineHas( allowed_room, func(ev gjson.Result) bool { if ev.Get("type").Str != "m.room.member" || ev.Get("sender").Str != bob.UserID { @@ -130,11 +139,11 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a t.Run("Join should succeed when invited", func(t *testing.T) { // Invite the user and joining should work. alice.MustInviteRoom(t, room, bob.UserID) - bob.JoinRoom(t, room, []string{"hs1"}) + bob.MustJoinRoom(t, room, []string{"hs1"}) // Leave the room again, and join the allowed room. bob.MustLeaveRoom(t, room) - bob.JoinRoom(t, allowed_room, []string{"hs1"}) + bob.MustJoinRoom(t, allowed_room, []string{"hs1"}) }) t.Run("Join should fail with mangled join rules", func(t *testing.T) {