Skip to content

Commit

Permalink
Add test for /admin/whois
Browse files Browse the repository at this point in the history
I accidentally pushed this to develop and reverted it.

Spec: matrix-org/matrix-spec-proposals#198
Synapse: matrix-org/synapse#418
  • Loading branch information
illicitonion committed Dec 3, 2015
1 parent b6135e2 commit 3d6037b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/48admin.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
test "/whois",
requires => [ $main::API_CLIENTS[0] ],

do => sub {
my ( $http ) = @_;

my $user;

# Register a user, rather than using a fixture, because we want to very
# tightly control the actions taken by that user.
# Conceivably this API may change based on the number of API calls the
# user made, for instance.
matrix_register_user( $http )
->then( sub {
( $user ) = @_;

do_request_json_for( $user,
method => "GET",
uri => "/api/v1/admin/whois/".$user->user_id,
)
})->then( sub {
my ( $body ) = @_;

assert_json_keys( $body, qw( devices user_id ) );
assert_eq( $body->{user_id}, $user->user_id, "user_id" );
assert_json_list( $body->{devices} );
assert_json_keys( $body->{devices}[0], "sessions" );
assert_json_list( $body->{devices}[0]{sessions} );
assert_json_keys( $body->{devices}[0]{sessions}[0], "connections" );
assert_json_list( $body->{devices}[0]{sessions}[0]{connections} );
assert_json_keys( $body->{devices}[0]{sessions}[0]{connections}[0], qw( ip last_seen user_agent ) );

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

0 comments on commit 3d6037b

Please sign in to comment.