mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-06 21:53:09 -06:00
Use WithAllDatabases where possible
This commit is contained in:
parent
5960b0aaf4
commit
86c8212557
|
|
@ -23,17 +23,17 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
internalTest "github.com/matrix-org/dendrite/internal/test"
|
||||
"github.com/matrix-org/dendrite/test"
|
||||
"github.com/matrix-org/dendrite/userapi"
|
||||
"github.com/matrix-org/dendrite/userapi/inthttp"
|
||||
"github.com/matrix-org/gomatrixserverlib"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/matrix-org/dendrite/internal/httputil"
|
||||
internalTest "github.com/matrix-org/dendrite/internal/test"
|
||||
"github.com/matrix-org/dendrite/setup/config"
|
||||
"github.com/matrix-org/dendrite/userapi/api"
|
||||
"github.com/matrix-org/dendrite/userapi/internal"
|
||||
"github.com/matrix-org/dendrite/userapi/inthttp"
|
||||
"github.com/matrix-org/dendrite/userapi/storage"
|
||||
)
|
||||
|
||||
|
|
@ -73,6 +73,7 @@ func MustMakeInternalAPI(t *testing.T, opts apiTestOpts, dbType test.DBType) (ap
|
|||
func TestQueryProfile(t *testing.T) {
|
||||
aliceAvatarURL := "mxc://example.com/alice"
|
||||
aliceDisplayName := "Alice"
|
||||
// only one DBType, since userapi.AddInternalRoutes complains about multiple prometheus counters added
|
||||
userAPI, accountDB, close := MustMakeInternalAPI(t, apiTestOpts{}, test.DBTypeSQLite)
|
||||
defer close()
|
||||
_, err := accountDB.CreateAccount(context.TODO(), "alice", "foobar", "", api.AccountTypeUser)
|
||||
|
|
@ -151,7 +152,8 @@ func TestLoginToken(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
|
||||
t.Run("tokenLoginFlow", func(t *testing.T) {
|
||||
userAPI, accountDB, close := MustMakeInternalAPI(t, apiTestOpts{}, test.DBTypeSQLite)
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
userAPI, accountDB, close := MustMakeInternalAPI(t, apiTestOpts{}, dbType)
|
||||
defer close()
|
||||
_, err := accountDB.CreateAccount(ctx, "auser", "apassword", "", api.AccountTypeUser)
|
||||
if err != nil {
|
||||
|
|
@ -197,9 +199,11 @@ func TestLoginToken(t *testing.T) {
|
|||
t.Fatalf("PerformLoginTokenDeletion failed: %v", err)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("expiredTokenIsNotReturned", func(t *testing.T) {
|
||||
userAPI, _, close := MustMakeInternalAPI(t, apiTestOpts{loginTokenLifetime: -1 * time.Second}, test.DBTypeSQLite)
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
userAPI, _, close := MustMakeInternalAPI(t, apiTestOpts{loginTokenLifetime: -1 * time.Second}, dbType)
|
||||
defer close()
|
||||
|
||||
creq := api.PerformLoginTokenCreationRequest{
|
||||
|
|
@ -220,9 +224,11 @@ func TestLoginToken(t *testing.T) {
|
|||
t.Errorf("QueryLoginToken Data: got %v, want nil", qresp.Data)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("deleteWorks", func(t *testing.T) {
|
||||
userAPI, _, close := MustMakeInternalAPI(t, apiTestOpts{}, test.DBTypeSQLite)
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
userAPI, _, close := MustMakeInternalAPI(t, apiTestOpts{}, dbType)
|
||||
defer close()
|
||||
|
||||
creq := api.PerformLoginTokenCreationRequest{
|
||||
|
|
@ -249,9 +255,11 @@ func TestLoginToken(t *testing.T) {
|
|||
t.Errorf("QueryLoginToken Data: got %v, want nil", qresp.Data)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("deleteUnknownIsNoOp", func(t *testing.T) {
|
||||
userAPI, _, close := MustMakeInternalAPI(t, apiTestOpts{}, test.DBTypeSQLite)
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
userAPI, _, close := MustMakeInternalAPI(t, apiTestOpts{}, dbType)
|
||||
defer close()
|
||||
dreq := api.PerformLoginTokenDeletionRequest{Token: "non-existent token"}
|
||||
var dresp api.PerformLoginTokenDeletionResponse
|
||||
|
|
@ -259,4 +267,5 @@ func TestLoginToken(t *testing.T) {
|
|||
t.Fatalf("PerformLoginTokenDeletion failed: %v", err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue