func TestRestrictedRoomsSpacesSummary(t *testing.T) {
	deployment := Deploy(t, b.BlueprintOneToOneRoom)
	defer deployment.Destroy(t)

	// Create the rooms
	alice := deployment.Client(t, "hs1", "@alice:hs1")
	space := alice.CreateRoom(t, map[string]interface{}{
		"preset": "public_chat",
		"name":   "Space",
		"creation_content": map[string]interface{}{
			"type": "m.space",
		},
		// World readable to allow peeking without joining.
		"initial_state": []map[string]interface{}{
			{
				"type":      "m.room.history_visibility",
				"state_key": "",
				"content": map[string]interface{}{
					"history_visibility": "world_readable",
				},
			},
		},
	})
	// The room is an unstable room version which supports the restricted join_rule.
	room := alice.CreateRoom(t, map[string]interface{}{
		"preset":       "public_chat",
		"name":         "Room",
		"room_version": "8",
		"initial_state": []map[string]interface{}{
			{
				"type":      "m.room.join_rules",
				"state_key": "",
				"content": map[string]interface{}{
					"join_rule": "restricted",
					"allow": []map[string]interface{}{
						{
							"type":    "m.room_membership",
							"room_id": &space,
							"via":     []string{"hs1"},
						},
					},
				},
			},
		},
	})
	alice.SendEventSynced(t, space, b.Event{
		Type:     "m.space.child",
		StateKey: &room,
		Content: map[string]interface{}{
			"via": []string{"hs1"},
		},
	})

	t.Logf("Space: %s", space)
	t.Logf("Room: %s", room)

	// Create a second user on the same homeserver.
	bob := deployment.Client(t, "hs1", "@bob:hs1")

	// Querying the space returns only the space, as the room is restricted.
	requestAndAssertSummary(t, bob, space, []interface{}{space})

	// Join the space, and now the restricted room should appear.
	bob.JoinRoom(t, space, []string{"hs1"})
	requestAndAssertSummary(t, bob, space, []interface{}{space, room})
}
// Tests that MSC2946 works for a restricted room.
//
// Create a space with a room in it that has join rules restricted to membership
// in that space.
//
// The user should be unable to see the room in the spaces summary unless they
// are a member of the space.
Tests that MSC2946 works for a restricted room.

Create a space with a room in it that has join rules restricted to membership
in that space.

The user should be unable to see the room in the spaces summary unless they
are a member of the space.
// Tests that MSC2946 works for a restricted room . // // Create a space with a room in it that has join rules restricted to membership // in that space . // // The user should be unable to see the room in the spaces summary unless they // are a member of the space .
func TestRestrictedRoomsSpacesSummary(t *testing.T) {
	deployment := Deploy(t, b.BlueprintOneToOneRoom)
	defer deployment.Destroy(t)
	alice := deployment.Client(t, "hs1", "@alice:hs1")
	space := alice.CreateRoom(t, map[string]interface{}{
		"preset": "public_chat",
		"name":   "Space",
		"creation_content": map[string]interface{}{
			"type": "m.space",
		},
		"initial_state": []map[string]interface{}{
			{
				"type":      "m.room.history_visibility",
				"state_key": "",
				"content": map[string]interface{}{
					"history_visibility": "world_readable",
				},
			},
		},
	})
	room := alice.CreateRoom(t, map[string]interface{}{
		"preset":       "public_chat",
		"name":         "Room",
		"room_version": "8",
		"initial_state": []map[string]interface{}{
			{
				"type":      "m.room.join_rules",
				"state_key": "",
				"content": map[string]interface{}{
					"join_rule": "restricted",
					"allow": []map[string]interface{}{
						{
							"type":    "m.room_membership",
							"room_id": &space,
							"via":     []string{"hs1"},
						},
					},
				},
			},
		},
	})
	alice.SendEventSynced(t, space, b.Event{
		Type:     "m.space.child",
		StateKey: &room,
		Content: map[string]interface{}{
			"via": []string{"hs1"},
		},
	})
	t.Logf("Space: %s", space)
	t.Logf("Room: %s", room)
	bob := deployment.Client(t, "hs1", "@bob:hs1")
	requestAndAssertSummary(t, bob, space, []interface{}{space})
	bob.JoinRoom(t, space, []string{"hs1"})
	requestAndAssertSummary(t, bob, space, []interface{}{space, room})
}
func TestRestrictedRoomsSpacesSummary ( t * testing . T ) { deployment := Deploy ( t , b . BlueprintOneToOneRoom ) defer deployment . Destroy ( t ) alice := deployment . Client ( t , " " , " " ) space := alice . CreateRoom ( t , map [ string ] interface { } { " " : " " , " " : " " , " " : map [ string ] interface { } { " " : " " , } , " " : [ ] map [ string ] interface { } { { " " : " " , " " : " " , " " : map [ string ] interface { } { " " : " " , } , } , } , } ) room := alice . CreateRoom ( t , map [ string ] interface { } { " " : " " , " " : " " , " " : " " , " " : [ ] map [ string ] interface { } { { " " : " " , " " : " " , " " : map [ string ] interface { } { " " : " " , " " : [ ] map [ string ] interface { } { { " " : " " , " " : & space , " " : [ ] string { " " } , } , } , } , } , } , } ) alice . SendEventSynced ( t , space , b . Event { Type : " " , StateKey : & room , Content : map [ string ] interface { } { " " : [ ] string { " " } , } , } ) t . Logf ( " " , space ) t . Logf ( " " , room ) bob := deployment . Client ( t , " " , " " ) requestAndAssertSummary ( t , bob , space , [ ] interface { } { space } ) bob . JoinRoom ( t , space , [ ] string { " " } ) requestAndAssertSummary ( t , bob , space , [ ] interface { } { space , room } ) }
Tests that MSC2946 works for a restricted room.
Tests that MSC2946 works for a restricted room .
// Create the rooms // World readable to allow peeking without joining. // The room is an unstable room version which supports the restricted join_rule. // Create a second user on the same homeserver. // Querying the space returns only the space, as the room is restricted. // Join the space, and now the restricted room should appear.