Skip to content
Open
Show file tree
Hide file tree
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
78 changes: 72 additions & 6 deletions tests/csapi/device_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,18 @@ func TestDeviceListUpdates(t *testing.T) {
})

// The observing user must share a room with the dummy barrier user.
roomID := barry.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := barry.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
observingUser.MustJoinRoom(t, roomID, []spec.ServerName{
deployment.GetFullyQualifiedHomeserverName(t, otherHSName),
})
Expand Down Expand Up @@ -160,7 +171,18 @@ func TestDeviceListUpdates(t *testing.T) {
barrier := makeBarrier(t, deployment, alice, otherHSName)
checkBobKeys := uploadNewKeys(t, bob)

roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
Comment on lines +174 to +185
Copy link
Collaborator

@MadLittleMods MadLittleMods Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for homeservers that only apply E2EE logic (device changes, etc) to shared encrypted rooms, vs. all shared rooms.

So I don't have to guess or make assumptions from the code, can you be more specific with what that means? How does this work for Synapse?

Making this change, makes it work with babbleserv because xxx?

Does the Matrix spec say anything around this? Does it need a clarification?

t.Logf("%s created test room %s.", alice.UserID, roomID)

// Alice performs an initial sync
Expand Down Expand Up @@ -215,7 +237,18 @@ func TestDeviceListUpdates(t *testing.T) {
barrier := makeBarrier(t, deployment, alice, otherHSName)
checkBobKeys := uploadNewKeys(t, bob)

roomID := bob.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := bob.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
t.Logf("%s created test room %s.", bob.UserID, roomID)

// Alice performs an initial sync
Expand Down Expand Up @@ -268,7 +301,18 @@ func TestDeviceListUpdates(t *testing.T) {
barrier := makeBarrier(t, deployment, alice, otherHSName)
checkBobKeys := uploadNewKeys(t, bob)

roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
t.Logf("%s created test room %s.", alice.UserID, roomID)

// Bob joins the room
Expand Down Expand Up @@ -327,7 +371,18 @@ func TestDeviceListUpdates(t *testing.T) {
barrier := makeBarrier(t, deployment, alice, otherHSName)
checkBobKeys := uploadNewKeys(t, bob)

roomID := bob.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := bob.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
t.Logf("%s created test room %s.", bob.UserID, roomID)

// Alice joins the room
Expand Down Expand Up @@ -386,7 +441,18 @@ func TestDeviceListUpdates(t *testing.T) {
barrier := makeBarrier(t, deployment, alice, otherHSName)
checkBobKeys := uploadNewKeys(t, bob)

roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
t.Logf("%s created test room %s.", alice.UserID, roomID)

// Bob joins the room
Expand Down
15 changes: 13 additions & 2 deletions tests/csapi/keychanges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ func TestKeyChangesLocal(t *testing.T) {
bobDeviceKeys, bobOTKs := bob.MustGenerateOneTimeKeys(t, 1)
bob.MustUploadKeys(t, bobDeviceKeys, bobOTKs)

roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
bob.MustJoinRoom(t, roomID, []spec.ServerName{})
nextBatch1 := alice.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(bob.UserID, roomID))

Expand All @@ -45,7 +56,7 @@ func TestKeyChangesLocal(t *testing.T) {
"password": password,
})
// Create a new device by logging in
res := unauthedClient.MustDo(t, "POST", []string{"_matrix", "client", "r0", "login"}, reqBody)
res := unauthedClient.MustDo(t, "POST", []string{"_matrix", "client", "v3", "login"}, reqBody)
loginResp := must.ParseJSON(t, res.Body)
unauthedClient.AccessToken = must.GetJSONFieldStr(t, loginResp, "access_token")
unauthedClient.DeviceID = must.GetJSONFieldStr(t, loginResp, "device_id")
Expand Down
13 changes: 12 additions & 1 deletion tests/csapi/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,18 @@ func TestSync(t *testing.T) {
// Regression test for https://github.com/element-hq/synapse/issues/16948

charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{LocalpartSuffix: "charlie"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})

aliceSyncFilter := `{
"room": {
Expand Down
9 changes: 8 additions & 1 deletion tests/federation_device_list_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,14 @@ func TestDeviceListsUpdateOverFederationOnRoomJoin(t *testing.T) {
bob := srv.UserID("complement_bob")
roomVer := gomatrixserverlib.RoomVersion("10")
initalEvents := federation.InitialRoomEvents(roomVer, bob)
room := srv.MustMakeRoom(t, roomVer, initalEvents)
room := srv.MustMakeRoom(t, roomVer, append(initalEvents, federation.Event{
Type: "m.room.encryption",
StateKey: b.Ptr(""),
Sender: bob,
Content: map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
}))

alice.MustJoinRoom(t, room.RoomID, []spec.ServerName{srv.ServerName()})
alice.SendEventSynced(t, room.RoomID, b.Event{
Expand Down
13 changes: 12 additions & 1 deletion tests/federation_upload_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ func TestFederationKeyUploadQuery(t *testing.T) {
bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{})

// for device lists to be shared between alice and bob they must share a room
roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"})
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"preset": "public_chat",
"initial_state": []map[string]interface{}{
{
"type": "m.room.encryption",
"state_key": "",
"content": map[string]interface{}{
"algorithm": "m.megolm.v1.aes-sha2",
},
},
},
})
bob.MustJoinRoom(t, roomID, []spec.ServerName{
deployment.GetFullyQualifiedHomeserverName(t, "hs1"),
})
Expand Down
Loading