Skip to content

Commit 4e951cb

Browse files
committed
Merge remote-tracking branch 'origin/release-v1.12.0' into dinsic-release-v1.12.x
* origin/release-v1.12.0: Missing bits Use r0 instead of 'unstable' for joined_members|rooms Add test to optionally keep other sessions when modifying a user's password. (#832) Remove tests that call query_auth endpoint. (#827) Add tests for validating alt_aliases of a canonical alias event. (#824) Update the haproxy config to route fallback auth and register to the same worker. (#828) Add tests for a user with sufficient power level removing an alias. (#818) Add a test for an event with an invalid signature (#821) Fix race in self signing key tests. (#822) Use retry_until_success instead of repeat_until_true. Attempt to deflake a test. Fix frontend proxy worker binding to wrong port. (#823) Stop checking for aliases in the public room list. Attempt to deflake a sytest (#816) Fix formatting from review. Support running Dendrite in more than 1 sqlite db file Add tests for moving alt_aliases to an upgraded room. Support running dendrite in sqlite
2 parents de81a37 + aaac4f5 commit 4e951cb

File tree

17 files changed

+466
-252
lines changed

17 files changed

+466
-252
lines changed

docker/base.Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,3 @@ ENV PGHOST=/var/run/postgresql
6060
ENV PGDATA=$PGHOST/data
6161
ENV PGUSER=postgres
6262
RUN for ver in `ls /usr/lib/postgresql | head -n 1`; do su -c '/usr/lib/postgresql/'$ver'/bin/initdb -E "UTF-8" --lc-collate="C" --lc-ctype="C" --username=postgres' postgres; done
63-
64-
# Turn off all the fsync stuff for postgres
65-
RUN for ver in /etc/postgresql/*/main; do mkdir -p $ver/conf.d/; echo -e "fsync=off\nfull_page_writes=off" >> $ver/conf.d/fsync.conf; done

lib/SyTest/Homeserver/Dendrite.pm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ sub _get_config
136136
},
137137

138138
database => {
139-
map { $_ => $db_uri } qw(
139+
# POSTGRES not set or is 0, use sqlite, which has separate .db files for each server
140+
map { ( ! defined $ENV{'POSTGRES'} || $ENV{'POSTGRES'} == '0') ?
141+
($_ => "file:$self->{hs_dir}/" . $_ . ".db") :
142+
($_ => $db_uri) } qw(
140143
account device media_api sync_api room_server server_key
141144
federation_sender public_rooms_api naffka appservice
142145
),

lib/SyTest/Homeserver/Synapse.pm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ sub wrap_synapse_command
712712
"worker_log_config" => $self->configure_logger("pusher"),
713713
"worker_replication_host" => "$bind_host",
714714
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
715+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
715716
"worker_listeners" => [
716717
{
717718
type => "http",
@@ -737,6 +738,7 @@ sub wrap_synapse_command
737738
"worker_log_config" => $self->configure_logger("appservice"),
738739
"worker_replication_host" => "$bind_host",
739740
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
741+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
740742
"worker_listeners" => [
741743
{
742744
type => "manhole",
@@ -762,6 +764,7 @@ sub wrap_synapse_command
762764
"worker_log_config" => $self->configure_logger("federation_sender"),
763765
"worker_replication_host" => "$bind_host",
764766
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
767+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
765768
"worker_listeners" => [
766769
{
767770
type => "manhole",
@@ -787,6 +790,7 @@ sub wrap_synapse_command
787790
"worker_log_config" => $self->configure_logger("synchrotron"),
788791
"worker_replication_host" => "$bind_host",
789792
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
793+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
790794
"worker_listeners" => [
791795
{
792796
type => "http",
@@ -854,6 +858,7 @@ sub wrap_synapse_command
854858
"worker_log_config" => $self->configure_logger("media_repository"),
855859
"worker_replication_host" => "$bind_host",
856860
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
861+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
857862
"worker_listeners" => [
858863
{
859864
type => "http",
@@ -921,6 +926,7 @@ sub wrap_synapse_command
921926
"worker_log_config" => $self->configure_logger("user_dir"),
922927
"worker_replication_host" => "$bind_host",
923928
"worker_replication_port" => $self->{ports}{synapse_replication_tcp},
929+
"worker_replication_http_port" => $self->{ports}{synapse_unsecure},
924930
"worker_listeners" => [
925931
{
926932
type => "http",
@@ -999,7 +1005,7 @@ sub wrap_synapse_command
9991005
},
10001006
{
10011007
type => "manhole",
1002-
port => $self->{ports}{frontend_proxy},
1008+
port => $self->{ports}{frontend_proxy_manhole},
10031009
bind_address => $bind_host,
10041010
},
10051011
{
@@ -1207,6 +1213,7 @@ sub generate_haproxy_map
12071213
^/_matrix/client/versions$ client_reader
12081214
^/_matrix/client/(api/v1|r0|unstable)/voip/turnServer$ client_reader
12091215
^/_matrix/client/(r0|unstable)/register$ client_reader
1216+
^/_matrix/client/(r0|unstable)/auth/.*/fallback/web$ client_reader
12101217
^/_matrix/client/(api/v1|r0|unstable)/rooms/.*/messages$ client_reader
12111218
^/_matrix/client/(api/v1|r0|unstable)/get_groups_publicised$ client_reader
12121219
^/_matrix/client/(api/v1|r0|unstable)/joined_groups$ client_reader

scripts/synapse_sytest.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,26 @@ cd "$(dirname $0)/.."
1616
mkdir /work
1717

1818
# PostgreSQL setup
19-
if [ -n "$MULTI_POSTGRES" ]; then
20-
# In this mode we want to run synapse against multiple split out databases.
21-
19+
if [ -n "$MULTI_POSTGRES" ] || [ -n "$POSTGRES" ]; then
2220
# We increase the max connections as we have more databases.
23-
echo -e "max_connections=1000" >> /var/run/postgresql/data/postgresql.conf
21+
sed -i -r "s/^max_connections.*$/max_connections = 500/" /var/run/postgresql/data/postgresql.conf
22+
23+
echo -e "fsync = off" >> /var/run/postgresql/data/postgresql.conf
24+
echo -e "full_page_writes = off" >> /var/run/postgresql/data/postgresql.conf
2425

2526
# Start the database
2627
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres
2728

29+
su -c psql postgres <<< "show config_file"
30+
su -c psql postgres <<< "show max_connections"
31+
su -c psql postgres <<< "show full_page_writes"
32+
su -c psql postgres <<< "show fsync"
33+
fi
34+
35+
# Now create the databases
36+
if [ -n "$MULTI_POSTGRES" ]; then
37+
# In this mode we want to run synapse against multiple split out databases.
38+
2839
# Make the test databases for the two Synapse servers that will be spun up
2940
su -c psql postgres <<EOF
3041
CREATE DATABASE pg1_main;
@@ -85,13 +96,11 @@ state_db:
8596
EOF
8697

8798
elif [ -n "$POSTGRES" ]; then
99+
# Env vars used by prep_sytest_for_postgres script.
88100
export PGUSER=postgres
89101
export POSTGRES_DB_1=pg1
90102
export POSTGRES_DB_2=pg2
91103

92-
# Start the database
93-
su -c 'eatmydata /usr/lib/postgresql/*/bin/pg_ctl -w -D $PGDATA start' postgres
94-
95104
# Write out the configuration for a PostgreSQL using Synapse
96105
./scripts/prep_sytest_for_postgres.sh
97106

tests/10apidoc/31room-state.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112

113113
do_request_json_for( $user,
114114
method => "GET",
115-
uri => "/unstable/rooms/$room_id/joined_members",
115+
uri => "/r0/rooms/$room_id/joined_members",
116116
)->then( sub {
117117
my ( $body ) = @_;
118118

@@ -220,7 +220,7 @@
220220

221221
do_request_json_for( $user,
222222
method => "GET",
223-
uri => "/unstable/joined_rooms",
223+
uri => "/r0/joined_rooms",
224224
)->then( sub {
225225
my ( $body ) = @_;
226226

tests/14account/01change-password.pl

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ sub matrix_set_password
8282
})->then_done(1);
8383
};
8484

85-
test "After changing password, a different session no longer works",
85+
test "After changing password, a different session no longer works by default",
8686
requires => [ local_user_fixture( password => $password ) ],
8787

8888
check => sub {
@@ -107,6 +107,38 @@ sub matrix_set_password
107107
})->then_done(1);
108108
};
109109

