mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-08 06:33:09 -06:00
resolve latest merge problems. Fix test failures
This commit is contained in:
parent
f9fe86ce2c
commit
63c169958d
|
|
@ -62,11 +62,10 @@ func TestLoginFromJSONReader(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
userInteractive := UserInteractive{
|
userInteractive := UserInteractive{
|
||||||
Completed: []string{},
|
Flows: []userInteractiveFlow{},
|
||||||
Flows: []userInteractiveFlow{},
|
Types: make(map[string]Type),
|
||||||
Types: make(map[string]Type),
|
Sessions: make(map[string][]string),
|
||||||
Sessions: make(map[string][]string),
|
Params: make(map[string]interface{}),
|
||||||
Params: make(map[string]interface{}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tst := range tsts {
|
for _, tst := range tsts {
|
||||||
|
|
@ -148,11 +147,10 @@ func TestBadLoginFromJSONReader(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
userInteractive := UserInteractive{
|
userInteractive := UserInteractive{
|
||||||
Completed: []string{},
|
Flows: []userInteractiveFlow{},
|
||||||
Flows: []userInteractiveFlow{},
|
Types: make(map[string]Type),
|
||||||
Types: make(map[string]Type),
|
Sessions: make(map[string][]string),
|
||||||
Sessions: make(map[string][]string),
|
Params: make(map[string]interface{}),
|
||||||
Params: make(map[string]interface{}),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tst := range tsts {
|
for _, tst := range tsts {
|
||||||
|
|
|
||||||
|
|
@ -220,7 +220,7 @@ func (u *UserInteractive) ResponseWithChallenge(sessionID string, response inter
|
||||||
// Verify returns an error/challenge response to send to the client, or nil if the user is authenticated.
|
// Verify returns an error/challenge response to send to the client, or nil if the user is authenticated.
|
||||||
// `bodyBytes` is the HTTP request body which must contain an `auth` key.
|
// `bodyBytes` is the HTTP request body which must contain an `auth` key.
|
||||||
// Returns the login that was verified for additional checks if required.
|
// Returns the login that was verified for additional checks if required.
|
||||||
func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte) (*Login, *util.JSONResponse) {
|
func (u *UserInteractive) Verify(ctx context.Context, bodyBytes []byte, device *api.Device) (*Login, *util.JSONResponse) {
|
||||||
// TODO: rate limit
|
// TODO: rate limit
|
||||||
|
|
||||||
// "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body"
|
// "A client should first make a request with no auth parameter. The homeserver returns an HTTP 401 response, with a JSON body"
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ var (
|
||||||
serverName = gomatrixserverlib.ServerName("example.com")
|
serverName = gomatrixserverlib.ServerName("example.com")
|
||||||
// space separated localpart+password -> account
|
// space separated localpart+password -> account
|
||||||
lookup = make(map[string]*api.Account)
|
lookup = make(map[string]*api.Account)
|
||||||
|
device = &api.Device{
|
||||||
|
AccessToken: "flibble",
|
||||||
|
DisplayName: "My Device",
|
||||||
|
ID: "device_id_goes_here",
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type fakeAccountDatabase struct {
|
type fakeAccountDatabase struct {
|
||||||
|
|
@ -55,7 +60,7 @@ func setup() *UserInteractive {
|
||||||
func TestUserInteractiveChallenge(t *testing.T) {
|
func TestUserInteractiveChallenge(t *testing.T) {
|
||||||
uia := setup()
|
uia := setup()
|
||||||
// no auth key results in a challenge
|
// no auth key results in a challenge
|
||||||
_, errRes := uia.Verify(ctx, []byte(`{}`))
|
_, errRes := uia.Verify(ctx, []byte(`{}`), device)
|
||||||
if errRes == nil {
|
if errRes == nil {
|
||||||
t.Fatalf("Verify succeeded with {} but expected failure")
|
t.Fatalf("Verify succeeded with {} but expected failure")
|
||||||
}
|
}
|
||||||
|
|
@ -95,7 +100,7 @@ func TestUserInteractivePasswordLogin(t *testing.T) {
|
||||||
}`),
|
}`),
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
_, errRes := uia.Verify(ctx, tc)
|
_, errRes := uia.Verify(ctx, tc, device)
|
||||||
if errRes != nil {
|
if errRes != nil {
|
||||||
t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes)
|
t.Errorf("Verify failed but expected success for request: %s - got %+v", string(tc), errRes)
|
||||||
}
|
}
|
||||||
|
|
@ -176,7 +181,7 @@ func TestUserInteractivePasswordBadLogin(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
_, errRes := uia.Verify(ctx, tc.body)
|
_, errRes := uia.Verify(ctx, tc.body, device)
|
||||||
if errRes == nil {
|
if errRes == nil {
|
||||||
t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body))
|
t.Errorf("Verify succeeded but expected failure for request: %s", string(tc.body))
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ func Deactivate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes)
|
login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, deviceAPI)
|
||||||
if errRes != nil {
|
if errRes != nil {
|
||||||
return *errRes
|
return *errRes
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -198,7 +198,7 @@ func DeleteDeviceById(
|
||||||
sessionID = s
|
sessionID = s
|
||||||
}
|
}
|
||||||
|
|
||||||
login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes)
|
login, errRes := userInteractiveAuth.Verify(ctx, bodyBytes, device)
|
||||||
if errRes != nil {
|
if errRes != nil {
|
||||||
switch data := errRes.JSON.(type) {
|
switch data := errRes.JSON.(type) {
|
||||||
case auth.Challenge:
|
case auth.Challenge:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue