Skip to content
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

Merged
merged 6 commits into from
Apr 25, 2017

Conversation

richvdh
Copy link
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
Member Author

richvdh commented Apr 24, 2017

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 {
Copy link
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.

my $server = SyTest::Federation::Server->new;
$loop->add( $server );

require IO::Async::SSL;
Copy link
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
Member Author

Choose a reason for hiding this comment

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

matrix_sync( $user );
})->then( sub {
my ( $body ) = @_;
foreach my $error_code (403, 500, -1) {
Copy link
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 )

},
teardown => sub {
my ($server) = @_;
$server -> close();
Copy link
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();


invite_server( $room, $creator_id, $user, $federation_server )
->then( sub {
if ($error_code < 0) {
Copy link
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 ) {

$federation_server->close();

return matrix_leave_room( $user, $room_id );
} else {
Copy link
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 {

});
};
test "Inbound federation can receive invite and reject when "
. ($error_code >= 0 ? "remote replies with a $error_code" : "is unreachable" ),
Copy link
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
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
Contributor

leonerd commented Apr 25, 2017

LGTM

@richvdh richvdh merged commit 3fceff7 into develop Apr 25, 2017
@richvdh
Copy link
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