diff --git a/client/client.go b/client/client.go index 9d73a70b..74d4b0fd 100644 --- a/client/client.go +++ b/client/client.go @@ -38,12 +38,14 @@ const ansiResetForeground = "\x1b[39m" // errorf is a wrapper around t.Errorf which prints the failing error message in red. func errorf(t TestLike, format string, args ...any) { + t.Helper() format = ansiRedForeground + format + ansiResetForeground t.Errorf(format, args...) } // fatalf is a wrapper around t.Fatalf which prints the failing error message in red. func fatalf(t TestLike, format string, args ...any) { + t.Helper() format = ansiRedForeground + format + ansiResetForeground t.Fatalf(format, args...) } diff --git a/internal/docker/deployment.go b/internal/docker/deployment.go index 4b4d0ebc..d27b9b4a 100644 --- a/internal/docker/deployment.go +++ b/internal/docker/deployment.go @@ -36,8 +36,10 @@ type HomeserverDeployment struct { accessTokensMutex sync.RWMutex ApplicationServices map[string]string // e.g { "my-as-id": "id: xxx\nas_token: xxx ..."} } DeviceIDs map[string]string // e.g { "@alice:hs1": "myDeviceID" } - CSAPIClients []*client.CSAPI - CSAPIClientsMutex sync.Mutex + + // track all clients so if Restart() is called we can repoint to the new high-numbered port + CSAPIClients []*client.CSAPI + CSAPIClientsMutex sync.Mutex } // Updates the client and federation base URLs of the homeserver deployment. @@ -85,7 +87,11 @@ func (d *Deployment) Register(t *testing.T, hsName string, opts helpers.Registra if password == "" { password = "complement_meets_min_password_req" } - localpart := fmt.Sprintf("user-%v-%v", d.localpartCounter.Add(1), opts.LocalpartSuffix) + + localpart := fmt.Sprintf("user-%v", d.localpartCounter.Add(1)) + if opts.LocalpartSuffix != "" { + localpart += fmt.Sprintf("-%s", opts.LocalpartSuffix) + } var userID, accessToken, deviceID string if opts.IsAdmin { userID, accessToken, deviceID = client.RegisterSharedSecret(t, localpart, password, opts.IsAdmin) @@ -133,10 +139,29 @@ func (d *Deployment) Login(t *testing.T, hsName string, existing *client.CSAPI, return client } -// Client returns a CSAPI client targeting the given hsName, using the access token for the given userID. -// Fails the test if the hsName is not found. Returns an unauthenticated client if userID is "", fails the test -// if the userID is otherwise not found. -func (d *Deployment) Client(t *testing.T, hsName, userID string) *client.CSAPI { +func (d *Deployment) UnauthenticatedClient(t *testing.T, hsName string) *client.CSAPI { + t.Helper() + dep, ok := d.HS[hsName] + if !ok { + t.Fatalf("Deployment.Client - HS name '%s' not found", hsName) + return nil + } + client := &client.CSAPI{ + BaseURL: dep.BaseURL, + Client: client.NewLoggedClient(t, hsName, nil), + SyncUntilTimeout: 5 * time.Second, + Debug: d.Deployer.debugLogging, + } + // Appending a slice is not thread-safe. Protect the write with a mutex. + dep.CSAPIClientsMutex.Lock() + dep.CSAPIClients = append(dep.CSAPIClients, client) + dep.CSAPIClientsMutex.Unlock() + return client +} + +// AppServiceUser returns a client for the given app service user ID. The HS in question must have an appservice +// hooked up to it already. TODO: REMOVE +func (d *Deployment) AppServiceUser(t *testing.T, hsName, appServiceUserID string) *client.CSAPI { t.Helper() dep, ok := d.HS[hsName] if !ok { @@ -144,18 +169,18 @@ func (d *Deployment) Client(t *testing.T, hsName, userID string) *client.CSAPI { return nil } dep.accessTokensMutex.RLock() - token := dep.AccessTokens[userID] + token := dep.AccessTokens[appServiceUserID] dep.accessTokensMutex.RUnlock() - if token == "" && userID != "" { - t.Fatalf("Deployment.Client - HS name '%s' - user ID '%s' not found", hsName, userID) + if token == "" && appServiceUserID != "" { + t.Fatalf("Deployment.Client - HS name '%s' - user ID '%s' not found", hsName, appServiceUserID) return nil } - deviceID := dep.DeviceIDs[userID] - if deviceID == "" && userID != "" { - t.Logf("WARNING: Deployment.Client - HS name '%s' - user ID '%s' - deviceID not found", hsName, userID) + deviceID := dep.DeviceIDs[appServiceUserID] + if deviceID == "" && appServiceUserID != "" { + t.Logf("WARNING: Deployment.Client - HS name '%s' - user ID '%s' - deviceID not found", hsName, appServiceUserID) } client := &client.CSAPI{ - UserID: userID, + UserID: appServiceUserID, AccessToken: token, DeviceID: deviceID, BaseURL: dep.BaseURL, diff --git a/test_main.go b/test_main.go index c47fd3ff..f0a5e53d 100644 --- a/test_main.go +++ b/test_main.go @@ -34,10 +34,21 @@ func TestMain(m *testing.M, namespace string) { // It will construct the blueprint if it doesn't already exist in the docker image cache. // This function is the main setup function for all tests as it provides a deployment with // which tests can interact with. -func Deploy(t *testing.T, blueprint b.Blueprint) Deployment { +func OldDeploy(t *testing.T, blueprint b.Blueprint) Deployment { t.Helper() if testPackage == nil { t.Fatalf("Deploy: testPackage not set, did you forget to call complement.TestMain?") } - return testPackage.Deploy(t, blueprint) + return testPackage.OldDeploy(t, blueprint) +} + +// Deploy will deploy the given number of servers or terminate the test. +// This function is the main setup function for all tests as it provides a deployment with +// which tests can interact with. +func Deploy(t *testing.T, numServers int) Deployment { + t.Helper() + if testPackage == nil { + t.Fatalf("Deploy: testPackage not set, did you forget to call complement.TestMain?") + } + return testPackage.Deploy(t, numServers) } diff --git a/test_package.go b/test_package.go index eefc654a..73ea52e3 100644 --- a/test_package.go +++ b/test_package.go @@ -19,15 +19,16 @@ import ( // Deployment provides a way for tests to interact with a set of homeservers. type Deployment interface { - // Client returns a CSAPI client targeting the given hsName, using the access token for the given userID. - // Fails the test if the hsName is not found. Returns an unauthenticated client if userID is "", fails the test - // if the userID is otherwise not found. - Client(t *testing.T, serverName, userID string) *client.CSAPI + // UnauthenticatedClient returns a blank CSAPI client. + UnauthenticatedClient(t *testing.T, serverName string) *client.CSAPI // Register a new user on the given server. Register(t *testing.T, hsName string, opts helpers.RegistrationOpts) *client.CSAPI // Login to an existing user account on the given server. In order to make tests not hardcode full user IDs, // an existing logged in client must be supplied. Login(t *testing.T, hsName string, existing *client.CSAPI, opts helpers.LoginOpts) *client.CSAPI + // AppServiceUser returns a client for the given app service user ID. The HS in question must have an appservice + // hooked up to it already. TODO: REMOVE + AppServiceUser(t *testing.T, hsName, appServiceUserID string) *client.CSAPI // Restart a deployment. Restart(t *testing.T) error // Destroy the entire deployment. Destroys all running containers. If `printServerLogs` is true, @@ -82,9 +83,30 @@ func (tp *TestPackage) Cleanup() { // It will construct the blueprint if it doesn't already exist in the docker image cache. // This function is the main setup function for all tests as it provides a deployment with // which tests can interact with. -func (tp *TestPackage) Deploy(t *testing.T, blueprint b.Blueprint) Deployment { +func (tp *TestPackage) OldDeploy(t *testing.T, blueprint b.Blueprint) Deployment { t.Helper() timeStartBlueprint := time.Now() + if err := tp.complementBuilder.ConstructBlueprintIfNotExist(blueprint); err != nil { + t.Fatalf("OldDeploy: Failed to construct blueprint: %s", err) + } + namespace := fmt.Sprintf("%d", atomic.AddUint64(&tp.namespaceCounter, 1)) + d, err := docker.NewDeployer(namespace, tp.complementBuilder.Config) + if err != nil { + t.Fatalf("OldDeploy: NewDeployer returned error %s", err) + } + timeStartDeploy := time.Now() + dep, err := d.Deploy(context.Background(), blueprint.Name) + if err != nil { + t.Fatalf("OldDeploy: Deploy returned error %s", err) + } + t.Logf("OldDeploy times: %v blueprints, %v containers", timeStartDeploy.Sub(timeStartBlueprint), time.Since(timeStartDeploy)) + return dep +} + +func (tp *TestPackage) Deploy(t *testing.T, numServers int) Deployment { + t.Helper() + blueprint := mapServersToBlueprint(numServers) + timeStartBlueprint := time.Now() if err := tp.complementBuilder.ConstructBlueprintIfNotExist(blueprint); err != nil { t.Fatalf("Deploy: Failed to construct blueprint: %s", err) } @@ -102,6 +124,16 @@ func (tp *TestPackage) Deploy(t *testing.T, blueprint b.Blueprint) Deployment { return dep } -func (tp *TestPackage) DeployDirty(t *testing.T, numServers int) Deployment { - return nil +// converts the requested number of servers into a single blueprint, which can be deployed using normal blueprint machinery. +func mapServersToBlueprint(numServers int) b.Blueprint { + servers := make([]b.Homeserver, numServers) + for i := range servers { + servers[i] = b.Homeserver{ + Name: fmt.Sprintf("hs%d", i+1), // hs1,hs2,... + } + } + return b.MustValidate(b.Blueprint{ + Name: fmt.Sprintf("%d_servers", numServers), + Homeservers: servers, + }) } diff --git a/tests/csapi/account_change_password_pushers_test.go b/tests/csapi/account_change_password_pushers_test.go index afa0b9bf..6607c002 100644 --- a/tests/csapi/account_change_password_pushers_test.go +++ b/tests/csapi/account_change_password_pushers_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -17,7 +16,7 @@ import ( ) func TestChangePasswordPushers(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) password1 := "superuser" password2 := "my_new_password" diff --git a/tests/csapi/account_change_password_test.go b/tests/csapi/account_change_password_test.go index 505580b8..efd8ecb0 100644 --- a/tests/csapi/account_change_password_test.go +++ b/tests/csapi/account_change_password_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -15,14 +14,14 @@ import ( ) func TestChangePassword(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) password1 := "superuser" password2 := "my_new_password" passwordClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{ Password: password1, }) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") _, sessionTest := createSession(t, deployment, passwordClient.UserID, "superuser") // sytest: After changing password, can't log in with old password t.Run("After changing password, can't log in with old password", func(t *testing.T) { @@ -124,7 +123,7 @@ func changePassword(t *testing.T, passwordClient *client.CSAPI, oldPassword stri } func createSession(t *testing.T, deployment complement.Deployment, userID, password string) (deviceID string, authedClient *client.CSAPI) { - authedClient = deployment.Client(t, "hs1", "") + authedClient = deployment.UnauthenticatedClient(t, "hs1") reqBody := client.WithJSONBody(t, map[string]interface{}{ "identifier": map[string]interface{}{ "type": "m.id.user", diff --git a/tests/csapi/account_data_test.go b/tests/csapi/account_data_test.go index e49a81e4..33f0da8b 100644 --- a/tests/csapi/account_data_test.go +++ b/tests/csapi/account_data_test.go @@ -4,16 +4,16 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestAddAccountData(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // sytest: Can add account data // sytest: Can get account data without syncing diff --git a/tests/csapi/account_deactivate_test.go b/tests/csapi/account_deactivate_test.go index 5e5f0240..b8a82ccb 100644 --- a/tests/csapi/account_deactivate_test.go +++ b/tests/csapi/account_deactivate_test.go @@ -7,7 +7,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -15,13 +14,13 @@ import ( ) func TestDeactivateAccount(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) password := "superuser" authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{ Password: password, }) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") // Ensure that the first step, in which the client queries the server's user-interactive auth flows, returns // at least one auth flow involving a password. diff --git a/tests/csapi/admin_test.go b/tests/csapi/admin_test.go index 4913b6d2..6234505a 100644 --- a/tests/csapi/admin_test.go +++ b/tests/csapi/admin_test.go @@ -8,7 +8,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -18,7 +17,7 @@ import ( // Check if this homeserver supports Synapse-style admin registration. // Not all images support this currently. func TestCanRegisterAdmin(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) deployment.Register(t, "hs1", helpers.RegistrationOpts{ IsAdmin: true, @@ -27,15 +26,15 @@ func TestCanRegisterAdmin(t *testing.T) { // Test if the implemented /_synapse/admin/v1/send_server_notice behaves as expected func TestServerNotices(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) admin := deployment.Register(t, "hs1", helpers.RegistrationOpts{ IsAdmin: true, }) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) reqBody := client.WithJSONBody(t, map[string]interface{}{ - "user_id": "@alice:hs1", + "user_id": alice.UserID, "content": map[string]interface{}{ "msgtype": "m.text", "body": "hello from server notices!", diff --git a/tests/csapi/apidoc_content_test.go b/tests/csapi/apidoc_content_test.go index 99d6b0be..a28236c6 100644 --- a/tests/csapi/apidoc_content_test.go +++ b/tests/csapi/apidoc_content_test.go @@ -5,15 +5,15 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/data" ) func TestContent(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) wantContentType := "image/png" // sytest: POST /media/v3/upload can create an upload mxcUri := alice.UploadContent(t, data.MatrixPng, "test.png", wantContentType) diff --git a/tests/csapi/apidoc_device_management_test.go b/tests/csapi/apidoc_device_management_test.go index 37c2fbfd..430ba39b 100644 --- a/tests/csapi/apidoc_device_management_test.go +++ b/tests/csapi/apidoc_device_management_test.go @@ -6,7 +6,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -14,9 +13,9 @@ import ( ) func TestDeviceManagement(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{ Password: "superuser", }) diff --git a/tests/csapi/apidoc_login_test.go b/tests/csapi/apidoc_login_test.go index f5c51f23..5d0ed19d 100644 --- a/tests/csapi/apidoc_login_test.go +++ b/tests/csapi/apidoc_login_test.go @@ -9,7 +9,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -18,9 +17,9 @@ import ( ) func TestLogin(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") testClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{ Password: "superuser", }) diff --git a/tests/csapi/apidoc_logout_test.go b/tests/csapi/apidoc_logout_test.go index e9dad737..addd33dc 100644 --- a/tests/csapi/apidoc_logout_test.go +++ b/tests/csapi/apidoc_logout_test.go @@ -8,14 +8,13 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestLogout(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) password := "superuser" diff --git a/tests/csapi/apidoc_presence_test.go b/tests/csapi/apidoc_presence_test.go index 277526bc..387821d7 100644 --- a/tests/csapi/apidoc_presence_test.go +++ b/tests/csapi/apidoc_presence_test.go @@ -13,20 +13,25 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestPresence(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + + // to share presence alice and bob must be in a shared room + roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) + bob.MustJoinRoom(t, roomID, []string{"hs1"}) // sytest: GET /presence/:user_id/status fetches initial status t.Run("GET /presence/:user_id/status fetches initial status", func(t *testing.T) { - res := alice.Do(t, "GET", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}) + res := alice.Do(t, "GET", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ match.JSONKeyPresent("presence"), @@ -40,11 +45,11 @@ func TestPresence(t *testing.T) { "status_msg": statusMsg, "presence": "online", }) - res := alice.Do(t, "PUT", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}, reqBody) + res := alice.Do(t, "PUT", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}, reqBody) must.MatchResponse(t, res, match.HTTPResponse{ StatusCode: 200, }) - res = alice.Do(t, "GET", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}) + res = alice.Do(t, "GET", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ match.JSONKeyPresent("presence"), @@ -65,7 +70,7 @@ func TestPresence(t *testing.T) { _, bobSinceToken := bob.MustSync(t, client.SyncReq{TimeoutMillis: "0"}) statusMsg := "Update for room members" - alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}, + alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}, client.WithJSONBody(t, map[string]interface{}{ "status_msg": statusMsg, "presence": "online", @@ -82,7 +87,7 @@ func TestPresence(t *testing.T) { t.Run("Presence changes to UNAVAILABLE are reported to local room members", func(t *testing.T) { _, bobSinceToken := bob.MustSync(t, client.SyncReq{TimeoutMillis: "0"}) - alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}, + alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}, client.WithJSONBody(t, map[string]interface{}{ "presence": "unavailable", }), diff --git a/tests/csapi/apidoc_profile_avatar_url_test.go b/tests/csapi/apidoc_profile_avatar_url_test.go index 0aac008d..b73f35f2 100644 --- a/tests/csapi/apidoc_profile_avatar_url_test.go +++ b/tests/csapi/apidoc_profile_avatar_url_test.go @@ -4,17 +4,17 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestProfileAvatarURL(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") - authedClient := deployment.Client(t, "hs1", "@alice:hs1") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") + authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) avatarURL := "mxc://example.com/SEsfnsuifSDFSSEF" // sytest: PUT /profile/:user_id/avatar_url sets my avatar t.Run("PUT /profile/:user_id/avatar_url sets my avatar", func(t *testing.T) { diff --git a/tests/csapi/apidoc_profile_displayname_test.go b/tests/csapi/apidoc_profile_displayname_test.go index aeb827dd..a7629027 100644 --- a/tests/csapi/apidoc_profile_displayname_test.go +++ b/tests/csapi/apidoc_profile_displayname_test.go @@ -4,17 +4,17 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestProfileDisplayName(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") - authedClient := deployment.Client(t, "hs1", "@alice:hs1") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") + authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) displayName := "my_display_name" // sytest: PUT /profile/:user_id/displayname sets my name t.Run("PUT /profile/:user_id/displayname sets my name", func(t *testing.T) { diff --git a/tests/csapi/apidoc_register_test.go b/tests/csapi/apidoc_register_test.go index 84f0060a..965c0857 100644 --- a/tests/csapi/apidoc_register_test.go +++ b/tests/csapi/apidoc_register_test.go @@ -14,7 +14,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -37,9 +36,9 @@ import ( // Can register using an email address func TestRegistration(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") t.Run("parallel", func(t *testing.T) { // sytest: GET /register yields a set of flows // The name in Sytest is different, the test is actually doing a POST request. diff --git a/tests/csapi/apidoc_request_encoding_test.go b/tests/csapi/apidoc_request_encoding_test.go index 97450ac8..30eeb127 100644 --- a/tests/csapi/apidoc_request_encoding_test.go +++ b/tests/csapi/apidoc_request_encoding_test.go @@ -6,16 +6,15 @@ import ( "encoding/json" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestRequestEncodingFails(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") testString := `{ "test":"a` + "\x81" + `" }` // sytest: POST rejects invalid utf-8 in JSON t.Run("POST rejects invalid utf-8 in JSON", func(t *testing.T) { diff --git a/tests/csapi/apidoc_room_alias_test.go b/tests/csapi/apidoc_room_alias_test.go index 5e49ac76..65cff3c9 100644 --- a/tests/csapi/apidoc_room_alias_test.go +++ b/tests/csapi/apidoc_room_alias_test.go @@ -10,6 +10,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/should" @@ -60,10 +61,10 @@ func mustSetCanonicalAlias(t *testing.T, c *client.CSAPI, roomID string, roomAli } func TestRoomAlias(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: PUT /directory/room/:room_alias creates alias @@ -186,10 +187,10 @@ func TestRoomAlias(t *testing.T) { } func TestRoomDeleteAlias(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: Alias creators can delete alias with no ops @@ -457,9 +458,9 @@ func TestRoomDeleteAlias(t *testing.T) { } func TestRoomCanonicalAlias(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { diff --git a/tests/csapi/apidoc_room_create_test.go b/tests/csapi/apidoc_room_create_test.go index 200fc148..2fea3dbc 100644 --- a/tests/csapi/apidoc_room_create_test.go +++ b/tests/csapi/apidoc_room_create_test.go @@ -8,16 +8,17 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestRoomCreate(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: POST /createRoom makes a public room diff --git a/tests/csapi/apidoc_room_forget_test.go b/tests/csapi/apidoc_room_forget_test.go index 45f62adf..1e3a4693 100644 --- a/tests/csapi/apidoc_room_forget_test.go +++ b/tests/csapi/apidoc_room_forget_test.go @@ -11,17 +11,18 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) // These tests ensure that forgetting about rooms works as intended func TestRoomForget(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: Can't forget room you're still in t.Run("Can't forget room you're still in", func(t *testing.T) { diff --git a/tests/csapi/apidoc_room_history_visibility_test.go b/tests/csapi/apidoc_room_history_visibility_test.go index 38bccaa9..9ab62f79 100644 --- a/tests/csapi/apidoc_room_history_visibility_test.go +++ b/tests/csapi/apidoc_room_history_visibility_test.go @@ -9,6 +9,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -37,11 +38,11 @@ func createRoomWithVisibility(t *testing.T, c *client.CSAPI, visibility string) // Fetches an event after join, and succeeds. // sytest: /event/ on joined room works func TestFetchEvent(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "shared") @@ -83,11 +84,11 @@ func TestFetchEvent(t *testing.T) { // history_visibility: joined // sytest: /event/ does not allow access to events before the user joined func TestFetchHistoricalJoinedEventDenied(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "joined") @@ -112,11 +113,11 @@ func TestFetchHistoricalJoinedEventDenied(t *testing.T) { // Tries to fetch an event before join, and succeeds. // history_visibility: shared func TestFetchHistoricalSharedEvent(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "shared") @@ -156,11 +157,11 @@ func TestFetchHistoricalSharedEvent(t *testing.T) { // Tries to fetch an event between being invited and joined, and succeeds. // history_visibility: invited func TestFetchHistoricalInvitedEventFromBetweenInvite(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "invited") @@ -203,11 +204,11 @@ func TestFetchHistoricalInvitedEventFromBetweenInvite(t *testing.T) { // Tries to fetch an event before being invited, and fails. // history_visibility: invited func TestFetchHistoricalInvitedEventFromBeforeInvite(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "invited") @@ -236,11 +237,11 @@ func TestFetchHistoricalInvitedEventFromBeforeInvite(t *testing.T) { // history_visibility: shared // sytest: /event/ on non world readable room does not work func TestFetchEventNonWorldReadable(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "shared") @@ -262,11 +263,11 @@ func TestFetchEventNonWorldReadable(t *testing.T) { // Tries to fetch an event without having joined, and succeeds. // history_visibility: world_readable func TestFetchEventWorldReadable(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := createRoomWithVisibility(t, alice, "world_readable") diff --git a/tests/csapi/apidoc_room_members_test.go b/tests/csapi/apidoc_room_members_test.go index 2d8fb19c..b62ef843 100644 --- a/tests/csapi/apidoc_room_members_test.go +++ b/tests/csapi/apidoc_room_members_test.go @@ -8,15 +8,16 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestRoomMembers(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: POST /rooms/:room_id/join can join a room t.Run("POST /rooms/:room_id/join can join a room", func(t *testing.T) { diff --git a/tests/csapi/apidoc_room_receipts_test.go b/tests/csapi/apidoc_room_receipts_test.go index f6deeec2..e78de2a1 100644 --- a/tests/csapi/apidoc_room_receipts_test.go +++ b/tests/csapi/apidoc_room_receipts_test.go @@ -6,6 +6,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/tidwall/gjson" ) @@ -36,9 +37,9 @@ func syncHasReadReceipt(roomID, userID, eventID string) client.SyncCheckOpt { // sytest: POST /rooms/:room_id/receipt can create receipts func TestRoomReceipts(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID, eventID := createRoomForReadReceipts(t, alice, deployment) alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "rooms", roomID, "receipt", "m.read", eventID}, client.WithJSONBody(t, struct{}{})) @@ -49,9 +50,9 @@ func TestRoomReceipts(t *testing.T) { // sytest: POST /rooms/:room_id/read_markers can create read marker func TestRoomReadMarkers(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID, eventID := createRoomForReadReceipts(t, alice, deployment) reqBody := client.WithJSONBody(t, map[string]interface{}{ diff --git a/tests/csapi/apidoc_room_state_test.go b/tests/csapi/apidoc_room_state_test.go index bb04b051..308e0f0f 100644 --- a/tests/csapi/apidoc_room_state_test.go +++ b/tests/csapi/apidoc_room_state_test.go @@ -9,16 +9,16 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestRoomState(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - authedClient := deployment.Client(t, "hs1", "@alice:hs1") + authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: GET /rooms/:room_id/state/m.room.member/:user_id fetches my membership t.Run("GET /rooms/:room_id/state/m.room.member/:user_id fetches my membership", func(t *testing.T) { diff --git a/tests/csapi/apidoc_search_test.go b/tests/csapi/apidoc_search_test.go index f98fb985..1640f636 100644 --- a/tests/csapi/apidoc_search_test.go +++ b/tests/csapi/apidoc_search_test.go @@ -11,6 +11,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -18,10 +19,10 @@ import ( // Note: In contrast to Sytest, we define a filter.rooms on each search request, this is to mimic // creating a new user and new room per test. This also allows us to run in parallel. func TestSearch(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("parallel", func(t *testing.T) { // sytest: Can search for an event by body diff --git a/tests/csapi/apidoc_server_capabilities_test.go b/tests/csapi/apidoc_server_capabilities_test.go index a42733ad..882c143c 100644 --- a/tests/csapi/apidoc_server_capabilities_test.go +++ b/tests/csapi/apidoc_server_capabilities_test.go @@ -5,17 +5,17 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestServerCapabilities(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - unauthedClient := deployment.Client(t, "hs1", "") - authedClient := deployment.Client(t, "hs1", "@alice:hs1") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") + authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // sytest: GET /capabilities is present and well formed for registered user data := authedClient.GetCapabilities(t) diff --git a/tests/csapi/apidoc_version_test.go b/tests/csapi/apidoc_version_test.go index 50eb1bb0..7584956b 100644 --- a/tests/csapi/apidoc_version_test.go +++ b/tests/csapi/apidoc_version_test.go @@ -8,7 +8,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -22,10 +21,10 @@ const GlobalVersionRegex = `v[1-9]\d*\.\d+(?:-\S+)?` const r0Regex = `r0\.\d+\.\d+` func TestVersionStructure(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - client := deployment.Client(t, "hs1", "") + client := deployment.UnauthenticatedClient(t, "hs1") // sytest: Version responds 200 OK with valid structure t.Run("Version responds 200 OK with valid structure", func(t *testing.T) { diff --git a/tests/csapi/device_lists_test.go b/tests/csapi/device_lists_test.go index b47b4f85..e25dbbce 100644 --- a/tests/csapi/device_lists_test.go +++ b/tests/csapi/device_lists_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -422,7 +421,7 @@ func TestDeviceListUpdates(t *testing.T) { // Create two homeservers // The users and rooms in the blueprint won't be used. // Each test creates their own Alice and Bob users. - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) t.Run("when local user joins a room", func(t *testing.T) { testOtherUserJoin(t, deployment, "hs1", "hs1") }) diff --git a/tests/csapi/e2e_key_backup_test.go b/tests/csapi/e2e_key_backup_test.go index 06bfbf63..1d08a214 100644 --- a/tests/csapi/e2e_key_backup_test.go +++ b/tests/csapi/e2e_key_backup_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -24,11 +24,10 @@ type backupKey struct { // if they have the same values for is_verified, then it will keep the key with a lower first_message_index; // and finally, is is_verified and first_message_index are equal, then it will keep the key with a lower forwarded_count. func TestE2EKeyBackupReplaceRoomKeyRules(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - userID := "@alice:hs1" roomID := "!foo:hs1" - alice := deployment.Client(t, "hs1", userID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // make a new key backup res := alice.MustDo(t, "POST", []string{"_matrix", "client", "v3", "room_keys", "version"}, client.WithJSONBody(t, map[string]interface{}{ diff --git a/tests/csapi/ignored_users_test.go b/tests/csapi/ignored_users_test.go index 145b003d..1c6aa5d9 100644 --- a/tests/csapi/ignored_users_test.go +++ b/tests/csapi/ignored_users_test.go @@ -11,7 +11,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -29,7 +28,7 @@ import ( // https://github.com/matrix-org/synapse/issues/11506 // to ensure that Synapse complies with this part of the spec. func TestInviteFromIgnoredUsersDoesNotAppearInSync(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{LocalpartSuffix: "alice"}) bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{LocalpartSuffix: "bob"}) diff --git a/tests/csapi/invalid_test.go b/tests/csapi/invalid_test.go index 5238d8c6..7d59cb6d 100644 --- a/tests/csapi/invalid_test.go +++ b/tests/csapi/invalid_test.go @@ -5,17 +5,17 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" ) func TestJson(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "room_opts": map[string]interface{}{ "room_version": "6", @@ -171,9 +171,9 @@ func getFilters() []map[string]interface{} { func TestFilter(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/2067 - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) filters := getFilters() @@ -188,9 +188,9 @@ func TestFilter(t *testing.T) { // sytest: Event size limits func TestEvent(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "room_opts": map[string]interface{}{ "room_version": "6", diff --git a/tests/csapi/keychanges_test.go b/tests/csapi/keychanges_test.go index 0692d420..93a9751c 100644 --- a/tests/csapi/keychanges_test.go +++ b/tests/csapi/keychanges_test.go @@ -9,7 +9,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -17,16 +16,16 @@ import ( ) func TestKeyChangesLocal(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) password := "$uperSecretPassword" bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "bob", Password: password, }) - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") t.Run("New login should create a device_lists.changed entry", func(t *testing.T) { mustUploadKeys(t, bob) diff --git a/tests/csapi/media_misc_test.go b/tests/csapi/media_misc_test.go index de593899..6efa39a5 100644 --- a/tests/csapi/media_misc_test.go +++ b/tests/csapi/media_misc_test.go @@ -9,6 +9,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/data" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" @@ -20,10 +21,10 @@ import ( func TestRoomImageRoundtrip(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1303 - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) mxcUri := alice.UploadContent(t, data.MatrixPng, "test.png", "image/png") @@ -62,10 +63,10 @@ func TestRoomImageRoundtrip(t *testing.T) { // sytest: Can read configuration endpoint func TestMediaConfig(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) res := alice.MustDo(t, "GET", []string{"_matrix", "media", "v3", "config"}) diff --git a/tests/csapi/power_levels_test.go b/tests/csapi/power_levels_test.go index 5d47a385..15a76056 100644 --- a/tests/csapi/power_levels_test.go +++ b/tests/csapi/power_levels_test.go @@ -9,6 +9,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -17,10 +18,10 @@ import ( // when that value is equal to the value of authorised user. // Regression test for https://github.com/matrix-org/gomatrixserverlib/pull/306 func TestDemotingUsersViaUsersDefault(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", @@ -49,10 +50,10 @@ func TestDemotingUsersViaUsersDefault(t *testing.T) { } func TestPowerLevels(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{}) diff --git a/tests/csapi/push_test.go b/tests/csapi/push_test.go index 85f0828d..5bfcb2a4 100644 --- a/tests/csapi/push_test.go +++ b/tests/csapi/push_test.go @@ -8,18 +8,18 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) // sytest: Getting push rules doesn't corrupt the cache SYN-390 func TestPushRuleCacheHealth(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Set a global push rule alice.SetPushRule(t, "global", "sender", alice.UserID, map[string]interface{}{ @@ -34,10 +34,10 @@ func TestPushRuleCacheHealth(t *testing.T) { } func TestPushSync(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) var syncResp gjson.Result var nextBatch string diff --git a/tests/csapi/room_ban_test.go b/tests/csapi/room_ban_test.go index fb346c2b..7a48dedf 100644 --- a/tests/csapi/room_ban_test.go +++ b/tests/csapi/room_ban_test.go @@ -6,6 +6,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -14,33 +15,12 @@ import ( // but this will actually validate against a present user in the room. // sytest: Non-present room members cannot ban others func TestNotPresentUserCannotBanOthers(t *testing.T) { - deployment := complement.Deploy(t, b.MustValidate(b.Blueprint{ - Name: "abc", - Homeservers: []b.Homeserver{ - { - Name: "hs1", - Users: []b.User{ - { - Localpart: "@alice", - DisplayName: "Alice", - }, - { - Localpart: "@bob", - DisplayName: "Bob", - }, - { - Localpart: "@charlie", - DisplayName: "Charlie", - }, - }, - }, - }, - })) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") - charlie := deployment.Client(t, "hs1", "@charlie:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", diff --git a/tests/csapi/room_kick_test.go b/tests/csapi/room_kick_test.go index 6c12e479..03b1e7ef 100644 --- a/tests/csapi/room_kick_test.go +++ b/tests/csapi/room_kick_test.go @@ -4,19 +4,19 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) // sytest: Users cannot kick users from a room they are not in func TestCannotKickNonPresentUser(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", @@ -36,11 +36,11 @@ func TestCannotKickNonPresentUser(t *testing.T) { // sytest: Users cannot kick users who have already left a room func TestCannotKickLeftUser(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", diff --git a/tests/csapi/room_leave_test.go b/tests/csapi/room_leave_test.go index dd9f97a5..00e93395 100644 --- a/tests/csapi/room_leave_test.go +++ b/tests/csapi/room_leave_test.go @@ -16,11 +16,11 @@ import ( ) func TestLeftRoomFixture(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "charlie", Password: "sufficiently_long_password_charlie", diff --git a/tests/csapi/room_members_test.go b/tests/csapi/room_members_test.go index ca74888b..bb269f7c 100644 --- a/tests/csapi/room_members_test.go +++ b/tests/csapi/room_members_test.go @@ -10,6 +10,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -21,11 +22,11 @@ func typeToStateKeyMapper(result gjson.Result) interface{} { // sytest: Can get rooms/{roomId}/members func TestGetRoomMembers(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", @@ -60,11 +61,11 @@ func TestGetRoomMembers(t *testing.T) { // Utilize ?at= to get room members at a point in sync. // sytest: Can get rooms/{roomId}/members at a given point func TestGetRoomMembersAtPoint(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", @@ -120,11 +121,11 @@ func TestGetRoomMembersAtPoint(t *testing.T) { // sytest: Can filter rooms/{roomId}/members func TestGetFilteredRoomMembers(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", diff --git a/tests/csapi/room_messages_test.go b/tests/csapi/room_messages_test.go index e2625dd3..373f3363 100644 --- a/tests/csapi/room_messages_test.go +++ b/tests/csapi/room_messages_test.go @@ -11,6 +11,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" @@ -20,10 +21,10 @@ import ( // sytest: GET /rooms/:room_id/messages returns a message func TestSendAndFetchMessage(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // flakey - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) @@ -63,10 +64,10 @@ func TestSendAndFetchMessage(t *testing.T) { // With a non-existent room_id, GET /rooms/:room_id/messages returns 403 // forbidden ("You aren't a member of the room"). func TestFetchMessagesFromNonExistentRoom(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := "!does-not-exist:hs1" // then request messages from the room @@ -81,10 +82,10 @@ func TestFetchMessagesFromNonExistentRoom(t *testing.T) { // sytest: PUT /rooms/:room_id/send/:event_type/:txn_id sends a message // sytest: PUT /rooms/:room_id/send/:event_type/:txn_id deduplicates the same txn id func TestSendMessageWithTxn(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{}) @@ -108,33 +109,12 @@ func TestSendMessageWithTxn(t *testing.T) { } func TestRoomMessagesLazyLoading(t *testing.T) { - deployment := complement.Deploy(t, b.MustValidate(b.Blueprint{ - Name: "alice_bob_and_charlie", - Homeservers: []b.Homeserver{ - { - Name: "hs1", - Users: []b.User{ - { - Localpart: "@alice", - DisplayName: "Alice", - }, - { - Localpart: "@bob", - DisplayName: "Bob", - }, - { - Localpart: "@charlie", - DisplayName: "Charlie", - }, - }, - }, - }, - })) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") - charlie := deployment.Client(t, "hs1", "@charlie:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) bob.MustJoinRoom(t, roomID, nil) @@ -199,10 +179,10 @@ func TestRoomMessagesLazyLoading(t *testing.T) { // // sytest: GET /rooms/:room_id/messages lazy loads members correctly func TestRoomMessagesLazyLoadingLocalUser(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{}) diff --git a/tests/csapi/room_profile_test.go b/tests/csapi/room_profile_test.go index 91c03ec5..d98c4379 100644 --- a/tests/csapi/room_profile_test.go +++ b/tests/csapi/room_profile_test.go @@ -6,8 +6,8 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" ) func TestAvatarUrlUpdate(t *testing.T) { @@ -20,12 +20,12 @@ func TestDisplayNameUpdate(t *testing.T) { // sytest: $datum updates affect room member events func testProfileFieldUpdate(t *testing.T, field string) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) const bogusData = "LemurLover" - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", diff --git a/tests/csapi/room_relations_test.go b/tests/csapi/room_relations_test.go index 411df83e..9f83d387 100644 --- a/tests/csapi/room_relations_test.go +++ b/tests/csapi/room_relations_test.go @@ -11,16 +11,17 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" ) func TestRelations(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) _, token := alice.MustSync(t, client.SyncReq{}) @@ -112,10 +113,10 @@ func TestRelations(t *testing.T) { } func TestRelationsPagination(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) _, token := alice.MustSync(t, client.SyncReq{}) @@ -211,10 +212,10 @@ func TestRelationsPagination(t *testing.T) { func TestRelationsPaginationSync(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/2944 - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) _, token := alice.MustSync(t, client.SyncReq{}) diff --git a/tests/csapi/room_threads_test.go b/tests/csapi/room_threads_test.go index b431ad46..81124e62 100644 --- a/tests/csapi/room_threads_test.go +++ b/tests/csapi/room_threads_test.go @@ -7,8 +7,8 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" @@ -33,10 +33,10 @@ func checkResults(t *testing.T, body []byte, expected []string) { // Test the /threads endpoint. func TestThreadsEndpoint(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // not supported - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) _, token := alice.MustSync(t, client.SyncReq{}) diff --git a/tests/csapi/room_typing_test.go b/tests/csapi/room_typing_test.go index 5759a967..84253cca 100644 --- a/tests/csapi/room_typing_test.go +++ b/tests/csapi/room_typing_test.go @@ -4,18 +4,17 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" ) // sytest: PUT /rooms/:room_id/typing/:user_id sets typing notification func TestTyping(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) @@ -38,11 +37,11 @@ func TestTyping(t *testing.T) { // sytest: Typing notifications don't leak func TestLeakyTyping(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "charlie", Password: "charliepassword", diff --git a/tests/csapi/rooms_invite_test.go b/tests/csapi/rooms_invite_test.go index 8e67d581..6c0f1db0 100644 --- a/tests/csapi/rooms_invite_test.go +++ b/tests/csapi/rooms_invite_test.go @@ -5,19 +5,19 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/tidwall/gjson" ) func TestRoomsInvite(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: Can invite users to invite-only rooms diff --git a/tests/csapi/rooms_members_local_test.go b/tests/csapi/rooms_members_local_test.go index 68c1af39..fe6ca4e3 100644 --- a/tests/csapi/rooms_members_local_test.go +++ b/tests/csapi/rooms_members_local_test.go @@ -4,17 +4,16 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/runtime" ) func TestMembersLocal(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Here we don't use the BlueprintOneToOneRoom because else Bob would be able to see Alice's presence changes through // that pre-existing one-on-one DM room. So we exclude that here. bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{ diff --git a/tests/csapi/rooms_state_test.go b/tests/csapi/rooms_state_test.go index f287e2ff..05a482e9 100644 --- a/tests/csapi/rooms_state_test.go +++ b/tests/csapi/rooms_state_test.go @@ -17,11 +17,10 @@ import ( ) func TestRoomCreationReportsEventsToMyself(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - userID := "@alice:hs1" - alice := deployment.Client(t, "hs1", userID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "bob", Password: "bobpassword", @@ -37,8 +36,8 @@ func TestRoomCreationReportsEventsToMyself(t *testing.T) { if ev.Get("type").Str != "m.room.create" { return false } - must.Equal(t, ev.Get("sender").Str, userID, "wrong sender") - must.Equal(t, ev.Get("content").Get("creator").Str, userID, "wrong content.creator") + must.Equal(t, ev.Get("sender").Str, alice.UserID, "wrong sender") + must.Equal(t, ev.Get("content").Get("creator").Str, alice.UserID, "wrong content.creator") return true })) }) @@ -51,8 +50,8 @@ func TestRoomCreationReportsEventsToMyself(t *testing.T) { if ev.Get("type").Str != "m.room.member" { return false } - must.Equal(t, ev.Get("sender").Str, userID, "wrong sender") - must.Equal(t, ev.Get("state_key").Str, userID, "wrong state_key") + must.Equal(t, ev.Get("sender").Str, alice.UserID, "wrong sender") + must.Equal(t, ev.Get("state_key").Str, alice.UserID, "wrong state_key") must.Equal(t, ev.Get("content").Get("membership").Str, "join", "wrong content.membership") return true })) @@ -79,7 +78,7 @@ func TestRoomCreationReportsEventsToMyself(t *testing.T) { if !ev.Get("state_key").Exists() { return false } - must.Equal(t, ev.Get("sender").Str, userID, "wrong sender") + must.Equal(t, ev.Get("sender").Str, alice.UserID, "wrong sender") must.Equal(t, ev.Get("content").Get("topic").Str, roomTopic, "wrong content.topic") return true })) diff --git a/tests/csapi/sync_archive_test.go b/tests/csapi/sync_archive_test.go index 37151cd0..77b14232 100644 --- a/tests/csapi/sync_archive_test.go +++ b/tests/csapi/sync_archive_test.go @@ -8,6 +8,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/runtime" ) @@ -15,10 +16,10 @@ import ( func TestSyncLeaveSection(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1323 - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) includeLeaveFilter := createFilter(t, alice, map[string]interface{}{ "room": map[string]interface{}{ @@ -76,10 +77,10 @@ func TestSyncLeaveSection(t *testing.T) { func TestGappedSyncLeaveSection(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1323 - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) gappyFilter := createFilter(t, alice, map[string]interface{}{ "room": map[string]interface{}{ @@ -117,11 +118,11 @@ func TestGappedSyncLeaveSection(t *testing.T) { func TestArchivedRoomsHistory(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1323 - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) const madeUpTestStateType = "a.madeup.test.state" @@ -234,11 +235,11 @@ func TestArchivedRoomsHistory(t *testing.T) { func TestOlderLeftRoomsNotInLeaveSection(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1323 - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) aliceFilter := createFilter(t, alice, map[string]interface{}{ "room": map[string]interface{}{ @@ -316,11 +317,11 @@ func TestLeaveEventVisibility(t *testing.T) { // this user is only meant to keep the room alive, // as a room with no users may be purged by the server, // creating side effects that this test is not looking for. - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) aliceFilter := createFilter(t, alice, map[string]interface{}{ "room": map[string]interface{}{ @@ -399,11 +400,11 @@ func TestLeaveEventVisibility(t *testing.T) { func TestLeaveEventInviteRejection(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1323 - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) aliceFilter := createFilter(t, alice, map[string]interface{}{ "room": map[string]interface{}{ diff --git a/tests/csapi/sync_filter_test.go b/tests/csapi/sync_filter_test.go index cdc562c9..23e27543 100644 --- a/tests/csapi/sync_filter_test.go +++ b/tests/csapi/sync_filter_test.go @@ -7,16 +7,16 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestSyncFilter(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - authedClient := deployment.Client(t, "hs1", "@alice:hs1") + authedClient := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // sytest: Can create filter t.Run("Can create filter", func(t *testing.T) { createFilter(t, authedClient, map[string]interface{}{ @@ -36,7 +36,7 @@ func TestSyncFilter(t *testing.T) { }, }, }) - res := authedClient.MustDo(t, "GET", []string{"_matrix", "client", "v3", "user", "@alice:hs1", "filter", filterID}) + res := authedClient.MustDo(t, "GET", []string{"_matrix", "client", "v3", "user", authedClient.UserID, "filter", filterID}) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ match.JSONKeyPresent("room"), diff --git a/tests/csapi/sync_test.go b/tests/csapi/sync_test.go index dd2f9992..5b0ffb18 100644 --- a/tests/csapi/sync_test.go +++ b/tests/csapi/sync_test.go @@ -18,11 +18,11 @@ import ( // Observes "first bug" from https://github.com/matrix-org/dendrite/pull/1394#issuecomment-687056673 func TestCumulativeJoinLeaveJoinSync(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := bob.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", @@ -56,11 +56,11 @@ func TestCumulativeJoinLeaveJoinSync(t *testing.T) { // Observes "second bug" from https://github.com/matrix-org/dendrite/pull/1394#issuecomment-687056673 func TestTentativeEventualJoiningAfterRejecting(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", @@ -106,10 +106,10 @@ func TestTentativeEventualJoiningAfterRejecting(t *testing.T) { func TestSync(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/1324 // sytest: Can sync - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) filterID := createFilter(t, alice, map[string]interface{}{ "room": map[string]interface{}{ @@ -376,11 +376,11 @@ func TestSync(t *testing.T) { // Test presence from people in 2 different rooms in incremental sync func TestPresenceSyncDifferentRooms(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "charlie", @@ -406,7 +406,7 @@ func TestPresenceSyncDifferentRooms(t *testing.T) { reqBody := client.WithJSONBody(t, map[string]interface{}{ "presence": "online", }) - bob.Do(t, "PUT", []string{"_matrix", "client", "v3", "presence", "@bob:hs1", "status"}, reqBody) + bob.Do(t, "PUT", []string{"_matrix", "client", "v3", "presence", bob.UserID, "status"}, reqBody) charlie.Do(t, "PUT", []string{"_matrix", "client", "v3", "presence", charlie.UserID, "status"}, reqBody) // Alice should see that Bob and Charlie are online. She may see this happen @@ -439,10 +439,10 @@ func TestPresenceSyncDifferentRooms(t *testing.T) { func TestRoomSummary(t *testing.T) { runtime.SkipIf(t, runtime.Synapse) // Currently more of a Dendrite test, so skip on Synapse - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) _, aliceSince := alice.MustSync(t, client.SyncReq{TimeoutMillis: "0"}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ diff --git a/tests/csapi/thread_notifications_test.go b/tests/csapi/thread_notifications_test.go index 0f436773..de440d49 100644 --- a/tests/csapi/thread_notifications_test.go +++ b/tests/csapi/thread_notifications_test.go @@ -9,6 +9,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/runtime" ) @@ -72,12 +73,12 @@ func syncHasThreadedReadReceipt(roomID, userID, eventID, threadID string) client // Notification counts and receipts are handled by bob. func TestThreadedReceipts(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // not supported - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Create a room with alice and bob. - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) bob.MustJoinRoom(t, roomID, nil) diff --git a/tests/csapi/to_device_test.go b/tests/csapi/to_device_test.go index 4ca2df54..084b85da 100644 --- a/tests/csapi/to_device_test.go +++ b/tests/csapi/to_device_test.go @@ -7,7 +7,6 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" ) @@ -16,11 +15,11 @@ import ( // sytest: Can recv a device message using /sync // sytest: Can send a to-device message to two users which both receive it using /sync func TestToDeviceMessages(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) charlie := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "charlie", Password: "charliepassword", diff --git a/tests/csapi/txnid_test.go b/tests/csapi/txnid_test.go index 9af3423f..04fb8d1e 100644 --- a/tests/csapi/txnid_test.go +++ b/tests/csapi/txnid_test.go @@ -20,7 +20,7 @@ func TestTxnInEvent(t *testing.T) { // See https://github.com/matrix-org/dendrite/issues/3000 runtime.SkipIf(t, runtime.Dendrite) - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) c := deployment.Register(t, "hs1", helpers.RegistrationOpts{ @@ -74,7 +74,7 @@ func mustHaveTransactionIDForEvent(t *testing.T, roomID, eventID, expectedTxnId func TestTxnScopeOnLocalEcho(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{ @@ -83,7 +83,7 @@ func TestTxnScopeOnLocalEcho(t *testing.T) { }) // Create a first client, which allocates a device ID. - c1 := deployment.Client(t, "hs1", "") + c1 := deployment.UnauthenticatedClient(t, "hs1") c1.UserID, c1.AccessToken, c1.DeviceID = c1.LoginUser(t, alice.UserID, "password") // Create a room where we can send events. @@ -103,7 +103,7 @@ func TestTxnScopeOnLocalEcho(t *testing.T) { c1.MustSyncUntil(t, client.SyncReq{}, mustHaveTransactionIDForEvent(t, roomID, eventID, txnId)) // Create a second client, inheriting the first device ID. - c2 := deployment.Client(t, "hs1", "") + c2 := deployment.UnauthenticatedClient(t, "hs1") c2.UserID, c2.AccessToken, c2.DeviceID = c2.LoginUser(t, alice.UserID, "password", client.WithDeviceID(c1.DeviceID)) must.Equal(t, c1.DeviceID, c2.DeviceID, "Device ID should be the same") @@ -116,7 +116,7 @@ func TestTxnScopeOnLocalEcho(t *testing.T) { func TestTxnIdempotencyScopedToDevice(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{ @@ -125,7 +125,7 @@ func TestTxnIdempotencyScopedToDevice(t *testing.T) { }) // Create a first client, which allocates a device ID. - c1 := deployment.Client(t, "hs1", "") + c1 := deployment.UnauthenticatedClient(t, "hs1") c1.UserID, c1.AccessToken, c1.DeviceID = c1.LoginUser(t, alice.UserID, "password") // Create a room where we can send events. @@ -143,7 +143,7 @@ func TestTxnIdempotencyScopedToDevice(t *testing.T) { eventID1 := c1.Unsafe_SendEventUnsyncedWithTxnID(t, roomID, event, txnId) // Create a second client, inheriting the first device ID. - c2 := deployment.Client(t, "hs1", "") + c2 := deployment.UnauthenticatedClient(t, "hs1") c2.UserID, c2.AccessToken, c2.DeviceID = c2.LoginUser(t, alice.UserID, "password", client.WithDeviceID(c1.DeviceID)) must.Equal(t, c1.DeviceID, c2.DeviceID, "Device ID should be the same") @@ -159,7 +159,7 @@ func TestTxnIdempotency(t *testing.T) { // Conduit appears to be tracking transaction IDs individually rather than combined with the request URI/room ID runtime.SkipIf(t, runtime.Conduit) - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{ @@ -168,7 +168,7 @@ func TestTxnIdempotency(t *testing.T) { }) // Create a first client, which allocates a device ID. - c1 := deployment.Client(t, "hs1", "") + c1 := deployment.UnauthenticatedClient(t, "hs1") c1.UserID, c1.AccessToken, c1.DeviceID = c1.LoginUser(t, alice.UserID, "password") // Create a room where we can send events. @@ -217,7 +217,7 @@ func TestTxnIdWithRefreshToken(t *testing.T) { // Dendrite and Conduit don't support refresh tokens yet. runtime.SkipIf(t, runtime.Dendrite, runtime.Conduit) - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{ @@ -227,7 +227,7 @@ func TestTxnIdWithRefreshToken(t *testing.T) { localpart, _, err := gomatrixserverlib.SplitID('@', alice.UserID) must.NotError(t, "failed to get localpart from user ID", err) - c := deployment.Client(t, "hs1", "") + c := deployment.UnauthenticatedClient(t, "hs1") var refreshToken string c.UserID, c.AccessToken, refreshToken, c.DeviceID, _ = c.LoginUserWithRefreshToken(t, localpart, "password") diff --git a/tests/csapi/upload_keys_test.go b/tests/csapi/upload_keys_test.go index c71400cd..d6b5355f 100644 --- a/tests/csapi/upload_keys_test.go +++ b/tests/csapi/upload_keys_test.go @@ -9,19 +9,19 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" ) func TestUploadKey(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) deviceKeys, oneTimeKeys := alice.MustGenerateOneTimeKeys(t, 1) diff --git a/tests/csapi/url_preview_test.go b/tests/csapi/url_preview_test.go index 3a29b60c..fc1ef2c7 100644 --- a/tests/csapi/url_preview_test.go +++ b/tests/csapi/url_preview_test.go @@ -11,8 +11,8 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/data" "github.com/matrix-org/complement/internal/web" "github.com/matrix-org/complement/match" @@ -42,7 +42,7 @@ var oGraphHtml = fmt.Sprintf(` func TestUrlPreview(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/621 - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) webServer := web.NewServer(t, deployment.GetConfig(), func(router *mux.Router) { @@ -63,7 +63,7 @@ func TestUrlPreview(t *testing.T) { }) defer webServer.Close() - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) res := alice.MustDo(t, "GET", []string{"_matrix", "media", "v3", "preview_url"}, client.WithQueries(url.Values{ diff --git a/tests/csapi/user_directory_display_names_test.go b/tests/csapi/user_directory_display_names_test.go index 8a7fe012..ce358d9d 100644 --- a/tests/csapi/user_directory_display_names_test.go +++ b/tests/csapi/user_directory_display_names_test.go @@ -5,24 +5,25 @@ package csapi_tests import ( + "strings" "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) -const aliceUserID = "@alice:hs1" const alicePublicName = "Alice Cooper" const alicePrivateName = "Freddy" -var justAliceByPublicName = []match.JSON{ - match.JSONKeyArrayOfSize("results", 1), - match.JSONKeyEqual("results.0.display_name", alicePublicName), - match.JSONKeyEqual("results.0.user_id", aliceUserID), +var justAliceByPublicName = func(alice *client.CSAPI) []match.JSON { + return []match.JSON{ + match.JSONKeyArrayOfSize("results", 1), + match.JSONKeyEqual("results.0.display_name", alicePublicName), + match.JSONKeyEqual("results.0.user_id", alice.UserID), + } } var noResults = []match.JSON{ @@ -40,12 +41,14 @@ func setupUsers(t *testing.T) (*client.CSAPI, *client.CSAPI, *client.CSAPI, func // - Eve knows about Alice, // - Alice reveals a private name to another friend Bob // - Eve shouldn't be able to see that private name via the directory. - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) cleanup := func(t *testing.T) { deployment.Destroy(t) } - alice := deployment.Client(t, "hs1", aliceUserID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{ + LocalpartSuffix: "alice", + }) bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{ LocalpartSuffix: "bob", }) @@ -70,7 +73,7 @@ func setupUsers(t *testing.T) (*client.CSAPI, *client.CSAPI, *client.CSAPI, func return alice, bob, eve, cleanup } -func checkExpectations(t *testing.T, bob, eve *client.CSAPI) { +func checkExpectations(t *testing.T, alice, bob, eve *client.CSAPI) { t.Run("Eve can find Alice by profile display name", func(t *testing.T) { res := eve.MustDo( t, @@ -80,19 +83,28 @@ func checkExpectations(t *testing.T, bob, eve *client.CSAPI) { "search_term": alicePublicName, }), ) - must.MatchResponse(t, res, match.HTTPResponse{JSON: justAliceByPublicName}) + must.MatchResponse(t, res, match.HTTPResponse{JSON: justAliceByPublicName(alice)}) }) + // Previously, this test searched for the literal mxid in the search_term. + // This was finnicky, because certain characters in the mxid would cause this test to fail, specifically '-'. + // Unfortunately, '-' is used by Complement when generating user ID localparts. + // See https://github.com/matrix-org/synapse/issues/13807 and specifically + // https://github.com/matrix-org/synapse/blob/888a29f4127723a8d048ce47cff37ee8a7a6f1b9/synapse/storage/databases/main/user_directory.py#L910-L924 + // The net result is that we cannot search for a user by the complete user ID, nor can we search for the + // localpart suffix, as the code only does prefix matching. + // The thing we /can/ search on is the mxid up to the '-', so let's do that. + searchTerms := strings.Split(alice.UserID, "-") t.Run("Eve can find Alice by mxid", func(t *testing.T) { res := eve.MustDo( t, "POST", []string{"_matrix", "client", "v3", "user_directory", "search"}, client.WithJSONBody(t, map[string]interface{}{ - "search_term": aliceUserID, + "search_term": searchTerms[0], }), ) - must.MatchResponse(t, res, match.HTTPResponse{JSON: justAliceByPublicName}) + must.MatchResponse(t, res, match.HTTPResponse{JSON: justAliceByPublicName(alice)}) }) t.Run("Eve cannot find Alice by room-specific name that Eve is not privy to", func(t *testing.T) { @@ -117,7 +129,7 @@ func checkExpectations(t *testing.T, bob, eve *client.CSAPI) { }), ) must.MatchResponse(t, res, match.HTTPResponse{ - JSON: justAliceByPublicName, + JSON: justAliceByPublicName(alice), }) }) @@ -127,11 +139,11 @@ func checkExpectations(t *testing.T, bob, eve *client.CSAPI) { "POST", []string{"_matrix", "client", "v3", "user_directory", "search"}, client.WithJSONBody(t, map[string]interface{}{ - "search_term": aliceUserID, + "search_term": searchTerms[0], }), ) must.MatchResponse(t, res, match.HTTPResponse{ - JSON: justAliceByPublicName, + JSON: justAliceByPublicName(alice), }) }) } @@ -161,7 +173,7 @@ func TestRoomSpecificUsernameChange(t *testing.T) { }), ) - checkExpectations(t, bob, eve) + checkExpectations(t, alice, bob, eve) } func TestRoomSpecificUsernameAtJoin(t *testing.T) { @@ -190,5 +202,5 @@ func TestRoomSpecificUsernameAtJoin(t *testing.T) { }), ) - checkExpectations(t, bob, eve) + checkExpectations(t, alice, bob, eve) } diff --git a/tests/csapi/user_query_keys_test.go b/tests/csapi/user_query_keys_test.go index 2d6227c6..a854ad39 100644 --- a/tests/csapi/user_query_keys_test.go +++ b/tests/csapi/user_query_keys_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -16,15 +16,15 @@ import ( // like an array in Python and hence go un-noticed. In Go however it will result in a 400. The correct behaviour is // to return a 400. Element iOS uses this erroneous format. func TestKeysQueryWithDeviceIDAsObjectFails(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - userID := "@alice:hs1" - alice := deployment.Client(t, "hs1", userID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) res := alice.Do(t, "POST", []string{"_matrix", "client", "v3", "keys", "query"}, client.WithJSONBody(t, map[string]interface{}{ "device_keys": map[string]interface{}{ - "@bob:hs1": map[string]bool{ + bob.UserID: map[string]bool{ "device_id1": true, "device_id2": true, }, diff --git a/tests/direct_messaging_test.go b/tests/direct_messaging_test.go index b9882304..a8f35f2a 100644 --- a/tests/direct_messaging_test.go +++ b/tests/direct_messaging_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" @@ -22,15 +22,15 @@ import ( // Test that a client can write `m.direct` account data and get told about updates to that event. // Requires a functioning account data implementation. func TestWriteMDirectAccountData(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer func() { // additional logging to debug https://github.com/matrix-org/synapse/issues/13334 t.Logf("%s: TestWriteMDirectAccountData complete: destroying HS deployment", time.Now()) deployment.Destroy(t) }() - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "invite": []string{bob.UserID}, "is_direct": true, @@ -70,11 +70,11 @@ func TestWriteMDirectAccountData(t *testing.T) { // Test that the `is_direct` flag on m.room.member invites propagate to the target user. Both users // are on the same homeserver. func TestIsDirectFlagLocal(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "invite": []string{bob.UserID}, "is_direct": true, @@ -103,7 +103,7 @@ func TestIsDirectFlagLocal(t *testing.T) { // Test that the `is_direct` flag on m.room.member invites propagate to the target user. Users // are on different homeservers. func TestIsDirectFlagFederation(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, @@ -114,7 +114,7 @@ func TestIsDirectFlagFederation(t *testing.T) { srv.UnexpectedRequestsAreErrors = false // we expect to be pushed events cancel := srv.Listen() defer cancel() - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomVer := alice.GetDefaultRoomVersion(t) bob := srv.UserID("bob") diff --git a/tests/federation_acl_test.go b/tests/federation_acl_test.go index 413660a3..72b6094b 100644 --- a/tests/federation_acl_test.go +++ b/tests/federation_acl_test.go @@ -6,6 +6,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" @@ -16,43 +17,12 @@ import ( func TestACLs(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // needs https://github.com/matrix-org/dendrite/pull/3008 // 1. Prepare 3 or more servers. 1st will be room host, 2nd will be blocked with m.room.server_acl and 3rd server will be affected by this issue. 1st and 2nd servers don't have to be powered by dendrite. - deployment := complement.Deploy(t, b.Blueprint{ - Name: "federation_three_homeservers", - Homeservers: []b.Homeserver{ - { - Name: "hs1", - Users: []b.User{ - { - Localpart: "alice", - DisplayName: "Alice", - }, - }, - }, - { - Name: "hs2", - Users: []b.User{ - { - Localpart: "bob", - DisplayName: "Bob", - }, - }, - }, - { - Name: "hs3", - Users: []b.User{ - { - Localpart: "charlie", - DisplayName: "Charlie", - }, - }, - }, - }, - }) + deployment := complement.Deploy(t, 3) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") - charlie := deployment.Client(t, "hs3", "@charlie:hs3") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) + charlie := deployment.Register(t, "hs3", helpers.RegistrationOpts{}) // 2. Create room on 1st server roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) diff --git a/tests/federation_event_auth_test.go b/tests/federation_event_auth_test.go index 013a259e..90f36e5a 100644 --- a/tests/federation_event_auth_test.go +++ b/tests/federation_event_auth_test.go @@ -29,10 +29,10 @@ import ( // - /event_auth for the latest join event returns the complete auth chain for Charlie (all the // joins and leaves are included), without any extraneous events. func TestEventAuth(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // create a remote homeserver which will make the /event_auth request var joinRuleEvent gomatrixserverlib.PDU diff --git a/tests/federation_keys_test.go b/tests/federation_keys_test.go index 220ae0f3..7907b191 100644 --- a/tests/federation_keys_test.go +++ b/tests/federation_keys_test.go @@ -13,7 +13,6 @@ import ( "github.com/tidwall/sjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -27,7 +26,7 @@ import ( // https://matrix.org/docs/spec/server_server/latest#get-matrix-key-v2-server-keyid // sytest: Federation key API allows unsigned requests for keys func TestInboundFederationKeys(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) fedClient := &http.Client{ diff --git a/tests/federation_presence_test.go b/tests/federation_presence_test.go index 8d1fd3ee..db8d2e2b 100644 --- a/tests/federation_presence_test.go +++ b/tests/federation_presence_test.go @@ -8,21 +8,26 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" ) func TestRemotePresence(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{LocalpartSuffix: "alice"}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{LocalpartSuffix: "bob"}) + + // for presence to be sent over federation alice and bob must share a room + roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) + bob.MustJoinRoom(t, roomID, []string{"hs1"}) // sytest: Presence changes are also reported to remote room members t.Run("Presence changes are also reported to remote room members", func(t *testing.T) { _, bobSinceToken := bob.MustSync(t, client.SyncReq{TimeoutMillis: "0"}) statusMsg := "Update for room members" - alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}, + alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}, client.WithJSONBody(t, map[string]interface{}{ "status_msg": statusMsg, "presence": "online", @@ -39,7 +44,7 @@ func TestRemotePresence(t *testing.T) { t.Run("Presence changes to UNAVAILABLE are reported to remote room members", func(t *testing.T) { _, bobSinceToken := bob.MustSync(t, client.SyncReq{TimeoutMillis: "0"}) - alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", "@alice:hs1", "status"}, + alice.MustDo(t, "PUT", []string{"_matrix", "client", "v3", "presence", alice.UserID, "status"}, client.WithJSONBody(t, map[string]interface{}{ "presence": "unavailable", }), diff --git a/tests/federation_query_profile_test.go b/tests/federation_query_profile_test.go index 0174619e..d0babd5a 100644 --- a/tests/federation_query_profile_test.go +++ b/tests/federation_query_profile_test.go @@ -10,8 +10,8 @@ import ( "github.com/matrix-org/gomatrixserverlib/fclient" "github.com/matrix-org/gomatrixserverlib/spec" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" @@ -23,7 +23,7 @@ import ( // Test that the server can make outbound federation profile requests // https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-query-profile func TestOutboundFederationProfile(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, @@ -60,7 +60,7 @@ func TestOutboundFederationProfile(t *testing.T) { })).Methods("GET") // query the display name which should do an outbound federation hit - unauthedClient := deployment.Client(t, "hs1", "") + unauthedClient := deployment.UnauthenticatedClient(t, "hs1") res := unauthedClient.MustDo(t, "GET", []string{"_matrix", "client", "v3", "profile", remoteUserID, "displayname"}) must.MatchResponse(t, res, match.HTTPResponse{ JSON: []match.JSON{ @@ -71,10 +71,10 @@ func TestOutboundFederationProfile(t *testing.T) { } func TestInboundFederationProfile(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), @@ -121,7 +121,7 @@ func TestInboundFederationProfile(t *testing.T) { origin, "hs1", "/_matrix/federation/v1/query/profile"+ - "?user_id=@alice:hs1"+ + "?user_id="+alice.UserID+ "&field=displayname", ) diff --git a/tests/federation_redaction_test.go b/tests/federation_redaction_test.go index ef7c5fbe..5a2dd9eb 100644 --- a/tests/federation_redaction_test.go +++ b/tests/federation_redaction_test.go @@ -5,7 +5,6 @@ import ( "time" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" "github.com/matrix-org/complement/must" @@ -17,10 +16,10 @@ import ( func TestFederationRedactSendsWithoutEvent(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) waiter := helpers.NewWaiter() wantEventType := "m.room.redaction" diff --git a/tests/federation_room_alias_test.go b/tests/federation_room_alias_test.go index 6d058956..a2a90c77 100644 --- a/tests/federation_room_alias_test.go +++ b/tests/federation_room_alias_test.go @@ -4,19 +4,19 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) // sytest: Remote room alias queries can handle Unicode func TestRemoteAliasRequestsUnderstandUnicode(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) const unicodeAlias = "#老虎£я🤨👉ඞ:hs1" diff --git a/tests/federation_room_ban_test.go b/tests/federation_room_ban_test.go index f526646b..4e3a9f29 100644 --- a/tests/federation_room_ban_test.go +++ b/tests/federation_room_ban_test.go @@ -4,19 +4,19 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" ) // Regression test for https://github.com/matrix-org/synapse/issues/1563 // Create a federation room. Bob bans Alice. Bob unbans Alice. Bob invites Alice (unbanning her). Ensure the invite is // received and can be accepted. func TestUnbanViaInvite(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) roomID := bob.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", diff --git a/tests/federation_room_event_auth_test.go b/tests/federation_room_event_auth_test.go index bbb31dbf..3d78aadc 100644 --- a/tests/federation_room_event_auth_test.go +++ b/tests/federation_room_event_auth_test.go @@ -20,6 +20,7 @@ import ( "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" "github.com/matrix-org/complement/must" ) @@ -73,7 +74,7 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) { * /rooms/{roomID}/event. If it is rejected, we should get a 404. */ - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), @@ -108,7 +109,7 @@ func TestInboundFederationRejectsEventsWithRejectedAuthEvents(t *testing.T) { }).Methods("GET") // have Alice create a room, and then join it - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) testRoomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", }) diff --git a/tests/federation_room_get_missing_events_test.go b/tests/federation_room_get_missing_events_test.go index e04a4f0b..ff83067a 100644 --- a/tests/federation_room_get_missing_events_test.go +++ b/tests/federation_room_get_missing_events_test.go @@ -42,7 +42,7 @@ func TestGetMissingEventsGapFilling(t *testing.T) { // 4) Respond to /get_missing_events with the missing events if the request is well-formed. // 5) Ensure the HS doesn't do /state_ids or /state // 6) Ensure Alice sees all injected events in the correct order. - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, @@ -60,7 +60,7 @@ func TestGetMissingEventsGapFilling(t *testing.T) { cancel := srv.Listen() defer cancel() - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) bob := srv.UserID("bob") // 1) Create a room between the HS and Complement. @@ -166,10 +166,10 @@ func TestGetMissingEventsGapFilling(t *testing.T) { // // sytest: Outbound federation will ignore a missing event with bad JSON for room version 6 func TestOutboundFederationIgnoresMissingEventWithBadJSONForRoomVersion6(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), @@ -329,10 +329,10 @@ func TestOutboundFederationIgnoresMissingEventWithBadJSONForRoomVersion6(t *test } func TestInboundCanReturnMissingEvents(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), diff --git a/tests/federation_room_invite_test.go b/tests/federation_room_invite_test.go index 7b48a10b..951d426c 100644 --- a/tests/federation_room_invite_test.go +++ b/tests/federation_room_invite_test.go @@ -7,7 +7,6 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/gomatrixserverlib" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" ) @@ -18,10 +17,10 @@ import ( // alice sends an invite to charlie@hs2, which he rejects. // We check that delia sees the rejection. func TestFederationRejectInvite(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationTwoLocalOneRemote) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - charlie := deployment.Client(t, "hs2", "@charlie:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + charlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // we'll awaken this Waiter when we receive a membership event for Charlie var waiter *helpers.Waiter diff --git a/tests/federation_room_join_test.go b/tests/federation_room_join_test.go index aeff8178..092b4434 100644 --- a/tests/federation_room_join_test.go +++ b/tests/federation_room_join_test.go @@ -22,6 +22,7 @@ import ( "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" @@ -38,10 +39,10 @@ import ( // m.room.create event would pick that up. We also can't tear down the Complement // server because otherwise signing key lookups will fail. func TestJoinViaRoomIDAndServerName(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) acceptMakeSendJoinRequests := true @@ -78,7 +79,7 @@ func TestJoinViaRoomIDAndServerName(t *testing.T) { acceptMakeSendJoinRequests = false // join the room using ?server_name on HS2 - bob := deployment.Client(t, "hs2", "@bob:hs2") + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) roomID := bob.MustJoinRoom(t, serverRoom.RoomID, []string{"hs1"}) must.Equal(t, roomID, serverRoom.RoomID, "joined room mismatch") } @@ -86,11 +87,11 @@ 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 := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) srv := federation.NewServer(t, deployment) cancel := srv.Listen() @@ -126,10 +127,10 @@ func TestJoinFederatedRoomFailOver(t *testing.T) { // the properties listed above, then asking HS1 to join them and make sure that // they 200 OK. func TestJoinFederatedRoomWithUnverifiableEvents(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), @@ -292,7 +293,7 @@ func TestJoinFederatedRoomWithUnverifiableEvents(t *testing.T) { // This test checks that users cannot circumvent the auth checks via send_join. func TestBannedUserCannotSendJoin(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, @@ -308,7 +309,7 @@ func TestBannedUserCannotSendJoin(t *testing.T) { charlie := srv.UserID("charlie") // alice creates a room, and bans charlie from it. - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", }) @@ -391,7 +392,7 @@ func testValidationForSendMembershipEndpoint(t *testing.T, baseApiPath, expected } } - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, @@ -402,7 +403,7 @@ func testValidationForSendMembershipEndpoint(t *testing.T, baseApiPath, expected defer cancel() // alice creates a room, and charlie joins it - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomId := alice.MustCreateRoom(t, createRoomOpts) charlie := srv.UserID("charlie") room := srv.MustJoinRoom(t, deployment, "hs1", roomId, charlie) @@ -494,7 +495,7 @@ func testValidationForSendMembershipEndpoint(t *testing.T, baseApiPath, expected // Will be skipped if the server returns a full-state response. func TestSendJoinPartialStateResponse(t *testing.T) { // start with a homeserver with two users - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) srv := federation.NewServer(t, deployment, @@ -510,8 +511,8 @@ func TestSendJoinPartialStateResponse(t *testing.T) { // annoyingly we can't get to the room that alice and bob already share (see https://github.com/matrix-org/complement/issues/254) // so we have to create a new one. // alice creates a room, which bob joins - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) bob.MustJoinRoom(t, roomID, nil) @@ -582,16 +583,15 @@ func TestJoinFederatedRoomFromApplicationServiceBridgeUser(t *testing.T) { // Dendrite doesn't read AS registration files from Complement yet runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/complement/issues/514 - deployment := complement.Deploy(t, b.BlueprintHSWithApplicationService) + deployment := complement.OldDeploy(t, b.BlueprintHSWithApplicationService) defer deployment.Destroy(t) // Create the application service bridge user to try to join the room from asUserID := "@the-bridge-user:hs1" - as := deployment.Client(t, "hs1", asUserID) + as := deployment.AppServiceUser(t, "hs1", asUserID) // Create the federated remote user which will create the room - remoteUserID := "@charlie:hs2" - remoteCharlie := deployment.Client(t, "hs2", remoteUserID) + remoteCharlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) t.Run("join remote federated room as application service user", func(t *testing.T) { //t.Parallel() diff --git a/tests/federation_room_send_test.go b/tests/federation_room_send_test.go index d89ebc25..c0b11226 100644 --- a/tests/federation_room_send_test.go +++ b/tests/federation_room_send_test.go @@ -20,10 +20,10 @@ import ( // Tests that the server is capable of making outbound /send requests func TestOutboundFederationSend(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) waiter := helpers.NewWaiter() wantEventType := "m.room.message" diff --git a/tests/federation_room_typing_test.go b/tests/federation_room_typing_test.go index 0b1e7a7b..26bcafb7 100644 --- a/tests/federation_room_typing_test.go +++ b/tests/federation_room_typing_test.go @@ -4,18 +4,18 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" ) // sytest: Typing notifications also sent to remote room members func TestRemoteTyping(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationTwoLocalOneRemote) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") - charlie := deployment.Client(t, "hs2", "@charlie:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + charlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) bob.MustJoinRoom(t, roomID, nil) diff --git a/tests/federation_rooms_invite_test.go b/tests/federation_rooms_invite_test.go index 4d867c7f..fc3ad771 100644 --- a/tests/federation_rooms_invite_test.go +++ b/tests/federation_rooms_invite_test.go @@ -7,18 +7,18 @@ import ( "github.com/matrix-org/gomatrixserverlib/spec" "github.com/tidwall/gjson" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestFederationRoomsInvite(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { // sytest: Invited user can reject invite over federation diff --git a/tests/federation_unreject_rejected_test.go b/tests/federation_unreject_rejected_test.go index 5c43ce56..dc77e5c1 100644 --- a/tests/federation_unreject_rejected_test.go +++ b/tests/federation_unreject_rejected_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" ) @@ -18,9 +18,9 @@ import ( // event B is unrejected on the second pass and will appear in // the /sync response AFTER event A. func TestUnrejectRejectedEvents(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), diff --git a/tests/federation_upload_keys_test.go b/tests/federation_upload_keys_test.go index 128a51cb..b439b55d 100644 --- a/tests/federation_upload_keys_test.go +++ b/tests/federation_upload_keys_test.go @@ -9,21 +9,27 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) func TestFederationKeyUploadQuery(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + 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"}) + bob.MustJoinRoom(t, roomID, []string{"hs1"}) // Do an initial sync so that we can see the changes come down sync. - _, nextBatchBeforeKeyUpload := bob.MustSync(t, client.SyncReq{}) + // We wait until we see the newly joined room as that can cause alice to appear in device_lists + // which we want to ignore for now. + nextBatchBeforeKeyUpload := bob.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(bob.UserID, roomID)) deviceKeys, oneTimeKeys := alice.MustGenerateOneTimeKeys(t, 1) // Upload keys diff --git a/tests/knock_restricted_test.go b/tests/knock_restricted_test.go index 9e6d9fb7..7765f974 100644 --- a/tests/knock_restricted_test.go +++ b/tests/knock_restricted_test.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/helpers" ) var ( @@ -42,14 +42,14 @@ func TestCannotSendKnockViaSendKnockInMSC3787Room(t *testing.T) { // See TestRestrictedRoomsLocalJoin func TestRestrictedRoomsLocalJoinInMSC3787Room(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Setup the user, allowed room, and restricted room. alice, allowed_room, room := setupRestrictedRoom(t, deployment, roomVersion, joinRule) // Create a second user on the same homeserver. - bob := deployment.Client(t, "hs1", "@bob:hs1") + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Execute the checks. checkRestrictedRoom(t, alice, bob, allowed_room, room, joinRule) @@ -57,14 +57,14 @@ func TestRestrictedRoomsLocalJoinInMSC3787Room(t *testing.T) { // See TestRestrictedRoomsRemoteJoin func TestRestrictedRoomsRemoteJoinInMSC3787Room(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) // Setup the user, allowed room, and restricted room. alice, allowed_room, room := setupRestrictedRoom(t, deployment, roomVersion, joinRule) // Create a second user on a different homeserver. - bob := deployment.Client(t, "hs2", "@bob:hs2") + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // Execute the checks. checkRestrictedRoom(t, alice, bob, allowed_room, room, joinRule) diff --git a/tests/knocking_test.go b/tests/knocking_test.go index 8451b9d9..1b70fbfd 100644 --- a/tests/knocking_test.go +++ b/tests/knocking_test.go @@ -40,20 +40,17 @@ func TestKnocking(t *testing.T) { } func doTestKnocking(t *testing.T, roomVersion string, joinRule string) { - deployment := complement.Deploy(t, b.BlueprintFederationTwoLocalOneRemote) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) // Create a client for one local user - aliceUserID := "@alice:hs1" - alice := deployment.Client(t, "hs1", aliceUserID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Create a client for another local user - bobUserID := "@bob:hs1" - bob := deployment.Client(t, "hs1", bobUserID) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Create a client for a remote user - charlieUserID := "@charlie:hs2" - charlie := deployment.Client(t, "hs2", charlieUserID) + charlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // Create a server to observe inviteWaiter := helpers.NewWaiter() @@ -342,12 +339,11 @@ func TestKnockRoomsInPublicRoomsDirectory(t *testing.T) { } func doTestKnockRoomsInPublicRoomsDirectory(t *testing.T, roomVersion string, joinRule string) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Create a client for a local user - aliceUserID := "@alice:hs1" - alice := deployment.Client(t, "hs1", aliceUserID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Create an invite-only room with the knock room version roomID := alice.MustCreateRoom(t, map[string]interface{}{ diff --git a/tests/media_filename_test.go b/tests/media_filename_test.go index cee712e9..2f7eaf29 100644 --- a/tests/media_filename_test.go +++ b/tests/media_filename_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/data" "github.com/matrix-org/complement/runtime" ) @@ -16,11 +16,11 @@ const asciiFileName = "ascii" const unicodeFileName = "\xf0\x9f\x90\x94" func TestMediaFilenames(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) t.Run("Parallel", func(t *testing.T) { diff --git a/tests/media_nofilename_test.go b/tests/media_nofilename_test.go index 2c279b45..7359c3dd 100644 --- a/tests/media_nofilename_test.go +++ b/tests/media_nofilename_test.go @@ -7,17 +7,17 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/federation" "github.com/matrix-org/complement/must" ) // Can handle uploads and remote/local downloads without a file name func TestMediaWithoutFileName(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) remoteMediaId := "PlainTextFile" remoteFile := []byte("Hello from the other side") diff --git a/tests/media_thumbnail_test.go b/tests/media_thumbnail_test.go index 038d01ba..eb6f6174 100644 --- a/tests/media_thumbnail_test.go +++ b/tests/media_thumbnail_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/internal/data" ) @@ -19,10 +19,10 @@ import ( // sytest: POSTed media can be thumbnailed func TestLocalPngThumbnail(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) fileName := "test.png" contentType := "image/png" @@ -34,11 +34,11 @@ func TestLocalPngThumbnail(t *testing.T) { // sytest: Remote media can be thumbnailed func TestRemotePngThumbnail(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs2", "@bob:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) fileName := "test.png" contentType := "image/png" diff --git a/tests/msc2836/msc2836_test.go b/tests/msc2836/msc2836_test.go index 19c3cb38..1940d87e 100644 --- a/tests/msc2836/msc2836_test.go +++ b/tests/msc2836/msc2836_test.go @@ -40,11 +40,11 @@ import ( // an event which the server does have, event B, to ensure that this request also works and also does // federated hits to return missing events (A,C). func TestEventRelationships(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) // Create the room and send events A,B,C,D - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", }) @@ -91,7 +91,7 @@ func TestEventRelationships(t *testing.T) { t.Logf("Event ID A:%s B:%s C:%s D:%s", eventA, eventB, eventC, eventD) // Join the room from another server - bob := deployment.Client(t, "hs2", "@bob:hs2") + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) _ = bob.MustJoinRoom(t, roomID, []string{"hs1"}) bob.MustSyncUntil(t, client.SyncReq{}, client.SyncJoinedTo(bob.UserID, roomID)) @@ -192,12 +192,12 @@ func TestEventRelationships(t *testing.T) { // We then check that B, which wasn't on the return path on the previous request, was persisted by calling // /event_relationships again with event ID 'A' and direction 'down'. func TestFederatedEventRelationships(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) - srv := federation.NewServer(t, deployment.GetConfig(), deployment.RoundTripper(), + srv := federation.NewServer(t, deployment, federation.HandleKeyRequests(), federation.HandleMakeSendJoinRequests(), federation.HandleTransactionRequests(nil, nil), diff --git a/tests/msc3391/msc3391_test.go b/tests/msc3391/msc3391_test.go index 98b846f4..0ab9f235 100644 --- a/tests/msc3391/msc3391_test.go +++ b/tests/msc3391/msc3391_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" @@ -22,12 +22,11 @@ const testAccountDataType = "org.example.test" var testAccountDataContent = map[string]interface{}{"test_data": 1} func TestRemovingAccountData(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Create a user to manipulate the account data of - aliceUserID := "@alice:hs1" - alice := deployment.Client(t, "hs1", aliceUserID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // And create a room with that user where we can store some room account data roomID := alice.MustCreateRoom(t, map[string]interface{}{}) diff --git a/tests/msc3874/room_messages_relation_filter_test.go b/tests/msc3874/room_messages_relation_filter_test.go index eb0ef6b8..e1b55edb 100644 --- a/tests/msc3874/room_messages_relation_filter_test.go +++ b/tests/msc3874/room_messages_relation_filter_test.go @@ -8,8 +8,8 @@ import ( "github.com/tidwall/gjson" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" @@ -17,10 +17,10 @@ import ( func TestFilterMessagesByRelType(t *testing.T) { runtime.SkipIf(t, runtime.Dendrite) // flakey - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) roomID := alice.MustCreateRoom(t, map[string]interface{}{"preset": "public_chat"}) diff --git a/tests/msc3890/msc3890_test.go b/tests/msc3890/msc3890_test.go index d8fabdfd..04dd4eeb 100644 --- a/tests/msc3890/msc3890_test.go +++ b/tests/msc3890/msc3890_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" @@ -18,7 +17,7 @@ import ( func TestDeletingDeviceRemovesDeviceLocalNotificationSettings(t *testing.T) { // Create a deployment with a single user - deployment := complement.Deploy(t, b.BlueprintCleanHS) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) t.Log("Alice registers on device 1 and logs in to device 2.") diff --git a/tests/msc3902/federation_room_join_partial_state_test.go b/tests/msc3902/federation_room_join_partial_state_test.go index 5bc60489..2ce6c420 100644 --- a/tests/msc3902/federation_room_join_partial_state_test.go +++ b/tests/msc3902/federation_room_join_partial_state_test.go @@ -221,7 +221,7 @@ func TestPartialStateJoin(t *testing.T) { return syncToken } - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Test that an eager (i.e. NOT lazy-loading members) /sync request made during a @@ -505,9 +505,9 @@ func TestPartialStateJoin(t *testing.T) { // we should be able to receive typing EDU over federation during the resync t.Run("CanReceiveTypingDuringPartialStateJoin", func(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) server := createTestServer(t, deployment) cancel := server.Listen() @@ -575,9 +575,9 @@ func TestPartialStateJoin(t *testing.T) { t.Run("CanReceivePresenceDuringPartialStateJoin", func(t *testing.T) { // See https://github.com/matrix-org/synapse/issues/13008") t.Skip("Presence EDUs are currently dropped during a resync") - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) server := createTestServer(t, deployment) cancel := server.Listen() @@ -622,9 +622,9 @@ func TestPartialStateJoin(t *testing.T) { // we should be able to receive to_device EDU over federation during the resync t.Run("CanReceiveToDeviceDuringPartialStateJoin", func(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) server := createTestServer(t, deployment) cancel := server.Listen() @@ -672,9 +672,9 @@ func TestPartialStateJoin(t *testing.T) { // we should be able to receive receipt EDU over federation during the resync t.Run("CanReceiveReceiptDuringPartialStateJoin", func(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) server := createTestServer(t, deployment) cancel := server.Listen() @@ -725,9 +725,9 @@ func TestPartialStateJoin(t *testing.T) { // we should be able to receive device list update EDU over federation during the resync t.Run("CanReceiveDeviceListUpdateDuringPartialStateJoin", func(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) server := createTestServer(t, deployment) cancel := server.Listen() @@ -776,9 +776,9 @@ func TestPartialStateJoin(t *testing.T) { // we should be able to receive signing key update EDU over federation during the resync t.Run("CanReceiveSigningKeyUpdateDuringPartialStateJoin", func(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) server := createTestServer(t, deployment) cancel := server.Listen() @@ -1235,10 +1235,10 @@ func TestPartialStateJoin(t *testing.T) { // partial state. t.Run("PartialStateJoinSyncsUsingOtherHomeservers", func(t *testing.T) { // set up 3 homeservers: hs1, hs2 and complement - deployment := complement.Deploy(t, b.BlueprintFederationTwoLocalOneRemote) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") - charlie := deployment.Client(t, "hs2", "@charlie:hs2") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + charlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // create a public room roomID := alice.MustCreateRoom(t, map[string]interface{}{ diff --git a/tests/msc3930/msc3930_test.go b/tests/msc3930/msc3930_test.go index 38995b01..7ae7c8e5 100644 --- a/tests/msc3930/msc3930_test.go +++ b/tests/msc3930/msc3930_test.go @@ -15,7 +15,7 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -27,12 +27,11 @@ const pollStartRuleID = ".org.matrix.msc3930.rule.poll_start" const pollEndRuleID = ".org.matrix.msc3930.rule.poll_end" func TestPollsLocalPushRules(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Create a user to poll the push rules of. - aliceUserID := "@alice:hs1" - alice := deployment.Client(t, "hs1", aliceUserID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Test for the presence of the expected push rules. Clients are expected // to implement local matching of events based on the presented rules. diff --git a/tests/restricted_room_hierarchy_test.go b/tests/restricted_room_hierarchy_test.go index 5db57e24..438ca14c 100644 --- a/tests/restricted_room_hierarchy_test.go +++ b/tests/restricted_room_hierarchy_test.go @@ -10,6 +10,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -36,11 +37,11 @@ func requestAndAssertSummary(t *testing.T, user *client.CSAPI, space string, exp // The user should be unable to see the room in the spaces summary unless they // are a member of the space. func TestRestrictedRoomsSpacesSummaryLocal(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Create the rooms - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) space := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "Space", @@ -92,7 +93,7 @@ func TestRestrictedRoomsSpacesSummaryLocal(t *testing.T) { t.Logf("Room: %s", room) // Create a second user on the same homeserver. - bob := deployment.Client(t, "hs1", "@bob:hs1") + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Querying the space returns only the space, as the room is restricted. requestAndAssertSummary(t, bob, space, []interface{}{space}) @@ -117,12 +118,12 @@ func TestRestrictedRoomsSpacesSummaryLocal(t *testing.T) { // different homeservers, and one might not have the proper information needed to // decide if a user is in a room. func TestRestrictedRoomsSpacesSummaryFederation(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationTwoLocalOneRemote) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) // Create the rooms - alice := deployment.Client(t, "hs1", "@alice:hs1") - bob := deployment.Client(t, "hs1", "@bob:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) space := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "Space", @@ -142,7 +143,7 @@ func TestRestrictedRoomsSpacesSummaryFederation(t *testing.T) { // The room is room version 8 which supports the restricted join_rule and is // created on hs2. - charlie := deployment.Client(t, "hs2", "@charlie:hs2") + charlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) room := charlie.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "Room", diff --git a/tests/restricted_rooms_test.go b/tests/restricted_rooms_test.go index 59f38495..4d31f169 100644 --- a/tests/restricted_rooms_test.go +++ b/tests/restricted_rooms_test.go @@ -10,6 +10,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/matrix-org/complement/runtime" @@ -20,7 +21,7 @@ import ( func setupRestrictedRoom(t *testing.T, deployment complement.Deployment, roomVersion string, joinRule string) (*client.CSAPI, string, string) { t.Helper() - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // The room which membership checks are delegated to. In practice, this will // often be an MSC1772 space, but that is not required. allowed_room := alice.MustCreateRoom(t, map[string]interface{}{ @@ -176,14 +177,14 @@ func checkRestrictedRoom(t *testing.T, alice *client.CSAPI, bob *client.CSAPI, a // Test joining a room with join rules restricted to membership in another room. func TestRestrictedRoomsLocalJoin(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // Setup the user, allowed room, and restricted room. alice, allowed_room, room := setupRestrictedRoom(t, deployment, "8", "restricted") // Create a second user on the same homeserver. - bob := deployment.Client(t, "hs1", "@bob:hs1") + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Execute the checks. checkRestrictedRoom(t, alice, bob, allowed_room, room, "restricted") @@ -191,14 +192,14 @@ func TestRestrictedRoomsLocalJoin(t *testing.T) { // Test joining a room with join rules restricted to membership in another room. func TestRestrictedRoomsRemoteJoin(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) // Setup the user, allowed room, and restricted room. alice, allowed_room, room := setupRestrictedRoom(t, deployment, "8", "restricted") // Create a second user on a different homeserver. - bob := deployment.Client(t, "hs2", "@bob:hs2") + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // Execute the checks. checkRestrictedRoom(t, alice, bob, allowed_room, room, "restricted") @@ -213,14 +214,14 @@ func TestRestrictedRoomsRemoteJoinLocalUser(t *testing.T) { func doTestRestrictedRoomsRemoteJoinLocalUser(t *testing.T, roomVersion string, joinRule string) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/2801 - deployment := complement.Deploy(t, b.BlueprintFederationTwoLocalOneRemote) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) // Charlie sets up the allowed room so it is on the other server. // // This is the room which membership checks are delegated to. In practice, // this will often be an MSC1772 space, but that is not required. - charlie := deployment.Client(t, "hs2", "@charlie:hs2") + charlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) allowed_room := charlie.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "Space", @@ -249,12 +250,12 @@ func doTestRestrictedRoomsRemoteJoinLocalUser(t *testing.T, roomVersion string, }) // Invite alice manually and accept it. - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) charlie.MustInviteRoom(t, room, alice.UserID) alice.JoinRoom(t, room, []string{"hs2"}) // Confirm that Alice cannot issue invites (due to the default power levels). - bob := deployment.Client(t, "hs1", "@bob:hs1") + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) res := alice.InviteRoom(t, room, bob.UserID) must.MatchResponse(t, res, match.HTTPResponse{ StatusCode: 403, @@ -332,38 +333,7 @@ func TestRestrictedRoomsRemoteJoinFailOver(t *testing.T) { func doTestRestrictedRoomsRemoteJoinFailOver(t *testing.T, roomVersion string, joinRule string) { runtime.SkipIf(t, runtime.Dendrite) // FIXME: https://github.com/matrix-org/dendrite/issues/2801 - deployment := complement.Deploy(t, b.Blueprint{ - Name: "federation_three_homeservers", - Homeservers: []b.Homeserver{ - { - Name: "hs1", - Users: []b.User{ - { - Localpart: "alice", - DisplayName: "Alice", - }, - }, - }, - { - Name: "hs2", - Users: []b.User{ - { - Localpart: "bob", - DisplayName: "Bob", - }, - }, - }, - { - Name: "hs3", - Users: []b.User{ - { - Localpart: "charlie", - DisplayName: "Charlie", - }, - }, - }, - }, - }) + deployment := complement.Deploy(t, 3) defer deployment.Destroy(t) // Setup the user, allowed room, and restricted room. @@ -386,7 +356,7 @@ func doTestRestrictedRoomsRemoteJoinFailOver(t *testing.T, roomVersion string, j }) // Create a second user on a different homeserver. - bob := deployment.Client(t, "hs2", "@bob:hs2") + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // Bob joins the room and allowed room. t.Logf("%s joins the authorizing room via hs1.", bob.UserID) @@ -395,7 +365,7 @@ func doTestRestrictedRoomsRemoteJoinFailOver(t *testing.T, roomVersion string, j bob.JoinRoom(t, room, []string{"hs1"}) // Charlie should join the allowed room (which gives access to the room). - charlie := deployment.Client(t, "hs3", "@charlie:hs3") + charlie := deployment.Register(t, "hs3", helpers.RegistrationOpts{}) t.Logf("%s joins the authorizing room via hs1.", charlie.UserID) charlie.JoinRoom(t, allowed_room, []string{"hs1"}) diff --git a/tests/room_hierarchy_test.go b/tests/room_hierarchy_test.go index c1d082be..caf4f126 100644 --- a/tests/room_hierarchy_test.go +++ b/tests/room_hierarchy_test.go @@ -23,6 +23,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -82,13 +83,13 @@ func roomToChildrenMapper(r gjson.Result) interface{} { // - Events are returned correctly. // - Redacting links works correctly. func TestClientSpacesSummary(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) roomNames := make(map[string]string) // create the rooms - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) root := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "Root", @@ -130,7 +131,7 @@ func TestClientSpacesSummary(t *testing.T) { }) roomNames[r3] = "R3" // alice is not joined to R4 - bob := deployment.Client(t, "hs1", "@bob:hs1") + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) r4 := bob.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "R4", @@ -392,11 +393,11 @@ func TestClientSpacesSummary(t *testing.T) { // Tests that: // - Rooms/spaces the user is not invited to should not appear. func TestClientSpacesSummaryJoinRules(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintOneToOneRoom) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) // create the rooms - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) root := alice.MustCreateRoom(t, map[string]interface{}{ "preset": "public_chat", "name": "Root", @@ -468,7 +469,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) { }) // Querying is done by bob who is not yet in any of the rooms. - bob := deployment.Client(t, "hs1", "@bob:hs1") + bob := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) bob.MustJoinRoom(t, root, []string{"hs1"}) res := bob.MustDo(t, "GET", []string{"_matrix", "client", "v1", "rooms", root, "hierarchy"}) @@ -540,7 +541,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) { // Tests that: // - Querying from root returns the entire graph func TestFederatedClientSpaces(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintFederationOneToOneRoom) + deployment := complement.Deploy(t, 2) defer deployment.Destroy(t) worldReadable := map[string]interface{}{ @@ -571,12 +572,12 @@ func TestFederatedClientSpaces(t *testing.T) { }, } // create the rooms - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) root := alice.MustCreateRoom(t, worldReadableSpace) r1 := alice.MustCreateRoom(t, worldReadable) ss1 := alice.MustCreateRoom(t, worldReadableSpace) r4 := alice.MustCreateRoom(t, worldReadable) - bob := deployment.Client(t, "hs2", "@bob:hs2") + bob := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) r2 := bob.MustCreateRoom(t, worldReadable) ss2 := bob.MustCreateRoom(t, worldReadableSpace) r3 := bob.MustCreateRoom(t, worldReadable) diff --git a/tests/room_timestamp_to_event_test.go b/tests/room_timestamp_to_event_test.go index 1988ab31..7c669847 100644 --- a/tests/room_timestamp_to_event_test.go +++ b/tests/room_timestamp_to_event_test.go @@ -18,6 +18,7 @@ import ( "github.com/matrix-org/complement" "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" "github.com/tidwall/gjson" @@ -25,20 +26,18 @@ import ( ) func TestJumpToDateEndpoint(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintHSWithApplicationService) + deployment := complement.OldDeploy(t, b.BlueprintHSWithApplicationService) defer deployment.Destroy(t) // Create the normal user which will send messages in the room - userID := "@alice:hs1" - alice := deployment.Client(t, "hs1", userID) + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Create the federated user which will fetch the messages from a remote homeserver - remoteUserID := "@charlie:hs2" - remoteCharlie := deployment.Client(t, "hs2", remoteUserID) + remoteCharlie := deployment.Register(t, "hs2", helpers.RegistrationOpts{}) // Create the application service bridge user that can use the ?ts query parameter asUserID := "@the-bridge-user:hs1" - as := deployment.Client(t, "hs1", asUserID) + as := deployment.AppServiceUser(t, "hs1", asUserID) t.Run("parallel", func(t *testing.T) { t.Run("should find event after given timestmap", func(t *testing.T) { @@ -116,7 +115,7 @@ func TestJumpToDateEndpoint(t *testing.T) { }) // We will use Bob to query the room they're not a member of - nonMemberUser := deployment.Client(t, "hs1", "@bob:hs1") + nonMemberUser := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Make the `/timestamp_to_event` request from Bob's perspective (non room member) timestamp := makeTimestampFromTime(timeBeforeRoomCreation) @@ -144,7 +143,7 @@ func TestJumpToDateEndpoint(t *testing.T) { }) // We will use Bob to query the room they're not a member of - nonMemberUser := deployment.Client(t, "hs1", "@bob:hs1") + nonMemberUser := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // Make the `/timestamp_to_event` request from Bob's perspective (non room member) timestamp := makeTimestampFromTime(timeBeforeRoomCreation) diff --git a/tests/unknown_endpoints_test.go b/tests/unknown_endpoints_test.go index d7f116e8..21761a37 100644 --- a/tests/unknown_endpoints_test.go +++ b/tests/unknown_endpoints_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/matrix-org/complement" - "github.com/matrix-org/complement/b" "github.com/matrix-org/complement/client" + "github.com/matrix-org/complement/helpers" "github.com/matrix-org/complement/match" "github.com/matrix-org/complement/must" ) @@ -38,10 +38,10 @@ func queryUnknownMethod(t *testing.T, user *client.CSAPI, method string, paths [ // Homeservers should return a 404 for unknown endpoints and 405 for incorrect // methods to known endpoints. func TestUnknownEndpoints(t *testing.T) { - deployment := complement.Deploy(t, b.BlueprintAlice) + deployment := complement.Deploy(t, 1) defer deployment.Destroy(t) - alice := deployment.Client(t, "hs1", "@alice:hs1") + alice := deployment.Register(t, "hs1", helpers.RegistrationOpts{}) // A completely unknown prefix to the matrix project. t.Run("Unknown prefix", func(t *testing.T) {