110+
test "After changing password, different sessions can optionally be kept",
111+
requires => [ local_user_fixture( password => $password ) ],
112+
113+
check => sub {
114+
my ( $user ) = @_;
115+
116+
my $other_login;
117+
118+
matrix_login_again_with_user( $user )->then( sub {
119+
( $other_login ) = @_;
120+
# ensure other login works to start with
121+
matrix_sync( $other_login );
122+
})->then( sub {
123+
do_request_json_for( $user,
124+
method => "POST",
125+
uri => "/r0/account/password",
126+
content => {
127+
auth => {
128+
type => "m.login.password",
129+
user => $user->user_id,
130+
password => $password,
131+
},
132+
new_password => "my new password",
133+
logout_devices => JSON::false,
134+
},
135+
);
136+
})->then( sub {
137+
# The access token should still be valid.
138+
matrix_sync( $other_login );
139+
})->then_done(1);
140+
};
141+
110142
test "Pushers created with a different access token are deleted on password change",
111143
requires => [ local_user_fixture( password => $password ) ],
112144

tests/30rooms/05aliases.pl

Lines changed: 123 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
}
9191
)->SyTest::pass_on_done( "m.room.canonical_alias accepts present aliases" );
9292
})->then( sub {
93+
# Create an unknown, but valid alias name.
9394
my $bad_alias = $room_alias =~ s/^#/#NOT-/r;
9495

9596
matrix_put_room_state( $user, $room_id,
@@ -99,6 +100,84 @@
99100
}
100101
)->main::expect_http_4xx
101102
->SyTest::pass_on_done( "m.room.canonical_alias rejects missing aliases" );
103+
})->then( sub {
104+
# Create an invalid alias name (starts with % instead of #).
105+
my $bad_alias = $room_alias =~ s/^#/%/r;
106+
107+
matrix_put_room_state( $user, $room_id,
108+
type => "m.room.canonical_alias",
109+
content => {
110+
alias => $bad_alias,
111+
}
112+
)->main::expect_http_4xx
113+
->SyTest::pass_on_done( "m.room.canonical_alias rejects invalid aliases" );
114+
});
115+
};
116+
117+
multi_test "Canonical alias can include alt_aliases",
118+
requires => [ local_user_fixture(), room_alias_name_fixture() ],
119+
120+
do => sub {
121+
my ( $user, $room_alias_name ) = @_;
122+
123+
my ( $room_id, $room_alias );
124+
125+
matrix_create_room( $user,
126+
room_alias_name => $room_alias_name,
127+
)->then( sub {
128+
( $room_id, $room_alias ) = @_;
129+
130+
matrix_put_room_state( $user, $room_id,
131+
type => "m.room.canonical_alias",
132+
content => {
133+
alias => $room_alias,
134+
alt_aliases => [ $room_alias ],
135+
}
136+
)->SyTest::pass_on_done( "m.room.canonical_alias accepts present aliases" );
137+
})->then( sub {
138+
# Create an unknown, but valid alias name.
139+
my $bad_alias = $room_alias =~ s/^#/#NOT-/r;
140+
141+
matrix_put_room_state( $user, $room_id,
142+
type => "m.room.canonical_alias",
143+
content => {
144+
alias => $room_alias,
145+
alt_aliases => [ $bad_alias ],
146+
}
147+
)->main::expect_matrix_error( 404, "M_NOT_FOUND" )
148+
->SyTest::pass_on_done( "m.room.canonical_alias rejects missing aliases" );
149+
})->then( sub {
150+
# Create an invalid alias name (starts with % instead of #).
151+
my $bad_alias = $room_alias =~ s/^#/%/r;
152+
153+
matrix_put_room_state( $user, $room_id,
154+
type => "m.room.canonical_alias",
155+
content => {
156+
alias => $room_alias,
157+
alt_aliases => [ $bad_alias ],
158+
}
159+
)->main::expect_matrix_error( 400, "M_INVALID_PARAM" )
160+
->SyTest::pass_on_done( "m.room.canonical_alias rejects invalid aliases" );
161+
})->then( sub {
162+
# Create a second room with an alias on it.
163+
my $other_alias_name = $room_alias_name . "2";
164+
165+
matrix_create_room( $user,
166+
room_alias_name => $other_alias_name,
167+
)->then( sub {
168+
my ( $other_room_id, $other_room_alias ) = @_;
169+
170+
# Attempt to set a canonical alias for the original room using an
171+
# alias from the second room.
172+
matrix_put_room_state( $user, $room_id,
173+
type => "m.room.canonical_alias",
174+
content => {
175+
alias => $room_alias,
176+
alt_aliases => [ $other_room_alias ],
177+
}
178+
)->main::expect_matrix_error( 400, "M_BAD_ALIAS" )
179+
->SyTest::pass_on_done( "m.room.canonical_alias rejects alias pointing to different room" );
180+
})
102181
});
103182
};
104183

