mirror of
https://github.com/1f349/dendrite.git
synced 2024-12-22 16:24:10 +00:00
Add regression test for 980fa55846
This commit is contained in:
parent
980fa55846
commit
04bab14290
@ -151,6 +151,33 @@ func TestQueryProfile(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
// TestPasswordlessLoginFails ensures that a passwordless account cannot
|
||||
// be logged into using an arbitrary password (effectively a regression test
|
||||
// for https://github.com/matrix-org/dendrite/issues/2780).
|
||||
func TestPasswordlessLoginFails(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
test.WithAllDatabases(t, func(t *testing.T, dbType test.DBType) {
|
||||
userAPI, accountDB, close := MustMakeInternalAPI(t, apiTestOpts{}, dbType)
|
||||
defer close()
|
||||
_, err := accountDB.CreateAccount(ctx, "auser", "", "", api.AccountTypeAppService)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to make account: %s", err)
|
||||
}
|
||||
|
||||
userReq := &api.QueryAccountByPasswordRequest{
|
||||
Localpart: "auser",
|
||||
PlaintextPassword: "apassword",
|
||||
}
|
||||
userRes := &api.QueryAccountByPasswordResponse{}
|
||||
if err := userAPI.QueryAccountByPassword(ctx, userReq, userRes); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if userRes.Exists || userRes.Account != nil {
|
||||
t.Fatal("QueryAccountByPassword should not return correctly for a passwordless account")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestLoginToken(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user