Add some invalid joins

This commit is contained in:
Till Faelligen 2022-12-09 17:49:28 +01:00
parent 632e9859eb
commit cb4aab0fa0
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -91,5 +91,23 @@ func TestJoinRoomByIDOrAlias(t *testing.T) {
t.Fatalf("expected response code to be %d, got %d", http.StatusForbidden, joinResp.Code)
}
// Some invalid requests
// room doesn't exist
joinResp = JoinRoomByIDOrAlias(req, aliceDev, rsAPI, userAPI, "!doesnotexist:test")
if joinResp.Is2xx() {
t.Fatalf("expected join room to fail, but didn't: %+v", joinResp)
}
// user from different server
joinResp = JoinRoomByIDOrAlias(req, &uapi.Device{UserID: "@wrong:server"}, rsAPI, userAPI, crResp.RoomAlias)
if joinResp.Is2xx() {
t.Fatalf("expected join room to fail, but didn't: %+v", joinResp)
}
// user doesn't exist locally
joinResp = JoinRoomByIDOrAlias(req, &uapi.Device{UserID: "@doesnotexist:test"}, rsAPI, userAPI, crResp.RoomAlias)
if joinResp.Is2xx() {
t.Fatalf("expected join room to fail, but didn't: %+v", joinResp)
}
})
}