Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v1.10.0' into dinsic-rel…
Browse files Browse the repository at this point in the history
…ease-v1.10.x

* origin/release-v1.10.0:
  remove checks on m.room.aliases (#801)
  Remove test which uses unspecced /events?dir=b (#794)
  Add some tests to check for adding/removing aliases (#792)
  Add test for ensuring power levels are correctly handled during upgrade (#777)
  Test that fetching device correctly resyncs (#791)
  Add support for experimental MSC2260 room version (#790)
  Fix power levels being sent as strings (#789)
  Don't respond with 503 as server will be marked as down. (#788)
  Test Synapse with MAU limits enabled. (#782)
  Fix docker/push.sh and make it echo commands
  Change postgres in docker image to use C collation/ctype. (#783)
  Add a passing test for recovery from gappy device list updates (#761)
  • Loading branch information
anoadragon453 committed Mar 23, 2020
2 parents cd14cbb + a954cc2 commit e9221c3
Show file tree
Hide file tree
Showing 11 changed files with 520 additions and 131 deletions.
4 changes: 2 additions & 2 deletions docker/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUN dos2unix /bootstrap.sh
ENV PGHOST=/var/run/postgresql
ENV PGDATA=$PGHOST/data
ENV PGUSER=postgres
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="en_US.UTF-8" --lc-ctype="en_US.UTF-8" --username=postgres' postgres; done
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

# Turn off all the fsync stuff for postgres
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
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
2 changes: 1 addition & 1 deletion docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /usr/bin/env bash

set -e
set -ex

cd $(dirname $0)
docker build --pull ../ -f Dockerfile -t matrixdotorg/sytest:dinsic
Expand Down
4 changes: 2 additions & 2 deletions docker/push.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -e
set -ex

cd $(dirname $0)

Expand All @@ -11,5 +11,5 @@ docker push matrixdotorg/sytest-synapse:py35
docker push matrixdotorg/sytest-synapse:py37
docker push matrixdotorg/sytest-synapse:py38
docker push matrixdotorg/sytest-dendrite:latest
docker push matrixdotorg/sytest-dendrite:go110
docker push matrixdotorg/sytest-dendrite:go111
docker push matrixdotorg/sytest-dendrite:go113
5 changes: 4 additions & 1 deletion lib/SyTest/Federation/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use SyTest::Assertions qw( :all );

use URI::Escape qw( uri_escape );

use constant SUPPORTED_ROOM_VERSIONS => [1, 2, 3, 4, 5];
use constant SUPPORTED_ROOM_VERSIONS => [qw(
1 2 3 4 5
org.matrix.msc2260
)];

sub configure
{
Expand Down
6 changes: 6 additions & 0 deletions lib/SyTest/Homeserver/Synapse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ sub start
},
) : (),

# We use a high limit so the limit is never reached, but enabling the
# limit ensures that the code paths get hit. This helps testing the
# feature with worker mode.
limit_usage_by_mau => "true",
max_mau_value => 50000000,

map {
defined $self->{$_} ? ( $_ => $self->{$_} ) : ()
} qw(
Expand Down
5 changes: 3 additions & 2 deletions tests/10apidoc/34room-messages.pl
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ sub matrix_send_room_message
content => $opts{content},
)->then( sub {
my ( $body ) = @_;

Future->done( $body->{event_id} );
my ( $event_id ) = $body->{event_id};
log_if_fail "Sent '$type' event in $room_id: $event_id";
Future->done( $event_id );
});
}

Expand Down
119 changes: 104 additions & 15 deletions tests/30rooms/05aliases.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
my $room_alias;

my $creator_fixture = local_user_fixture();
my $second_user_fixture = local_user_fixture();

my $room_fixture = room_fixture( $creator_fixture );

Expand Down Expand Up @@ -101,31 +102,119 @@
});
};

test "Creators can delete alias",
requires => [ $creator_fixture, $room_fixture, room_alias_fixture(),
qw( can_create_room_alias )],
test "Regular users can add and delete aliases in the default room configuration",
requires => [
$creator_fixture, $second_user_fixture,
magic_room_fixture(
requires_users => [ $creator_fixture, $second_user_fixture, ]
),
room_alias_fixture(),
qw( can_create_room_alias ),
],

proves => [qw( can_delete_room_alias )],

do => sub {
my ( $user, $room_id, $room_alias ) = @_;
my $server_name = $user->http->server_name;
my ( $creator, $other_user, $room_id, $room_alias ) = @_;
_test_can_create_and_delete_alias( $room_id, $other_user, $room_alias );
};

do_request_json_for( $user,
method => "PUT",
uri => "/r0/directory/room/$room_alias",

content => { room_id => $room_id },
test "Regular users can add and delete aliases when m.room.aliases is restricted",
requires => [
$creator_fixture, $second_user_fixture,
magic_room_fixture(
requires_users => [ $creator_fixture, $second_user_fixture, ],
),
room_alias_fixture(),
qw( can_delete_room_alias ),
],

proves => [qw( can_delete_room_alias )],

do => sub {
my ( $creator, $other_user, $room_id, $alias ) = @_;

my $server_name = $other_user->http->server_name;

matrix_change_room_power_levels(
$creator, $room_id, sub {
$_[0]->{events}->{'m.room.aliases'} = 50;
},
)->then( sub {
do_request_json_for( $user,
method => "DELETE",
uri => "/r0/directory/room/$room_alias",
matrix_get_room_state( $creator, $room_id,
type => "m.room.power_levels",
);
})->then( sub {
my ( $body ) = @_;
log_if_fail "power levels", $body;

content => {},
)
})
assert_eq( $body->{events}->{'m.room.aliases'}, 50 );

do_request_json_for( $other_user,
method => "PUT",
uri => "/r0/directory/room/$alias",
content => { room_id => $room_id },
);
})->then( sub {
do_request_json_for( $other_user,
method => "DELETE",
uri => "/r0/directory/room/$alias",
content => {},
);
});
};


sub _test_can_create_and_delete_alias {
my ( $room_id, $user, $alias ) = @_;

my $server_name = $user->http->server_name;

do_request_json_for( $user,
method => "PUT",
uri => "/r0/directory/room/$alias",

content => { room_id => $room_id },
)->then( sub {
matrix_get_room_state( $user, $room_id,
type => "m.room.aliases",
state_key => $server_name,
)
})->then( sub {
my ( $body ) = @_;

log_if_fail "Aliases after adding alias", $body;

assert_json_keys( $body, qw( aliases ) );
assert_json_list( my $aliases = $body->{aliases} );

any { $_ eq $alias } @$aliases or die "Expected alias to be in list";

do_request_json_for( $user,
method => "DELETE",
uri => "/r0/directory/room/$alias",

content => {},
)
})->then( sub {
matrix_get_room_state( $user, $room_id,
type => "m.room.aliases",
state_key => $server_name,
)
})->then( sub {
my ( $body ) = @_;

log_if_fail "Aliases after deleting alias", $body;
assert_json_keys( $body, qw( aliases ) );
assert_json_list( my $aliases = $body->{aliases} );

none { $_ eq $alias } @$aliases or die "Expected alias to not be in list";

Future->done;
});
}

test "Deleting a non-existent alias should return a 404",
requires => [ $creator_fixture, room_alias_fixture(),
qw( can_delete_room_alias ) ],
Expand Down
67 changes: 2 additions & 65 deletions tests/30rooms/30history-visibility.pl
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ sub test_history_visibility
}

foreach my $i (
[ "Guest", sub { guest_user_fixture( with_events => 1 ) } ],
[ "Real", sub { local_user_fixture( with_events => 1 ) } ]
[ "Guest", sub { guest_user_fixture() } ],
[ "Real", sub { local_user_fixture() } ]
) {
my ( $name, $fixture ) = @$i;

Expand Down Expand Up @@ -241,42 +241,6 @@ sub test_history_visibility
},
);

test(
"$name non-joined user doesn't get events before room made world_readable",

requires => [ $fixture->(), local_user_fixture( with_events => 1 ) ],

do => sub {
my ( $nonjoined_user, $user ) = @_;

my $room_id;

matrix_create_and_join_room( [ $user ] )
->then( sub {
( $room_id ) = @_;

matrix_send_room_text_message( $user, $room_id, body => "private" );
})->then( sub {
matrix_set_room_history_visibility_synced( $user, $room_id, "world_readable" );
})->then( sub {
Future->needs_all(
matrix_send_room_text_message( $user, $room_id, body => "public" ),

# The client is allowed to see exactly two events, the
# m.room.history_visibility event and the public message.
# The server is free to return these in separate calls to
# /events, so we try at most two times to get the events we expect.
check_events( $nonjoined_user, $room_id )
->then( sub {
Future->done(1);
}, sub {
check_events( $nonjoined_user, $room_id );
}),
);
});
},
);

# /state

test(
Expand Down Expand Up @@ -584,33 +548,6 @@ sub test_history_visibility
})
};

sub check_events
{
my ( $user, $room_id ) = @_;

matrix_get_events( $user, limit => 3, dir => "b", room_id => $room_id )
->then( sub {
my ( $body ) = @_;

log_if_fail "Body", $body;

assert_json_keys( $body, qw( chunk ) );
@{ $body->{chunk} } >= 1 or die "Want at least one event";
@{ $body->{chunk} } < 3 or die "Want at most two events";

my $found = 0;
foreach my $event ( @{ $body->{chunk} } ) {
next if !exists $event->{content};
next if !exists $event->{content}{body};

$found = 1 if $event->{content}{body} eq "public";
die "Should not have found private" if $event->{content}{body} eq "private";
}

Future->done( $found );
}),
}

sub ignore_presence_for
{
my ( $ignored_users, @events ) = @_;
Expand Down
Loading

0 comments on commit e9221c3

Please sign in to comment.