Skip to content

Commit

Permalink
keys/query should include device display name
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Aug 3, 2016
1 parent 54d74b0 commit b878e1c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/10apidoc/12device_management.pl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
our @EXPORT = qw( matrix_get_device );
our @EXPORT = qw( matrix_get_device matrix_set_device_display_name );

sub matrix_get_device {
my ( $user, $device_id ) = @_;
Expand All @@ -10,6 +10,19 @@ sub matrix_get_device {
);
}

sub matrix_set_device_display_name {
my ( $user, $device_id, $display_name ) = @_;

return do_request_json_for(
$user,
method => "PUT",
uri => "/unstable/devices/${device_id}",
content => {
display_name => $display_name,
},
);
}

test "GET /device/{deviceId}",
requires => [ local_user_fixture( with_events => 0 ) ],

Expand Down
15 changes: 15 additions & 0 deletions tests/41end-to-end-keys/01-upload-key.pl
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,29 @@
)->then( sub {
my ( $content ) = @_;

log_if_fail( "/query response", $content );

assert_json_keys( $content, "device_keys" );

my $device_keys = $content->{device_keys};
assert_json_keys( $device_keys, $user->user_id );

my $alice_keys = $device_keys->{ $user->user_id };
assert_json_keys( $alice_keys, $user->device_id );

my $alice_device_keys = $alice_keys->{ $user->device_id };
assert_json_keys( $alice_device_keys, "unsigned" );

my $unsigned = $alice_device_keys->{unsigned};

# display_name should be null by default
exists $unsigned->{device_display_name} or
die "Expected to get a (null) device_display_name";
defined $unsigned->{device_display_name} and
die "Device display name was unexpectedly defined.";

# TODO: Check that the content matches what we uploaded.

Future->done(1)
})
};
Expand Down
9 changes: 9 additions & 0 deletions tests/41end-to-end-keys/04-query-key-federation.pl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
matrix_put_e2e_keys( $user )
->SyTest::pass_on_done( "Uploaded key" )
->then( sub {
matrix_set_device_display_name( $user, $user->device_id, "test display name" ),
})->then( sub {
do_request_json_for( $remote_user,
method => "POST",
uri => "/unstable/keys/query/",
Expand All @@ -27,7 +29,14 @@

my $alice_keys = $device_keys->{ $user->user_id };
assert_json_keys( $alice_keys, $user->device_id );

my $alice_device_keys = $alice_keys->{ $user->device_id };

# TODO: Check that the content matches what we uploaded.

assert_eq( $alice_device_keys->{"unsigned"}->{"device_display_name"},
"test display name" );

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

0 comments on commit b878e1c

Please sign in to comment.