1- // +build msc2946  
1+ // +build !dendrite_blacklist  
22
33// This file includes tests for MSC2946, the spaces summary API. 
44// 
@@ -204,40 +204,7 @@ func TestClientSpacesSummary(t *testing.T) {
204204	// - Rooms are returned correctly along with the custom fields `room_type`. 
205205	// - Events are returned correctly. 
206206	t .Run ("query whole graph" , func (t  * testing.T ) {
207- 		res  :=  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "spaces" }, nil )
208- 		must .MatchResponse (t , res , match.HTTPResponse {
209- 			JSON : []match.JSON {
210- 				match .JSONCheckOff ("rooms" , []interface {}{
211- 					root , r1 , r2 , r3 , r4 , ss1 , ss2 ,
212- 				}, func (r  gjson.Result ) interface {} {
213- 					return  r .Get ("room_id" ).Str 
214- 				}, func (roomInt  interface {}, data  gjson.Result ) error  {
215- 					roomID  :=  roomInt .(string )
216- 					// check fields 
217- 					if  name , ok  :=  roomNames [roomID ]; ok  {
218- 						if  data .Get ("name" ).Str  !=  name  {
219- 							return  fmt .Errorf ("room %s got name %s want %s" , roomID , data .Get ("name" ).Str , name )
220- 						}
221- 					}
222- 					if  roomID  ==  ss1  {
223- 						wantType  :=  "m.space" 
224- 						if  data .Get ("room_type" ).Str  !=  wantType  {
225- 							return  fmt .Errorf ("room %s got type %s want %s" , roomID , data .Get ("room_type" ).Str , wantType )
226- 						}
227- 					}
228- 					return  nil 
229- 				}),
230- 				// Check that the links from Root down to other rooms and spaces exist. 
231- 				match .JSONCheckOff ("events" , []interface {}{
232- 					rootToR1 , rootToR2 , rootToSS1 ,
233- 					ss1ToSS2 , ss2ToR3 , ss2ToR4 ,
234- 				}, func (r  gjson.Result ) interface {} {
235- 					return  eventKey (r .Get ("room_id" ).Str , r .Get ("state_key" ).Str , r .Get ("type" ).Str )
236- 				}, nil ),
237- 			},
238- 		})
239- 
240- 		res  =  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "hierarchy" }, nil )
207+ 		res  :=  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "v1" , "rooms" , root , "hierarchy" }, nil )
241208		must .MatchResponse (t , res , match.HTTPResponse {
242209			JSON : []match.JSON {
243210				match .JSONCheckOff ("rooms" , []interface {}{
@@ -271,35 +238,6 @@ func TestClientSpacesSummary(t *testing.T) {
271238		})
272239	})
273240
274- 	// - Setting max_rooms_per_space works correctly 
275- 	t .Run ("max_rooms_per_space" , func (t  * testing.T ) {
276- 		// should omit either R3 or R4 if we start from SS1 because we only return 1 link per room which will be: 
277- 		// SS1 -> SS2 
278- 		// SS2 -> R3,R4 (but only 1 is allowed) 
279- 		query  :=  make (url.Values , 1 )
280- 		query .Set ("max_rooms_per_space" , "1" )
281- 		res  :=  alice .MustDoFunc (
282- 			t ,
283- 			"GET" ,
284- 			[]string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , ss1 , "spaces" },
285- 			client .WithQueries (query ),
286- 		)
287- 		wantItems  :=  []interface {}{
288- 			ss1ToSS2 ,
289- 			ss2ToR3 , ss2ToR4 , // one of these 
290- 		}
291- 		body  :=  must .ParseJSON (t , res .Body )
292- 		gjson .GetBytes (body , "events" ).ForEach (func (_ , val  gjson.Result ) bool  {
293- 			wantItems  =  must .CheckOff (t , wantItems , eventKey (val .Get ("room_id" ).Str , val .Get ("state_key" ).Str , val .Get ("type" ).Str ))
294- 			return  true 
295- 		})
296- 		if  len (wantItems ) !=  1  {
297- 			if  wantItems [0 ] !=  ss2ToR3  &&  wantItems [0 ] !=  ss2ToR4  {
298- 				t .Errorf ("expected fewer events to be returned: %s" , string (body ))
299- 			}
300- 		}
301- 	})
302- 
303241	// - Setting max_depth works correctly 
304242	t .Run ("max_depth" , func (t  * testing.T ) {
305243		// Should only include R1, SS1, and R2. 
@@ -308,7 +246,7 @@ func TestClientSpacesSummary(t *testing.T) {
308246		res  :=  alice .MustDoFunc (
309247			t ,
310248			"GET" ,
311- 			[]string {"_matrix" , "client" , "unstable"  ,  "org.matrix.msc2946 ""rooms" , root , "hierarchy" },
249+ 			[]string {"_matrix" , "client" , "v1 " , "rooms" , root , "hierarchy" },
312250			client .WithQueries (query ),
313251		)
314252		must .MatchResponse (t , res , match.HTTPResponse {
@@ -336,7 +274,7 @@ func TestClientSpacesSummary(t *testing.T) {
336274		res  :=  alice .MustDoFunc (
337275			t ,
338276			"GET" ,
339- 			[]string {"_matrix" , "client" , "unstable"  ,  "org.matrix.msc2946 ""rooms" , root , "hierarchy" },
277+ 			[]string {"_matrix" , "client" , "v1 " , "rooms" , root , "hierarchy" },
340278			client .WithQueries (query ),
341279		)
342280		must .MatchResponse (t , res , match.HTTPResponse {
@@ -364,7 +302,7 @@ func TestClientSpacesSummary(t *testing.T) {
364302		res  :=  alice .MustDoFunc (
365303			t ,
366304			"GET" ,
367- 			[]string {"_matrix" , "client" , "unstable"  ,  "org.matrix.msc2946 ""rooms" , root , "hierarchy" },
305+ 			[]string {"_matrix" , "client" , "v1 " , "rooms" , root , "hierarchy" },
368306			client .WithQueries (query ),
369307		)
370308		body  :=  must .MatchResponse (t , res , match.HTTPResponse {
@@ -383,7 +321,7 @@ func TestClientSpacesSummary(t *testing.T) {
383321		res  =  alice .MustDoFunc (
384322			t ,
385323			"GET" ,
386- 			[]string {"_matrix" , "client" , "unstable"  ,  "org.matrix.msc2946 ""rooms" , root , "hierarchy" },
324+ 			[]string {"_matrix" , "client" , "v1 " , "rooms" , root , "hierarchy" },
387325			client .WithQueries (query ),
388326		)
389327		must .MatchResponse (t , res , match.HTTPResponse {
@@ -404,23 +342,7 @@ func TestClientSpacesSummary(t *testing.T) {
404342			StateKey : & ss1 ,
405343			Content :  map [string ]interface {}{},
406344		})
407- 		res  :=  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "spaces" }, nil )
408- 		must .MatchResponse (t , res , match.HTTPResponse {
409- 			JSON : []match.JSON {
410- 				match .JSONCheckOff ("rooms" , []interface {}{
411- 					root , r1 , r2 ,
412- 				}, func (r  gjson.Result ) interface {} {
413- 					return  r .Get ("room_id" ).Str 
414- 				}, nil ),
415- 				match .JSONCheckOff ("events" , []interface {}{
416- 					rootToR1 , rootToR2 ,
417- 				}, func (r  gjson.Result ) interface {} {
418- 					return  eventKey (r .Get ("room_id" ).Str , r .Get ("state_key" ).Str , r .Get ("type" ).Str )
419- 				}, nil ),
420- 			},
421- 		})
422- 
423- 		res  =  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "hierarchy" }, nil )
345+ 		res  :=  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "v1" , "rooms" , root , "hierarchy" }, nil )
424346		must .MatchResponse (t , res , match.HTTPResponse {
425347			JSON : []match.JSON {
426348				match .JSONCheckOff ("rooms" , []interface {}{
@@ -534,22 +456,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
534456	bob  :=  deployment .Client (t , "hs1" , "@bob:hs1" )
535457	bob .JoinRoom (t , root , []string {"hs1" })
536458
537- 	res  :=  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "spaces" }, nil )
538- 	must .MatchResponse (t , res , match.HTTPResponse {
539- 		JSON : []match.JSON {
540- 			match .JSONCheckOff ("rooms" , []interface {}{
541- 				root ,
542- 			}, func (r  gjson.Result ) interface {} {
543- 				return  r .Get ("room_id" ).Str 
544- 			}, nil ),
545- 			match .JSONCheckOff ("events" , []interface {}{
546- 				rootToR1 , rootToSS1 ,
547- 			}, func (r  gjson.Result ) interface {} {
548- 				return  eventKey (r .Get ("room_id" ).Str , r .Get ("state_key" ).Str , r .Get ("type" ).Str )
549- 			}, nil ),
550- 		},
551- 	})
552- 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "hierarchy" }, nil )
459+ 	res  :=  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "v1" , "rooms" , root , "hierarchy" }, nil )
553460	must .MatchResponse (t , res , match.HTTPResponse {
554461		JSON : []match.JSON {
555462			match .JSONCheckOff ("rooms" , []interface {}{
@@ -569,22 +476,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
569476	alice .InviteRoom (t , r1 , bob .UserID )
570477	alice .InviteRoom (t , r3 , bob .UserID )
571478
572- 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "spaces" }, nil )
573- 	must .MatchResponse (t , res , match.HTTPResponse {
574- 		JSON : []match.JSON {
575- 			match .JSONCheckOff ("rooms" , []interface {}{
576- 				root , r1 ,
577- 			}, func (r  gjson.Result ) interface {} {
578- 				return  r .Get ("room_id" ).Str 
579- 			}, nil ),
580- 			match .JSONCheckOff ("events" , []interface {}{
581- 				rootToR1 , rootToSS1 ,
582- 			}, func (r  gjson.Result ) interface {} {
583- 				return  eventKey (r .Get ("room_id" ).Str , r .Get ("state_key" ).Str , r .Get ("type" ).Str )
584- 			}, nil ),
585- 		},
586- 	})
587- 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "hierarchy" }, nil )
479+ 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "v1" , "rooms" , root , "hierarchy" }, nil )
588480	must .MatchResponse (t , res , match.HTTPResponse {
589481		JSON : []match.JSON {
590482			match .JSONCheckOff ("rooms" , []interface {}{
@@ -603,22 +495,7 @@ func TestClientSpacesSummaryJoinRules(t *testing.T) {
603495	// Invite to SS1 and it now appears, as well as the rooms under it. 
604496	alice .InviteRoom (t , ss1 , bob .UserID )
605497
606- 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "spaces" }, nil )
607- 	must .MatchResponse (t , res , match.HTTPResponse {
608- 		JSON : []match.JSON {
609- 			match .JSONCheckOff ("rooms" , []interface {}{
610- 				root , r1 , ss1 , r2 , r3 ,
611- 			}, func (r  gjson.Result ) interface {} {
612- 				return  r .Get ("room_id" ).Str 
613- 			}, nil ),
614- 			match .JSONCheckOff ("events" , []interface {}{
615- 				rootToR1 , rootToSS1 , ss1ToR2 , ss1ToR3 ,
616- 			}, func (r  gjson.Result ) interface {} {
617- 				return  eventKey (r .Get ("room_id" ).Str , r .Get ("state_key" ).Str , r .Get ("type" ).Str )
618- 			}, nil ),
619- 		},
620- 	})
621- 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "hierarchy" }, nil )
498+ 	res  =  bob .MustDo (t , "GET" , []string {"_matrix" , "client" , "v1" , "rooms" , root , "hierarchy" }, nil )
622499	must .MatchResponse (t , res , match.HTTPResponse {
623500		JSON : []match.JSON {
624501			match .JSONCheckOff ("rooms" , []interface {}{
@@ -748,17 +625,7 @@ func TestFederatedClientSpaces(t *testing.T) {
748625	}
749626	t .Logf ("rooms: %v" , allEvents )
750627
751- 	res  :=  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "spaces" }, nil )
752- 	must .MatchResponse (t , res , match.HTTPResponse {
753- 		JSON : []match.JSON {
754- 			match .JSONCheckOff ("rooms" , []interface {}{
755- 				root , r1 , r2 , r3 , r4 , ss1 , ss2 ,
756- 			}, func (r  gjson.Result ) interface {} {
757- 				return  r .Get ("room_id" ).Str 
758- 			}, nil ),
759- 		},
760- 	})
761- 	res  =  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "unstable" , "org.matrix.msc2946" , "rooms" , root , "hierarchy" }, nil )
628+ 	res  :=  alice .MustDo (t , "GET" , []string {"_matrix" , "client" , "v1" , "rooms" , root , "hierarchy" }, nil )
762629	must .MatchResponse (t , res , match.HTTPResponse {
763630		JSON : []match.JSON {
764631			match .JSONCheckOff ("rooms" , []interface {}{
0 commit comments