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
18 changes: 18 additions & 0 deletions runtime/hs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package runtime

import (
"context"
"slices"

"github.com/docker/docker/client"
"github.com/matrix-org/complement/ct"
Expand All @@ -12,6 +13,7 @@ const (
Synapse = "synapse"
Conduit = "conduit"
Conduwuit = "conduwuit"
Venator = "venator"
)

var Homeserver string
Expand Down Expand Up @@ -50,3 +52,19 @@ func SkipIf(t ct.TestLike, hses ...string) {
)
}
}

// SkipUnless is the inverse of SkipIf: if the homeserver being tested is not present in the provided set, the test is skipped.
// This also means running without a blacklist tag will always skip.
func SkipUnless(t ct.TestLike, hses ...string) {
t.Helper()
if slices.Contains(hses, Homeserver) {
return
}
if Homeserver == "" {
t.Logf(
"WARNING: %s called runtime.SkipUnless(%v) but Complement doesn't know which HS is running as it was run without a *_blacklist tag: not executing test.",
t.Name(), hses,
)
}
t.Skipf("test only runs on specific homeservers: %v", hses)
}
7 changes: 7 additions & 0 deletions runtime/hs_venator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build venator_blacklist

package runtime

func init() {
Homeserver = Venator
}
6 changes: 4 additions & 2 deletions tests/csapi/account_change_password_pushers_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//go:build !dendrite_blacklist
// +build !dendrite_blacklist
//go:build !dendrite_blacklist && !venator_blacklist
// +build !dendrite_blacklist,!venator_blacklist

// Venator: https://github.com/matrix-org/complement/issues/897

package csapi_tests

Expand Down
5 changes: 5 additions & 0 deletions tests/csapi/account_change_password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,16 @@ import (
"github.com/matrix-org/complement/helpers"
"github.com/matrix-org/complement/match"
"github.com/matrix-org/complement/must"
"github.com/matrix-org/complement/runtime"

"github.com/tidwall/gjson"
)

