Skip to content

Tests for rejecting invites to unreachable servers#353

Merged
richvdh merged 6 commits into
developfrom
rav/reject_invite_to_unreachable_server
Apr 25, 2017
Merged

Tests for rejecting invites to unreachable servers#353
richvdh merged 6 commits into
developfrom
rav/reject_invite_to_unreachable_server

Conversation

@richvdh
Copy link
Copy Markdown
Member

@richvdh richvdh commented Apr 21, 2017

No description provided.

richvdh added 4 commits April 20, 2017 23:59
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.
@richvdh
Copy link
Copy Markdown
Member Author

richvdh commented Apr 24, 2017

retest this please

Comment thread 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 {
Copy link
Copy Markdown
Contributor

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.

Comment thread tests/50federation/00prepare.pl Outdated
my $server = SyTest::Federation::Server->new;
$loop->add( $server );

require IO::Async::SSL;
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread tests/50federation/35room-invite.pl Outdated
matrix_sync( $user );
})->then( sub {
my ( $body ) = @_;
foreach my $error_code (403, 500, -1) {
Copy link
Copy Markdown
Contributor

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 )

Comment thread tests/50federation/35room-invite.pl Outdated
},
teardown => sub {
my ($server) = @_;
$server -> close();
Copy link
Copy Markdown
Contributor

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();

Comment thread tests/50federation/35room-invite.pl Outdated

invite_server( $room, $creator_id, $user, $federation_server )
->then( sub {
if ($error_code < 0) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if( $error_code < 0 ) {

Comment thread tests/50federation/35room-invite.pl Outdated
$federation_server->close();

return matrix_leave_room( $user, $room_id );
} else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncuddle the else

}
else {

Comment thread 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" ),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace

( $error_code ...

@leonerd
Copy link
Copy Markdown
Contributor

leonerd commented Apr 25, 2017

Semantically seems good; even commented to say why each test needs its own server :)

Just needs some small formatting fixes.

Formatting fixes
@leonerd
Copy link
Copy Markdown
Contributor

leonerd commented Apr 25, 2017

LGTM

@richvdh richvdh merged commit 3fceff7 into develop Apr 25, 2017
@richvdh
Copy link
Copy Markdown
Member Author

richvdh commented Apr 25, 2017

ta

@richvdh richvdh deleted the rav/reject_invite_to_unreachable_server branch April 25, 2017 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants