aboutsummaryrefslogtreecommitdiff
path: root/federationapi/federationapi_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'federationapi/federationapi_test.go')
-rw-r--r--federationapi/federationapi_test.go29
1 files changed, 15 insertions, 14 deletions
diff --git a/federationapi/federationapi_test.go b/federationapi/federationapi_test.go
index 3c01a825..a8af0000 100644
--- a/federationapi/federationapi_test.go
+++ b/federationapi/federationapi_test.go
@@ -16,6 +16,7 @@ import (
"github.com/matrix-org/gomatrix"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/gomatrixserverlib/fclient"
+ "github.com/matrix-org/gomatrixserverlib/spec"
"github.com/nats-io/nats.go"
"github.com/matrix-org/dendrite/federationapi"
@@ -56,7 +57,7 @@ type fedClient struct {
fedClientMutex sync.Mutex
api.FederationClient
allowJoins []*test.Room
- keys map[gomatrixserverlib.ServerName]struct {
+ keys map[spec.ServerName]struct {
key ed25519.PrivateKey
keyID gomatrixserverlib.KeyID
}
@@ -64,7 +65,7 @@ type fedClient struct {
sentTxn bool
}
-func (f *fedClient) GetServerKeys(ctx context.Context, matrixServer gomatrixserverlib.ServerName) (gomatrixserverlib.ServerKeys, error) {
+func (f *fedClient) GetServerKeys(ctx context.Context, matrixServer spec.ServerName) (gomatrixserverlib.ServerKeys, error) {
f.fedClientMutex.Lock()
defer f.fedClientMutex.Unlock()
fmt.Println("GetServerKeys:", matrixServer)
@@ -83,11 +84,11 @@ func (f *fedClient) GetServerKeys(ctx context.Context, matrixServer gomatrixserv
}
keys.ServerName = matrixServer
- keys.ValidUntilTS = gomatrixserverlib.AsTimestamp(time.Now().Add(10 * time.Hour))
+ keys.ValidUntilTS = spec.AsTimestamp(time.Now().Add(10 * time.Hour))
publicKey := pkey.Public().(ed25519.PublicKey)
keys.VerifyKeys = map[gomatrixserverlib.KeyID]gomatrixserverlib.VerifyKey{
keyID: {
- Key: gomatrixserverlib.Base64Bytes(publicKey),
+ Key: spec.Base64Bytes(publicKey),
},
}
toSign, err := json.Marshal(keys.ServerKeyFields)
@@ -105,7 +106,7 @@ func (f *fedClient) GetServerKeys(ctx context.Context, matrixServer gomatrixserv
return keys, nil
}
-func (f *fedClient) MakeJoin(ctx context.Context, origin, s gomatrixserverlib.ServerName, roomID, userID string, roomVersions []gomatrixserverlib.RoomVersion) (res fclient.RespMakeJoin, err error) {
+func (f *fedClient) MakeJoin(ctx context.Context, origin, s spec.ServerName, roomID, userID string, roomVersions []gomatrixserverlib.RoomVersion) (res fclient.RespMakeJoin, err error) {
for _, r := range f.allowJoins {
if r.ID == roomID {
res.RoomVersion = r.Version
@@ -114,7 +115,7 @@ func (f *fedClient) MakeJoin(ctx context.Context, origin, s gomatrixserverlib.Se
RoomID: roomID,
Type: "m.room.member",
StateKey: &userID,
- Content: gomatrixserverlib.RawJSON([]byte(`{"membership":"join"}`)),
+ Content: spec.RawJSON([]byte(`{"membership":"join"}`)),
PrevEvents: r.ForwardExtremities(),
}
var needed gomatrixserverlib.StateNeeded
@@ -129,7 +130,7 @@ func (f *fedClient) MakeJoin(ctx context.Context, origin, s gomatrixserverlib.Se
}
return
}
-func (f *fedClient) SendJoin(ctx context.Context, origin, s gomatrixserverlib.ServerName, event *gomatrixserverlib.Event) (res fclient.RespSendJoin, err error) {
+func (f *fedClient) SendJoin(ctx context.Context, origin, s spec.ServerName, event *gomatrixserverlib.Event) (res fclient.RespSendJoin, err error) {
f.fedClientMutex.Lock()
defer f.fedClientMutex.Unlock()
for _, r := range f.allowJoins {
@@ -147,7 +148,7 @@ func (f *fedClient) SendTransaction(ctx context.Context, t gomatrixserverlib.Tra
f.fedClientMutex.Lock()
defer f.fedClientMutex.Unlock()
for _, edu := range t.EDUs {
- if edu.Type == gomatrixserverlib.MDeviceListUpdate {
+ if edu.Type == spec.MDeviceListUpdate {
f.sentTxn = true
}
}
@@ -174,7 +175,7 @@ func testFederationAPIJoinThenKeyUpdate(t *testing.T, dbType test.DBType) {
jsctx, _ := natsInstance.Prepare(processCtx, &cfg.Global.JetStream)
defer jetstream.DeleteAllStreams(jsctx, &cfg.Global.JetStream)
- serverA := gomatrixserverlib.ServerName("server.a")
+ serverA := spec.ServerName("server.a")
serverAKeyID := gomatrixserverlib.KeyID("ed25519:servera")
serverAPrivKey := test.PrivateKeyA
creator := test.NewUser(t, test.WithSigningServer(serverA, serverAKeyID, serverAPrivKey))
@@ -203,7 +204,7 @@ func testFederationAPIJoinThenKeyUpdate(t *testing.T, dbType test.DBType) {
fc := &fedClient{
allowJoins: []*test.Room{room},
t: t,
- keys: map[gomatrixserverlib.ServerName]struct {
+ keys: map[spec.ServerName]struct {
key ed25519.PrivateKey
keyID gomatrixserverlib.KeyID
}{
@@ -223,7 +224,7 @@ func testFederationAPIJoinThenKeyUpdate(t *testing.T, dbType test.DBType) {
fsapi.PerformJoin(context.Background(), &api.PerformJoinRequest{
RoomID: room.ID,
UserID: joiningUser.ID,
- ServerNames: []gomatrixserverlib.ServerName{serverA},
+ ServerNames: []spec.ServerName{serverA},
}, &resp)
if resp.JoinedVia != serverA {
t.Errorf("PerformJoin: joined via %v want %v", resp.JoinedVia, serverA)
@@ -302,7 +303,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
_, privKey, _ := ed25519.GenerateKey(nil)
cfg.Global.KeyID = gomatrixserverlib.KeyID("ed25519:auto")
- cfg.Global.ServerName = gomatrixserverlib.ServerName("localhost")
+ cfg.Global.ServerName = spec.ServerName("localhost")
cfg.Global.PrivateKey = privKey
cfg.Global.JetStream.InMemory = true
keyRing := &test.NopJSONVerifier{}
@@ -312,7 +313,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
federationapi.AddPublicRoutes(processCtx, routers, cfg, &natsInstance, nil, nil, keyRing, nil, &internal.FederationInternalAPI{}, nil, caching.DisableMetrics)
baseURL, cancel := test.ListenAndServe(t, routers.Federation, true)
defer cancel()
- serverName := gomatrixserverlib.ServerName(strings.TrimPrefix(baseURL, "https://"))
+ serverName := spec.ServerName(strings.TrimPrefix(baseURL, "https://"))
fedCli := fclient.NewFederationClient(
cfg.Global.SigningIdentities(),
@@ -325,7 +326,7 @@ func TestRoomsV3URLEscapeDoNot404(t *testing.T) {
t.Errorf("failed to parse event: %s", err)
}
he := ev.Headered(tc.roomVer)
- invReq, err := gomatrixserverlib.NewInviteV2Request(he, nil)
+ invReq, err := fclient.NewInviteV2Request(he, nil)
if err != nil {
t.Errorf("failed to create invite v2 request: %s", err)
continue