Skip to content

Add test for failover of federated joins #612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/federation_room_join_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,36 @@ func TestJoinViaRoomIDAndServerName(t *testing.T) {
})
}

// This tests that joining a room with multiple ?server_name=s works correctly.
// The join should succeed even if the first server is not in the room.
func TestJoinFederatedRoomFailOver(t *testing.T) {
deployment := Deploy(t, b.BlueprintFederationOneToOneRoom)
defer deployment.Destroy(t)

alice := deployment.Client(t, "hs1", "@alice:hs1")
bob := deployment.Client(t, "hs2", "@bob:hs2")

srv := federation.NewServer(t, deployment)
cancel := srv.Listen()
defer cancel()

srv.Mux().Handle("/_matrix/federation/v1/make_join/{roomID}/{userID}", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
t.Logf("Complement homeserver responds to /make_join with 404, M_NOT_FOUND.")
w.WriteHeader(404)
w.Write([]byte(`{
"errcode": "M_NOT_FOUND",
"error": "Unknown room."
}`))
})).Methods("GET")

roomID := bob.CreateRoom(t, map[string]interface{}{"preset": "public_chat"})
t.Logf("%s created room %s.", bob.UserID, roomID)

t.Logf("%s joins the room via {complement,hs2}.", alice.UserID)
alice.JoinRoom(t, roomID, []string{srv.ServerName(), "hs2"})
bob.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(alice.UserID, roomID))
}

// This tests that joining a room over federation works in the presence of:
// - Events with missing signatures
// - Events with bad signatures
Expand Down