Skip to content

Commit e719bfb

Browse files
authored
Make the federation package public (#686)
Marked with EXPERIMENTAL all over as the API may change without warning.
1 parent 00850a7 commit e719bfb

19 files changed

+32
-15
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/matrix-org/util"
1616
)
1717

18+
// EXPERIMENTAL
1819
// MakeJoinRequestsHandler is the http.Handler implementation for the make_join part of
1920
// HandleMakeSendJoinRequests.
2021
func MakeJoinRequestsHandler(s *Server, w http.ResponseWriter, req *http.Request) {
@@ -53,6 +54,7 @@ func MakeJoinRequestsHandler(s *Server, w http.ResponseWriter, req *http.Request
5354
w.Write(b)
5455
}
5556

57+
// EXPERIMENTAL
5658
// MakeRespMakeJoin makes the response for a /make_join request, without verifying any signatures
5759
// or dealing with HTTP responses itself.
5860
func MakeRespMakeJoin(s *Server, room *ServerRoom, userID string) (resp fclient.RespMakeJoin, err error) {
@@ -84,6 +86,7 @@ func MakeRespMakeJoin(s *Server, room *ServerRoom, userID string) (resp fclient.
8486
return
8587
}
8688

89+
// EXPERIMENTAL
8790
// MakeRespMakeKnock makes the response for a /make_knock request, without verifying any signatures
8891
// or dealing with HTTP responses itself.
8992
func MakeRespMakeKnock(s *Server, room *ServerRoom, userID string) (resp fclient.RespMakeKnock, err error) {
@@ -115,6 +118,7 @@ func MakeRespMakeKnock(s *Server, room *ServerRoom, userID string) (resp fclient
115118
return
116119
}
117120

121+
// EXPERIMENTAL
118122
// SendJoinRequestsHandler is the http.Handler implementation for the send_join part of
119123
// HandleMakeSendJoinRequests.
120124
//
@@ -212,6 +216,7 @@ func SendJoinRequestsHandler(s *Server, w http.ResponseWriter, req *http.Request
212216
w.Write(b)
213217
}
214218

219+
// EXPERIMENTAL
215220
// HandleMakeSendJoinRequests is an option which will process make_join and send_join requests for rooms which are present
216221
// in this server. To add a room to this server, see Server.MustMakeRoom. No checks are done to see whether join requests
217222
// are allowed or not. If you wish to test that, write your own test.
@@ -240,6 +245,7 @@ func HandlePartialStateMakeSendJoinRequests() func(*Server) {
240245
}
241246
}
242247

248+
// EXPERIMENTAL
243249
// HandleInviteRequests is an option which makes the server process invite requests.
244250
//
245251
// inviteCallback is a callback function that if non-nil will be called and passed the incoming invite event
@@ -289,6 +295,7 @@ func HandleInviteRequests(inviteCallback func(gomatrixserverlib.PDU)) func(*Serv
289295
}
290296
}
291297

298+
// EXPERIMENTAL
292299
// HandleDirectoryLookups will automatically return room IDs for any aliases present on this server.
293300
func HandleDirectoryLookups() func(*Server) {
294301
return func(s *Server) {
@@ -323,6 +330,7 @@ func HandleDirectoryLookups() func(*Server) {
323330
}
324331
}
325332

333+
// EXPERIMENTAL
326334
// HandleEventRequests is an option which will process GET /_matrix/federation/v1/event/{eventId} requests universally when requested.
327335
func HandleEventRequests() func(*Server) {
328336
return func(srv *Server) {
@@ -366,6 +374,7 @@ func HandleEventRequests() func(*Server) {
366374
}
367375
}
368376

377+
// EXPERIMENTAL
369378
// HandleEventAuthRequests is an option which will process GET /_matrix/federation/v1/event_auth/{roomId}/{eventId}
370379
// requests universally when requested.
371380
func HandleEventAuthRequests() func(*Server) {
@@ -415,6 +424,7 @@ func HandleEventAuthRequests() func(*Server) {
415424
}
416425
}
417426

427+
// EXPERIMENTAL
418428
// HandleKeyRequests is an option which will process GET /_matrix/key/v2/server requests universally when requested.
419429
func HandleKeyRequests() func(*Server) {
420430
return func(srv *Server) {
@@ -455,6 +465,7 @@ func HandleKeyRequests() func(*Server) {
455465
}
456466
}
457467

468+
// EXPERIMENTAL
458469
// HandleMediaRequests is an option which will process /_matrix/media/v1/download/* using the provided map
459470
// as a way to do so. The key of the map is the media ID to be handled.
460471
func HandleMediaRequests(mediaIds map[string]func(w http.ResponseWriter)) func(*Server) {
@@ -489,6 +500,7 @@ func HandleMediaRequests(mediaIds map[string]func(w http.ResponseWriter)) func(*
489500
}
490501
}
491502

503+
// EXPERIMENTAL
492504
// HandleTransactionRequests is an option which will process GET /_matrix/federation/v1/send/{transactionID} requests universally when requested.
493505
// pduCallback and eduCallback are functions that if non-nil will be called and passed each PDU or EDU event received in the transaction.
494506
// Callbacks will be fired AFTER the event has been stored onto the respective ServerRoom.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// package federation is an EXPERIMENTAL set of functions for creating mock federation servers, for testing over federation.
2+
// It is marked as EXPERIMENTAL as the API may break without warning.
13
package federation
24

35
import (
@@ -38,6 +40,7 @@ type FederationDeployment interface {
3840
RoundTripper() http.RoundTripper
3941
}
4042

43+
// EXPERIMENTAL
4144
// Server represents a federation server
4245
type Server struct {
4346
t *testing.T
@@ -61,6 +64,7 @@ type Server struct {
6164
keyRing *gomatrixserverlib.KeyRing
6265
}
6366

67+
// EXPERIMENTAL
6468
// NewServer creates a new federation server with configured options.
6569
func NewServer(t *testing.T, deployment FederationDeployment, opts ...func(*Server)) *Server {
6670
// generate signing key
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ type Event struct {
2929
Redacts string
3030
}
3131

32+
// EXPERIMENTAL
3233
// ServerRoom represents a room on this test federation server
3334
type ServerRoom struct {
3435
Version gomatrixserverlib.RoomVersion

tests/csapi/sync_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/matrix-org/complement/b"
1313
"github.com/matrix-org/complement/client"
1414
"github.com/matrix-org/complement/helpers"
15-
"github.com/matrix-org/complement/internal/federation"
15+
"github.com/matrix-org/complement/federation"
1616
"github.com/matrix-org/complement/runtime"
1717
"github.com/matrix-org/gomatrixserverlib"
1818
"github.com/matrix-org/gomatrixserverlib/fclient"

tests/direct_messaging_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/matrix-org/complement"
1010
"github.com/matrix-org/complement/client"
1111
"github.com/matrix-org/complement/helpers"
12-
"github.com/matrix-org/complement/internal/federation"
12+
"github.com/matrix-org/complement/federation"
1313
"github.com/matrix-org/complement/match"
1414
"github.com/matrix-org/complement/must"
1515
"github.com/matrix-org/gomatrixserverlib/fclient"

tests/federation_event_auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/matrix-org/complement"
99
"github.com/matrix-org/complement/b"
1010
"github.com/matrix-org/complement/helpers"
11-
"github.com/matrix-org/complement/internal/federation"
11+
"github.com/matrix-org/complement/federation"
1212
"github.com/matrix-org/complement/must"
1313
"github.com/matrix-org/gomatrixserverlib/spec"
1414

tests/federation_query_profile_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
"github.com/matrix-org/complement/client"
1414
"github.com/matrix-org/complement/helpers"
15-
"github.com/matrix-org/complement/internal/federation"
15+
"github.com/matrix-org/complement/federation"
1616
"github.com/matrix-org/complement/match"
1717
"github.com/matrix-org/complement/must"
1818
)

tests/federation_redaction_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
"github.com/matrix-org/complement"
88
"github.com/matrix-org/complement/helpers"
9-
"github.com/matrix-org/complement/internal/federation"
9+
"github.com/matrix-org/complement/federation"
1010
"github.com/matrix-org/complement/must"
1111
"github.com/matrix-org/complement/runtime"
1212
"github.com/matrix-org/gomatrixserverlib"

tests/federation_room_event_auth_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/matrix-org/complement/b"
2222
"github.com/matrix-org/complement/client"
2323
"github.com/matrix-org/complement/helpers"
24-
"github.com/matrix-org/complement/internal/federation"
24+
"github.com/matrix-org/complement/federation"
2525
"github.com/matrix-org/complement/must"
2626
)
2727

0 commit comments

Comments
 (0)