Skip to content

Commit

Permalink
Merge pull request #132 from matrix-org/daniel/hashtagnofilter
Browse files Browse the repository at this point in the history
Allow empty responses instead of errors for filtered events
  • Loading branch information
illicitonion committed Jan 5, 2016
2 parents 1c15dc4 + 1e330b1 commit fb3f31b
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions tests/30rooms/60anonymousaccess.pl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
matrix_send_room_text_message( $user, $room_id, body => "mice" )
})->then( sub {
matrix_get_room_messages( $anonymous_user, $room_id, limit => "1" )
->main::expect_http_403;
});
})->followed_by( \&expect_4xx_or_empty_chunk );
};

test "Anonymous user can view world-readable rooms",
Expand Down Expand Up @@ -57,8 +56,7 @@
matrix_send_room_text_message( $user, $room_id, body => "mice" )
})->then( sub {
matrix_get_room_messages( $anonymous_user, $room_id, limit => "2" )
->main::expect_http_403;
});
})->followed_by( \&expect_4xx_or_empty_chunk );
};

test "Anonymous user cannot call /sync on non-world_readable room",
Expand Down Expand Up @@ -814,3 +812,29 @@ sub ignore_presence_for
)
} @events ];
}

sub expect_4xx_or_empty_chunk
{
my ( $f ) = @_;

$f->then( sub {
my ( $body ) = @_;

log_if_fail "Body", $body;

assert_json_keys( $body, qw( chunk ) );
assert_json_list( $body->{chunk} );
die "Want list to be empty" if @{ $body->{chunk} };

Future->done( 1 );
},
http => sub {
my ( undef, undef, $response ) = @_;

log_if_fail "HTTP Response", $response;

$response->code >= 400 and $response->code < 500 or die "want 4xx";

Future->done( 1 );
});
}

0 comments on commit fb3f31b

Please sign in to comment.