@@ -2,6 +2,7 @@ package tests
22
33import (
44 "encoding/json"
5+ "fmt"
56 "testing"
67
78 "github.com/tidwall/gjson"
@@ -16,6 +17,27 @@ func TestLogin(t *testing.T) {
1617 defer deployment .Destroy (t )
1718 unauthedClient := deployment .Client (t , "hs1" , "" )
1819 t .Run ("parallel" , func (t * testing.T ) {
20+ // sytest: GET /login yields a set of flows
21+ t .Run ("GET /login yields a set of flows" , func (t * testing.T ) {
22+ t .Parallel ()
23+ res := unauthedClient .MustDo (t , "GET" , []string {"_matrix" , "client" , "r0" , "login" }, json .RawMessage (`{}` ))
24+ must .MatchResponse (t , res , match.HTTPResponse {
25+ Headers : map [string ]string {
26+ "Content-Type" : "application/json" ,
27+ },
28+ JSON : []match.JSON {
29+ // TODO(paul): Spec is a little vague here. Spec says that every
30+ // option needs a 'stages' key, but the implementation omits it
31+ // for options that have only one stage in their flow.
32+ match .JSONArrayEach ("flows" , func (val gjson.Result ) error {
33+ if ! (val .Get ("stages" ).IsArray ()) && (val .Get ("type" ).Raw == "" ) {
34+ return fmt .Errorf ("expected flow to have a list of 'stages' or a 'type' : %v %v" , val .Get ("type" ).Raw , val .Get ("stages" ))
35+ }
36+ return nil
37+ }),
38+ },
39+ })
40+ })
1941 // sytest: POST /login can log in as a user
2042 t .Run ("POST /login can login as user" , func (t * testing.T ) {
2143 t .Parallel ()
@@ -32,8 +54,6 @@ func TestLogin(t *testing.T) {
3254 match .JSONKeyTypeEqual ("user_id" , gjson .String ),
3355 },
3456 })
35- //body, _ := ioutil.ReadAll(res.Body)
36- //userId := gjson.Get(string(body), "user_id")
3757 res = unauthedClient .MustDo (t , "POST" , []string {"_matrix" , "client" , "r0" , "login" }, json .RawMessage (`{
3858 "type": "m.login.password",
3959 "identifier": {
0 commit comments