-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests for rejecting invites to unreachable servers #353
Conversation
It can figure out some of its parameters itself, so we can avoid some duplication.
Allow tests to spin up their own federation servers, so that they can do nefarious things with them
to avoid our server getting blacklisted and affecting later tests.
retest this please |
tests/50federation/00prepare.pl
Outdated
push our @EXPORT, qw( INBOUND_SERVER OUTBOUND_CLIENT ); | ||
push our @EXPORT, qw( INBOUND_SERVER OUTBOUND_CLIENT create_federation_server ); | ||
|
||
sub create_federation_server { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{
wants to be on its own line for new toplevel functions.
tests/50federation/00prepare.pl
Outdated
my $server = SyTest::Federation::Server->new; | ||
$loop->add( $server ); | ||
|
||
require IO::Async::SSL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably no need to hide this require
within a function; just move it to toplevel at the start of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmkay. I was just cargo-culting the original (https://github.com/matrix-org/sytest/pull/353/files#diff-ae1f9e915c208806589880fe9bd6e5f5L21). Moved anyway.
tests/50federation/35room-invite.pl
Outdated
matrix_sync( $user ); | ||
})->then( sub { | ||
my ( $body ) = @_; | ||
foreach my $error_code (403, 500, -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wants whitespace inside parens
( 403, 500, -1 )
tests/50federation/35room-invite.pl
Outdated
}, | ||
teardown => sub { | ||
my ($server) = @_; | ||
$server -> close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No spaces around ->
$server->close();
tests/50federation/35room-invite.pl
Outdated
|
||
invite_server( $room, $creator_id, $user, $federation_server ) | ||
->then( sub { | ||
if ($error_code < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if( $error_code < 0 ) {
tests/50federation/35room-invite.pl
Outdated
$federation_server->close(); | ||
|
||
return matrix_leave_room( $user, $room_id ); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncuddle the else
}
else {
tests/50federation/35room-invite.pl
Outdated
}); | ||
}; | ||
test "Inbound federation can receive invite and reject when " | ||
. ($error_code >= 0 ? "remote replies with a $error_code" : "is unreachable" ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whitespace
( $error_code ...
Semantically seems good; even commented to say why each test needs its own server :) Just needs some small formatting fixes. |
Formatting fixes
LGTM |
ta |
No description provided.