From 7e3b798983fa11352fb19fe382b7a1217c8dbce3 Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Thu, 8 Jul 2021 17:22:38 -0300 Subject: Fix params with dashes Couple of endpoints were passing parameters with dash on the JSON body intead of an underscore. This fixes he following methods: - ban - unban - invite - kick --- t/20-client.t | 45 +++++++++++++++++++++++++++++++++++++++++++-- t/30-room.t | 31 ++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 3 deletions(-) (limited to 't') diff --git a/t/20-client.t b/t/20-client.t index c15d86f..5b46eb6 100644 --- a/t/20-client.t +++ b/t/20-client.t @@ -1,7 +1,7 @@ use lib 'lib'; use Test; use Matrix::Client; -plan 5; +plan 7; unless %*ENV { skip-rest 'No test server setted'; @@ -20,7 +20,20 @@ subtest 'creation' => { $client .= new(:$home-server, :$device-id); isnt $client.home-server, '', 'home server isnt empty'; isnt $client.device-id, '', 'device-id isnt empty'; - note $client.base-url; +} + +subtest 'register' => { + plan 2; + my Matrix::Client $new-user-client .= new(:$home-server, :$device-id); + my $new-username = ('a'..'z').pick(20).join; + lives-ok { + $new-user-client.register( + $new-username, + 'P4ssw0rd' + ); + }, 'can .register'; + + isnt $new-user-client.access-token, '', 'access-token setted'; } subtest 'login' => { @@ -95,3 +108,31 @@ subtest 'directory' => { message => /M_NOT_FOUND/, "Room not found after delete"; } + +subtest 'ban' => { + plan 2; + my Matrix::Client $new-user-client .= new(:$home-server); + my $new-username = ('a'..'z').pick(20).join; + $new-user-client.register($new-username, 'password'); + my $user-id = $new-user-client.whoami; + + my $room = $client.create-room( + :public, + :preset, + :name("The Grand Duke Pub"), + :topic("All about happy hour"), + :creation_content({ + "m.federate" => False + }) + ); + + $new-user-client.join-room($room.id); + + lives-ok { + $client.ban($room.id, $user-id, :reason) + }, 'can ban usernames'; + + lives-ok { + $client.unban($room.id, $user-id, :reason); + }, 'can unban'; +} diff --git a/t/30-room.t b/t/30-room.t index 7eb9dd7..f5b653e 100644 --- a/t/30-room.t +++ b/t/30-room.t @@ -1,7 +1,7 @@ use lib 'lib'; use Test; use Matrix::Client; -plan 12; +plan 14; use-ok 'Matrix::Client::Room'; @@ -107,3 +107,32 @@ subtest 'name' => { $test-room.leave; }; + +subtest 'ban' => { + plan 2; + my Matrix::Client $new-user-client .= new(:$home-server); + my $new-username = ('a'..'z').pick(20).join; + $new-user-client.register($new-username, 'password'); + $new-user-client.join-room($public-room-id); + my $user-id = $new-user-client.whoami; + + my $room = $client.create-room( + :public, + :preset, + :name("The Grand Duke Pub"), + :topic("All about happy hour"), + :creation_content({ + "m.federate" => False + }) + ); + + $new-user-client.join-room($room.id); + + lives-ok { + $room.ban($user-id, :reason) + }, 'can ban usernames'; + + lives-ok { + $room.unban($user-id, :reason); + }, 'can unban'; +} -- cgit v1.2.3-70-g09d2