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 |
| 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.
{ wants to be on its own line for new toplevel functions.
| my $server = SyTest::Federation::Server->new; | ||
| $loop->add( $server ); | ||
|
|
||
| require IO::Async::SSL; |
There was a problem hiding this comment.
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.
mmkay. I was just cargo-culting the original (https://github.com/matrix-org/sytest/pull/353/files#diff-ae1f9e915c208806589880fe9bd6e5f5L21). Moved anyway.
| matrix_sync( $user ); | ||
| })->then( sub { | ||
| my ( $body ) = @_; | ||
| foreach my $error_code (403, 500, -1) { |
There was a problem hiding this comment.
Wants whitespace inside parens
( 403, 500, -1 )
| }, | ||
| teardown => sub { | ||
| my ($server) = @_; | ||
| $server -> close(); |
There was a problem hiding this comment.
No spaces around ->
$server->close();
|
|
||
| invite_server( $room, $creator_id, $user, $federation_server ) | ||
| ->then( sub { | ||
| if ($error_code < 0) { |
| $federation_server->close(); | ||
|
|
||
| return matrix_leave_room( $user, $room_id ); | ||
| } else { |
There was a problem hiding this comment.
Uncuddle the else
}
else {
| }); | ||
| }; | ||
| 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.
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.