complement/tests/knock_restricted_test.go
kegsay a669c750c8
Remove Deployment.Client and change Deploy (#676)
* Remove Deployment.Client and change Deploy

- `Deployment.Client` was used to get pre-registered clients. Now we want tests to register new users for each test, for dirty runs. So swap for `Deployment.Register` everywhere.
- `Deploy` was used to deploy a blueprint. We don't want this to enable dirty runs. So replace it with the number of servers you need e.g `Deploy(t, 2)`.

* Fix up more broken refactoring

* unbreak tests; make user localpart look nicer

* Alice and bob must share a room for presence

* Fix user directory test

* Fix race condition caused by making the room later than before
2023-10-17 18:07:43 +01:00

81 lines
2.4 KiB
Go

//go:build !dendrite_blacklist
// +build !dendrite_blacklist
// This file contains tests for a join rule which mixes concepts of restricted joins
// and knocking. This is implemented in room version 10.
//
// Generally, this is a combination of knocking_test and restricted_rooms_test.
package tests
import (
"testing"
"github.com/matrix-org/complement"
"github.com/matrix-org/complement/helpers"
)
var (
roomVersion = "10"
joinRule = "knock_restricted"
)
// See TestKnocking
func TestKnockingInMSC3787Room(t *testing.T) {
doTestKnocking(t, roomVersion, joinRule)
}
// See TestKnockRoomsInPublicRoomsDirectory
func TestKnockRoomsInPublicRoomsDirectoryInMSC3787Room(t *testing.T) {
doTestKnockRoomsInPublicRoomsDirectory(t, roomVersion, joinRule)
}
// See TestCannotSendKnockViaSendKnock
func TestCannotSendKnockViaSendKnockInMSC3787Room(t *testing.T) {
testValidationForSendMembershipEndpoint(t, "/_matrix/federation/v1/send_knock", "knock",
map[string]interface{}{
"preset": "public_chat",
"room_version": roomVersion,
},
)
}
// See TestRestrictedRoomsLocalJoin
func TestRestrictedRoomsLocalJoinInMSC3787Room(t *testing.T) {
deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)
// Setup the user, allowed room, and restricted room.
alice, allowed_room, room := setupRestrictedRoom(t, deployment, roomVersion, joinRule)
// Create a second user on the same homeserver.
bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{})
// Execute the checks.
checkRestrictedRoom(t, alice, bob, allowed_room, room, joinRule)
}
// See TestRestrictedRoomsRemoteJoin
func TestRestrictedRoomsRemoteJoinInMSC3787Room(t *testing.T) {
deployment := complement.Deploy(t, 2)
defer deployment.Destroy(t)
// Setup the user, allowed room, and restricted room.
alice, allowed_room, room := setupRestrictedRoom(t, deployment, roomVersion, joinRule)
// Create a second user on a different homeserver.
bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{})
// Execute the checks.
checkRestrictedRoom(t, alice, bob, allowed_room, room, joinRule)
}
// See TestRestrictedRoomsRemoteJoinLocalUser
func TestRestrictedRoomsRemoteJoinLocalUserInMSC3787Room(t *testing.T) {
doTestRestrictedRoomsRemoteJoinLocalUser(t, roomVersion, joinRule)
}
// See TestRestrictedRoomsRemoteJoinFailOver
func TestRestrictedRoomsRemoteJoinFailOverInMSC3787Room(t *testing.T) {
doTestRestrictedRoomsRemoteJoinFailOver(t, roomVersion, joinRule)
}