@@ -135,8 +214,6 @@
135214
do => sub {
136215
my ( $creator, $other_user, $room_id, $alias ) = @_;
137216

138-
my $server_name = $other_user->http->server_name;
139-
140217
matrix_change_room_power_levels(
141218
$creator, $room_id, sub {
142219
$_[0]->{events}->{'m.room.aliases'} = 50;
@@ -169,8 +246,6 @@
169246
sub _test_can_create_and_delete_alias {
170247
my ( $room_id, $user, $alias ) = @_;
171248

172-
my $server_name = $user->http->server_name;
173-
174249
do_request_json_for( $user,
175250
method => "PUT",
176251
uri => "/r0/directory/room/$alias",
@@ -209,7 +284,6 @@ sub _test_can_create_and_delete_alias {
209284

210285
do => sub {
211286
my ( $user, $room_id, $other_user, $room_alias ) = @_;
212-
my $server_name = $user->http->server_name;
213287

214288
do_request_json_for( $user,
215289
method => "PUT",
@@ -226,6 +300,50 @@ sub _test_can_create_and_delete_alias {
226300
})
227301
};
228302

303+
test "Users with sufficient power-level can delete other's aliases",
304+
requires => [ $creator_fixture, local_user_fixture(), room_alias_fixture(),
305+
qw( can_create_room_alias )],
306+
307+
do => sub {
308+
my ( $user, $other_user, $room_alias ) = @_;
309+
my $room_id;
310+
311+
matrix_create_and_join_room(
312+
[ $user, $other_user ],
313+
)->then( sub {
314+
( $room_id ) = @_;
315+
316+
matrix_change_room_power_levels(
317+
$user, $room_id, sub {
318+
$_[0]->{users}->{$other_user->user_id} = 100;
319+
},
320+
)
321+
})->then( sub {
322+
do_request_json_for( $user,
323+
method => "PUT",
324+
uri => "/r0/directory/room/$room_alias",
325+
326+
content => { room_id => $room_id },
327+
)
328+
})->then( sub {
329+
do_request_json_for( $other_user,
330+
method => "DELETE",
331+
uri => "/r0/directory/room/$room_alias",
332+
333+
content => {},
334+
)
335+
})->then( sub {
336+
my ( $res ) = @_;
337+
log_if_fail "Unable to delete alias", $res;
338+
339+
do_request_json_for(
340+
$user,
341+
method => "GET",
342+
uri => "/r0/directory/room/$room_alias",
343+
);
344+
})->main::expect_http_404;
345+
};
346+
229347
test "Can delete canonical alias",
230348
requires => [ local_user_fixture( with_events => 0 ), room_alias_fixture(),
231349
qw( can_create_room_alias )],
@@ -275,7 +393,6 @@ sub _test_can_create_and_delete_alias {
275393

276394
do => sub {
277395
my ( $creator, $other_user, $room_alias ) = @_;
278-
my $server_name = $creator->http->server_name;
279396
my $room_id;
280397

281398
matrix_create_and_join_room( [ $creator, $other_user ] )
@@ -305,7 +422,6 @@ sub _test_can_create_and_delete_alias {
305422

306423
do => sub {
307424
my ( $creator, $other_user, $room_alias ) = @_;
308-
my $server_name = $creator->http->server_name;
309425
my $room_id;
310426

311427
matrix_create_and_join_room( [ $creator, $other_user ] )

0 commit comments

Comments
 (0)