-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Erik Johnston <erik@matrix.org> Co-authored-by: David Robertson <davidr@element.io> Co-authored-by: Kegan Dougal <kegan@matrix.org>
- Loading branch information
1 parent
6c31e8d
commit 25adcae
Showing
6 changed files
with
133 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//go:build msc3787 | ||
// +build msc3787 | ||
|
||
// This file contains tests for a join rule which mixes concepts of restricted joins | ||
// and knocking. This is currently experimental and defined by MSC3787, found here: | ||
// /~https://github.com/matrix-org/matrix-spec-proposals/pull/3787 | ||
// | ||
// Generally, this is a combination of knocking_test and restricted_rooms_test. | ||
|
||
package tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/matrix-org/complement/internal/b" | ||
) | ||
|
||
var ( | ||
msc3787RoomVersion = "org.matrix.msc3787" | ||
msc3787JoinRule = "knock_restricted" | ||
) | ||
|
||
// See TestKnocking | ||
func TestKnockingInMSC3787Room(t *testing.T) { | ||
doTestKnocking(t, msc3787RoomVersion, msc3787JoinRule) | ||
} | ||
|
||
// See TestKnockRoomsInPublicRoomsDirectory | ||
func TestKnockRoomsInPublicRoomsDirectoryInMSC3787Room(t *testing.T) { | ||
doTestKnockRoomsInPublicRoomsDirectory(t, msc3787RoomVersion, msc3787JoinRule) | ||
} | ||
|
||
// See TestCannotSendKnockViaSendKnock | ||
func TestCannotSendKnockViaSendKnockInMSC3787Room(t *testing.T) { | ||
testValidationForSendMembershipEndpoint(t, "/_matrix/federation/v1/send_knock", "knock", | ||
map[string]interface{}{ | ||
"preset": "public_chat", | ||
"room_version": msc3787RoomVersion, | ||
}, | ||
) | ||
} | ||
|
||
// See TestRestrictedRoomsLocalJoin | ||
func TestRestrictedRoomsLocalJoinInMSC3787Room(t *testing.T) { | ||
deployment := Deploy(t, b.BlueprintOneToOneRoom) | ||
defer deployment.Destroy(t) | ||
|
||
// Setup the user, allowed room, and restricted room. | ||
alice, allowed_room, room := setupRestrictedRoom(t, deployment, msc3787RoomVersion, msc3787JoinRule) | ||
|
||
// Create a second user on the same homeserver. | ||
bob := deployment.Client(t, "hs1", "@bob:hs1") | ||
|
||
// Execute the checks. | ||
checkRestrictedRoom(t, alice, bob, allowed_room, room, msc3787JoinRule) | ||
} | ||
|
||
// See TestRestrictedRoomsRemoteJoin | ||
func TestRestrictedRoomsRemoteJoinInMSC3787Room(t *testing.T) { | ||
deployment := Deploy(t, b.BlueprintFederationOneToOneRoom) | ||
defer deployment.Destroy(t) | ||
|
||
// Setup the user, allowed room, and restricted room. | ||
alice, allowed_room, room := setupRestrictedRoom(t, deployment, msc3787RoomVersion, msc3787JoinRule) | ||
|
||
// Create a second user on a different homeserver. | ||
bob := deployment.Client(t, "hs2", "@bob:hs2") | ||
|
||
// Execute the checks. | ||
checkRestrictedRoom(t, alice, bob, allowed_room, room, msc3787JoinRule) | ||
} | ||
|
||
// See TestRestrictedRoomsRemoteJoinLocalUser | ||
func TestRestrictedRoomsRemoteJoinLocalUserInMSC3787Room(t *testing.T) { | ||
doTestRestrictedRoomsRemoteJoinLocalUser(t, msc3787RoomVersion, msc3787JoinRule) | ||
} | ||
|
||
// See TestRestrictedRoomsRemoteJoinFailOver | ||
func TestRestrictedRoomsRemoteJoinFailOverInMSC3787Room(t *testing.T) { | ||
doTestRestrictedRoomsRemoteJoinFailOver(t, msc3787RoomVersion, msc3787JoinRule) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters