@@ -46,5 +46,55 @@ func TestRoomCreate(t *testing.T) {
4646 },
4747 })
4848 })
49+ // sytest: POST /createRoom makes a private room with invites
50+ t .Run ("POST /createRoom makes a private room with invites" , func (t * testing.T ) {
51+ t .Parallel ()
52+ userInvite := deployment .RegisterUser (t , "hs1" , "create_room" , "superuser" )
53+ reqBody := client .WithJSONBody (t , map [string ]interface {}{
54+ "visibility" : "private" ,
55+ "invite" : []string {userInvite .UserID },
56+ })
57+ res := authedClient .MustDoFunc (t , "POST" , []string {"_matrix" , "client" , "r0" , "createRoom" }, reqBody )
58+ must .MatchResponse (t , res , match.HTTPResponse {
59+ JSON : []match.JSON {
60+ match .JSONKeyPresent ("room_id" ),
61+ match .JSONKeyTypeEqual ("room_id" , gjson .String ),
62+ },
63+ })
64+ })
65+ // sytest: POST /createRoom rejects attempts to create rooms with numeric versions
66+ t .Run ("POST /createRoom rejects attempts to create rooms with numeric versions" , func (t * testing.T ) {
67+ t .Parallel ()
68+ reqBody := client .WithJSONBody (t , map [string ]interface {}{
69+ "visibility" : "private" ,
70+ "room_version" : 1 ,
71+ "preset" : "public_chat" ,
72+ })
73+ res := authedClient .DoFunc (t , "POST" , []string {"_matrix" , "client" , "r0" , "createRoom" }, reqBody )
74+ must .MatchResponse (t , res , match.HTTPResponse {
75+ StatusCode : 400 ,
76+ JSON : []match.JSON {
77+ match .JSONKeyPresent ("errcode" ),
78+ match .JSONKeyEqual ("errcode" , "M_BAD_JSON" ),
79+ },
80+ })
81+ })
82+ // sytest: POST /createRoom rejects attempts to create rooms with unknown versions
83+ t .Run ("POST /createRoom rejects attempts to create rooms with unknown versions" , func (t * testing.T ) {
84+ t .Parallel ()
85+ reqBody := client .WithJSONBody (t , map [string ]interface {}{
86+ "visibility" : "private" ,
87+ "room_version" : "ahfgwjyerhgiuveisbruvybseyrugvi" ,
88+ "preset" : "public_chat" ,
89+ })
90+ res := authedClient .DoFunc (t , "POST" , []string {"_matrix" , "client" , "r0" , "createRoom" }, reqBody )
91+ must .MatchResponse (t , res , match.HTTPResponse {
92+ StatusCode : 400 ,
93+ JSON : []match.JSON {
94+ match .JSONKeyPresent ("errcode" ),
95+ match .JSONKeyEqual ("errcode" , "M_UNSUPPORTED_ROOM_VERSION" ),
96+ },
97+ })
98+ })
4999 })
50100}
0 commit comments