|
1 | | -test "Name/topic keys are correct", |
2 | | - requires => [ $main::API_CLIENTS[0], local_user_fixture() ], |
3 | | - |
4 | | - check => sub { |
5 | | - my ( $http, $user ) = @_; |
6 | | - |
7 | | - my %rooms = ( |
8 | | - publicroomalias_no_name => {}, |
9 | | - publicroomalias_with_name => { |
10 | | - name => "name_1", |
11 | | - }, |
12 | | - publicroomalias_with_topic => { |
13 | | - topic => "topic_1", |
14 | | - }, |
15 | | - publicroomalias_with_name_topic => { |
16 | | - name => "name_2", |
17 | | - topic => "topic_2", |
18 | | - }, |
19 | | - publicroom_with_unicode_chars_name => { |
20 | | - name => "un nom français", |
21 | | - }, |
22 | | - publicroom_with_unicode_chars_topic => { |
23 | | - topic => "un topic à la française", |
24 | | - }, |
25 | | - publicroom_with_unicode_chars_name_topic => { |
26 | | - name => "un nom français", |
27 | | - topic => "un topic à la française", |
28 | | - }, |
29 | | - ); |
30 | | - |
31 | | - Future->needs_all( map { |
32 | | - my $alias_local = $_; |
33 | | - my $room = $rooms{$alias_local}; |
34 | | - |
35 | | - matrix_create_room_synced( $user, |
36 | | - visibility => "public", |
37 | | - room_alias_name => $alias_local, |
38 | | - %{$room}, |
39 | | - )->on_done( sub { |
40 | | - my ( $room_id ) = @_; |
41 | | - log_if_fail "Created room $room_id with alias $alias_local"; |
42 | | - }); |
43 | | - } keys %rooms ) |
44 | | - ->then( sub { |
45 | | - my $iter = 0; |
46 | | - retry_until_success { |
47 | | - $http->do_request_json( |
48 | | - method => "GET", |
49 | | - uri => "/v3/publicRooms", |
50 | | - )->then( sub { |
51 | | - my ( $body ) = @_; |
52 | | - |
53 | | - $iter++; |
54 | | - log_if_fail "Iteration $iter: publicRooms result", $body; |
55 | | - |
56 | | - assert_json_keys( $body, qw( chunk )); |
57 | | - assert_json_list( $body->{chunk} ); |
58 | | - |
59 | | - my %isOK = map { |
60 | | - $_ => 0, |
61 | | - } keys ( %rooms ); |
62 | | - |
63 | | - foreach my $room ( @{ $body->{chunk} } ) { |
64 | | - assert_json_keys( $room, |
65 | | - qw( world_readable guest_can_join num_joined_members ) |
66 | | - ); |
67 | | - |
68 | | - my $name = $room->{name}; |
69 | | - my $topic = $room->{topic}; |
70 | | - my $canonical_alias = $room->{canonical_alias}; |
71 | | - |
72 | | - next unless $canonical_alias; |
73 | | - |
74 | | - foreach my $alias_local ( keys %rooms ) { |
75 | | - $canonical_alias =~ m/^\Q#$alias_local:\E/ or next; |
76 | | - |
77 | | - my $room_config = $rooms{$alias_local}; |
78 | | - |
79 | | - assert_eq( $room->{num_joined_members}, 1, "member count for '$alias_local'" ); |
80 | | - |
81 | | - # The rooms should get created "atomically", so we should never |
82 | | - # see any out of the public rooms list in the wrong state. If |
83 | | - # we see a room we expect it to already be in the right state. |
84 | | - |
85 | | - if( defined $name ) { |
86 | | - assert_eq( $room_config->{name}, $name, "room name for '$alias_local'" ); |
87 | | - } |
88 | | - else { |
89 | | - defined $room_config->{name} and die "Expected not to find a name for '$alias_local'"; |
90 | | - } |
91 | | - |
92 | | - if( defined $topic ) { |
93 | | - assert_eq( $room_config->{topic}, $topic, "room topic for '$alias_local'" ); |
94 | | - } |
95 | | - else { |
96 | | - defined $room_config->{topic} and die "Expected not to find a topic for '$alias_local'"; |
97 | | - } |
98 | | - |
99 | | - $isOK{$alias_local} = 1; |
100 | | - } |
101 | | - } |
102 | | - |
103 | | - foreach my $alias ( keys %rooms ) { |
104 | | - $isOK{$alias} or die "$alias not found in result"; |
105 | | - } |
106 | | - |
107 | | - Future->done( 1 ); |
108 | | - }); |
109 | | - }; |
110 | | - }); |
111 | | - }; |
112 | | - |
113 | 1 | test "Can get remote public room list", |
114 | 2 | requires => [ $main::HOMESERVER_INFO[0], local_user_fixture(), remote_user_fixture() ], |
115 | 3 |
|
|
0 commit comments