func TestChangePassword(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/897
// Omitting the entire file via build tag breaks other test files due to the definition of createSession
runtime.SkipIf(t, runtime.Venator)

deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)
password1 := "superuser"
Expand Down
7 changes: 7 additions & 0 deletions tests/csapi/account_deactivate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"
"testing"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand Down Expand Up @@ -73,6 +74,8 @@ func TestDeactivateAccount(t *testing.T) {

// sytest: Can't deactivate account with wrong password
t.Run("Can't deactivate account with wrong password", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/898
runtime.SkipIf(t, runtime.Venator)
res := deactivateAccount(t, authedClient, "wrong_password")
must.MatchResponse(t, res, match.HTTPResponse{
StatusCode: 401,
Expand All @@ -83,6 +86,8 @@ func TestDeactivateAccount(t *testing.T) {
})
// sytest: Can deactivate account
t.Run("Can deactivate account", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/898
runtime.SkipIf(t, runtime.Venator)

res := deactivateAccount(t, authedClient, password)
must.MatchResponse(t, res, match.HTTPResponse{
Expand All @@ -91,6 +96,8 @@ func TestDeactivateAccount(t *testing.T) {
})
// sytest: After deactivating account, can't log in with password
t.Run("After deactivating account, can't log in with password", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/898
runtime.SkipIf(t, runtime.Venator)

reqBody := client.WithJSONBody(t, map[string]interface{}{
"identifier": map[string]interface{}{
Expand Down
2 changes: 2 additions & 0 deletions tests/csapi/apidoc_content_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
func TestContent(t *testing.T) {
// Synapse no longer allows downloads over the unauthenticated media endpoints by default
runtime.SkipIf(t, runtime.Synapse)
// Venator is too young for any media to be available over the unauthenticated API, and always returns M_NOT_FOUND
runtime.SkipIf(t, runtime.Venator)

deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)
Expand Down
5 changes: 5 additions & 0 deletions tests/csapi/apidoc_device_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package csapi_tests
import (
"testing"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand Down Expand Up @@ -126,6 +127,8 @@ func TestDeviceManagement(t *testing.T) {

// sytest: DELETE /device/{deviceId}
t.Run("DELETE /device/{deviceId}", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/899
runtime.SkipIf(t, runtime.Venator)
newDeviceID, session2 := createSession(t, deployment, authedClient.UserID, "superuser")
session2.MustSync(t, client.SyncReq{})

Expand Down Expand Up @@ -196,6 +199,8 @@ func TestDeviceManagement(t *testing.T) {
})
// sytest: DELETE /device/{deviceId} requires UI auth user to match device owner
t.Run("DELETE /device/{deviceId} requires UI auth user to match device owner", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/899
runtime.SkipIf(t, runtime.Venator)
bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{
LocalpartSuffix: "bob",
Password: "bobspassword",
Expand Down
5 changes: 3 additions & 2 deletions tests/csapi/apidoc_presence_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//go:build !dendrite_blacklist
// +build !dendrite_blacklist
//go:build !dendrite_blacklist && !venator_blacklist
// +build !dendrite_blacklist,!venator_blacklist

// Rationale for being included in Dendrite's blacklist: https://github.com/matrix-org/complement/pull/104#discussion_r617646624
// Venator: Does not implement presence

package csapi_tests

Expand Down
13 changes: 13 additions & 0 deletions tests/csapi/apidoc_register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/url"
"testing"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand Down Expand Up @@ -62,6 +63,8 @@ func TestRegistration(t *testing.T) {
})
// sytest: POST /register can create a user
t.Run("POST /register can create a user", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/893
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
res := unauthedClient.Do(t, "POST", []string{"_matrix", "client", "v3", "register"}, client.WithRawBody(json.RawMessage(`{
"auth": {
Expand All @@ -79,6 +82,8 @@ func TestRegistration(t *testing.T) {
})
// sytest: POST /register downcases capitals in usernames
t.Run("POST /register downcases capitals in usernames", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/893
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
res := unauthedClient.Do(t, "POST", []string{"_matrix", "client", "v3", "register"}, client.WithRawBody(json.RawMessage(`{
"auth": {
Expand All @@ -96,6 +101,8 @@ func TestRegistration(t *testing.T) {
})
// sytest: POST /register returns the same device_id as that in the request
t.Run("POST /register returns the same device_id as that in the request", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/893
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
deviceID := "my_device_id"
res := unauthedClient.Do(t, "POST", []string{"_matrix", "client", "v3", "register"}, client.WithRawBody(json.RawMessage(`{
Expand All @@ -115,6 +122,8 @@ func TestRegistration(t *testing.T) {
})
// sytest: POST /register rejects registration of usernames with '$q'
t.Run("POST /register rejects usernames with special characters", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/893
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
specialChars := []string{
`!`,
Expand Down Expand Up @@ -151,6 +160,8 @@ func TestRegistration(t *testing.T) {
}
})
t.Run("POST /register rejects if user already exists", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/893
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
res := unauthedClient.Do(t, "POST", []string{"_matrix", "client", "v3", "register"}, client.WithRawBody(json.RawMessage(`{
"auth": {
Expand Down Expand Up @@ -178,6 +189,8 @@ func TestRegistration(t *testing.T) {
})
// sytest: POST /register allows registration of usernames with '$chr'
t.Run("POST /register allows registration of usernames with ", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/893
runtime.SkipIf(t, runtime.Venator)
testChars := []rune("q3._=-/")
for x := range testChars {
localpart := fmt.Sprintf("chrtestuser%s", string(testChars[x]))
Expand Down
8 changes: 8 additions & 0 deletions tests/csapi/apidoc_room_alias_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand Down Expand Up @@ -276,6 +277,8 @@ func TestRoomDeleteAlias(t *testing.T) {

// sytest: Can delete canonical alias
t.Run("Can delete canonical alias", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/900
runtime.SkipIf(t, runtime.Venator)
t.Parallel()

roomID := alice.MustCreateRoom(t, map[string]interface{}{})
Expand Down Expand Up @@ -383,6 +386,8 @@ func TestRoomDeleteAlias(t *testing.T) {

// sytest: Users can't delete other's aliases
t.Run("Users can't delete other's aliases", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/900
runtime.SkipIf(t, runtime.Venator)
t.Parallel()

roomID := alice.MustCreateRoom(t, map[string]interface{}{})
Expand Down Expand Up @@ -416,6 +421,9 @@ func TestRoomDeleteAlias(t *testing.T) {

// sytest: Users with sufficient power-level can delete other's aliases
t.Run("Users with sufficient power-level can delete other's aliases", func(t *testing.T) {
// Venator: https://github.com/matrix-org/complement/issues/900
// This technically passes, but not because of the behaviour this test is testing for.
runtime.SkipIf(t, runtime.Venator)
t.Parallel()

roomID := alice.MustCreateRoom(t, map[string]interface{}{})
Expand Down
2 changes: 2 additions & 0 deletions tests/csapi/apidoc_room_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ func TestRoomCreate(t *testing.T) {
})
// sytest: POST /createRoom creates a room with the given version
t.Run("POST /createRoom creates a room with the given version", func(t *testing.T) {
// Venator: does not support room v2 (>=v10 only)
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
roomID := alice.MustCreateRoom(t, map[string]interface{}{
"room_version": "2",
Expand Down
3 changes: 3 additions & 0 deletions tests/csapi/apidoc_room_forget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/url"
"testing"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand All @@ -19,6 +20,8 @@ import (

// These tests ensure that forgetting about rooms works as intended
func TestRoomForget(t *testing.T) {
// Venator: does not implement manual room forgetting (is always done automatically on leave)
runtime.SkipIf(t, runtime.Venator)
deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)

Expand Down
5 changes: 5 additions & 0 deletions tests/csapi/apidoc_room_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand Down Expand Up @@ -59,6 +60,8 @@ func TestRoomState(t *testing.T) {
})
// sytest: GET /rooms/:room_id/state/m.room.power_levels fetches powerlevels
t.Run("GET /rooms/:room_id/state/m.room.power_levels fetches powerlevels", func(t *testing.T) {
// Venator doesn't marshal default values so the presence check fails despite being valid.
runtime.SkipIf(t, runtime.Venator)
t.Parallel()

roomID := authedClient.MustCreateRoom(t, map[string]interface{}{
Expand Down Expand Up @@ -329,6 +332,8 @@ func TestRoomState(t *testing.T) {
})
})
t.Run("GET /rooms/:room_id/joined_members is forbidden after leaving room", func(t *testing.T) {
// Venator: does not implement API version r0
runtime.SkipIf(t, runtime.Venator)
t.Parallel()
roomID := authedClient.MustCreateRoom(t, map[string]interface{}{})
authedClient.MustLeaveRoom(t, roomID)
Expand Down
26 changes: 22 additions & 4 deletions tests/csapi/device_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,34 @@ func TestDeviceListUpdates(t *testing.T) {
defer deployment.Destroy(t)

t.Run("when local user joins a room", func(t *testing.T) { testOtherUserJoin(t, deployment, "hs1", "hs1") })
t.Run("when remote user joins a room", func(t *testing.T) { testOtherUserJoin(t, deployment, "hs1", "hs2") })
t.Run("when remote user joins a room", func(t *testing.T) {
// Venator: does not yet implement federation
runtime.SkipIf(t, runtime.Venator)
testOtherUserJoin(t, deployment, "hs1", "hs2")
})
t.Run("when joining a room with a local user", func(t *testing.T) { testJoin(t, deployment, "hs1", "hs1") })
t.Run("when joining a room with a remote user", func(t *testing.T) { testJoin(t, deployment, "hs1", "hs2") })
t.Run("when joining a room with a remote user", func(t *testing.T) {
// Venator: does not yet implement federation
runtime.SkipIf(t, runtime.Venator)
testJoin(t, deployment, "hs1", "hs2")
})
t.Run("when local user leaves a room", func(t *testing.T) { testOtherUserLeave(t, deployment, "hs1", "hs1") })
t.Run("when remote user leaves a room", func(t *testing.T) { testOtherUserLeave(t, deployment, "hs1", "hs2") })
t.Run("when remote user leaves a room", func(t *testing.T) {
// Venator: does not yet implement federation
runtime.SkipIf(t, runtime.Venator)
testOtherUserLeave(t, deployment, "hs1", "hs2")
})
t.Run("when leaving a room with a local user", func(t *testing.T) { testLeave(t, deployment, "hs1", "hs1") })
t.Run("when leaving a room with a remote user", func(t *testing.T) {
runtime.SkipIf(t, runtime.Synapse) // FIXME: https://github.com/matrix-org/synapse/issues/13650
// Venator: does not yet implement federation
runtime.SkipIf(t, runtime.Venator)
testLeave(t, deployment, "hs1", "hs2")
})
t.Run("when local user rejoins a room", func(t *testing.T) { testOtherUserRejoin(t, deployment, "hs1", "hs1") })
t.Run("when remote user rejoins a room", func(t *testing.T) { testOtherUserRejoin(t, deployment, "hs1", "hs2") })
t.Run("when remote user rejoins a room", func(t *testing.T) {
// Venator: does not yet implement federation
runtime.SkipIf(t, runtime.Venator)
testOtherUserRejoin(t, deployment, "hs1", "hs2")
})
}
4 changes: 4 additions & 0 deletions tests/csapi/invalid_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build !venator_blacklist

// Venator: does not support room version 6 (>=v10 only)

package csapi_tests

import (
Expand Down
4 changes: 4 additions & 0 deletions tests/csapi/keychanges_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//go:build !venator_blacklist

// Venator: does not implement r0 API, which part of this test depends on

package csapi_tests

import (
Expand Down
3 changes: 3 additions & 0 deletions tests/csapi/media_async_uploads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func TestAsyncUpload(t *testing.T) {
})

t.Run("Not yet uploaded", func(t *testing.T) {
// Venator is too young for any media to be available over the unauthenticated API,
// and always returns M_NOT_FOUND
runtime.SkipIf(t, runtime.Venator)
mxcURI := alice.CreateMedia(t)
parts := strings.Split(mxcURI, "/")
mediaID := parts[len(parts)-1]
Expand Down
2 changes: 2 additions & 0 deletions tests/csapi/media_misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ func TestRoomImageRoundtrip(t *testing.T) {

// sytest: Can read configuration endpoint
func TestMediaConfig(t *testing.T) {
// Venator: does not permit the use of the legacy media API (always returns M_NOT_FOUND)
runtime.SkipIf(t, runtime.Venator)
deployment := complement.Deploy(t, 1)
defer deployment.Destroy(t)

Expand Down
5 changes: 5 additions & 0 deletions tests/csapi/power_levels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

"github.com/matrix-org/complement/runtime"
"github.com/tidwall/gjson"

"github.com/matrix-org/complement"
Expand Down Expand Up @@ -59,6 +60,10 @@ func TestPowerLevels(t *testing.T) {

// sytest: GET /rooms/:room_id/state/m.room.power_levels can fetch levels
t.Run("GET /rooms/:room_id/state/m.room.power_levels can fetch levels", func(t *testing.T) {
// Venator skips marshalling default values, which means all of these checks fail:
// > MatchJSONBytes key 'ban' missing with input = {}
// This is a feature :D
runtime.SkipIf(t, runtime.Venator)
// Test if the old state still exists
// note: before v10 we technically cannot assume that powerlevel integers are json numbers,
// as they can be both strings and numbers.
Expand Down
Loading
Loading