From c0c73d1e4998aef30ed93431afd1f526acb18d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Thu, 5 Mar 2020 20:41:29 +0100 Subject: Send participant permissions to the external signaling server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to filter control messages the external signaling server needs to know the permissions of each participant. Those permissions need to be set when the participant joins the room or if the participant type is changed. All participants should have permissions to publish media and screen, but only logged in moderators should have permission to send control messages. Signed-off-by: Daniel Calviño Sánchez --- tests/php/Signaling/BackendNotifierTest.php | 95 ++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 2 deletions(-) (limited to 'tests/php/Signaling/BackendNotifierTest.php') diff --git a/tests/php/Signaling/BackendNotifierTest.php b/tests/php/Signaling/BackendNotifierTest.php index a2f6bcbe4..37676eabf 100644 --- a/tests/php/Signaling/BackendNotifierTest.php +++ b/tests/php/Signaling/BackendNotifierTest.php @@ -562,6 +562,7 @@ class BackendNotifierTest extends \Test\TestCase { 'participants' => [ 'changed' => [ [ + 'permissions' => ['publish-media', 'publish-screen', 'control'], 'inCall' => 0, 'lastPing' => 0, 'sessionId' => $userSession, @@ -595,6 +596,7 @@ class BackendNotifierTest extends \Test\TestCase { 'participants' => [ 'changed' => [ [ + 'permissions' => ['publish-media', 'publish-screen'], 'inCall' => 0, 'lastPing' => 0, 'sessionId' => $guestSession, @@ -624,8 +626,8 @@ class BackendNotifierTest extends \Test\TestCase { $room->addUsers([ 'userId' => $notJoinedUserId, ]); - $participant = $room->getParticipant($notJoinedUserId); - $room->setParticipantType($participant, Participant::MODERATOR); + $notJoinedParticipant = $room->getParticipant($notJoinedUserId); + $room->setParticipantType($notJoinedParticipant, Participant::MODERATOR); $requests = $this->controller->getRequests(); $bodies = array_map(function($request) use ($room) { @@ -660,6 +662,95 @@ class BackendNotifierTest extends \Test\TestCase { ], ], ], $bodies); + + $this->controller->clearRequests(); + $room->setParticipantType($participant, Participant::USER); + + $requests = $this->controller->getRequests(); + $bodies = array_map(function($request) use ($room) { + return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); + }, $requests); + $this->assertContains([ + 'type' => 'participants', + 'participants' => [ + 'changed' => [ + [ + 'permissions' => ['publish-media', 'publish-screen'], + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => $userSession, + 'participantType' => Participant::USER, + 'userId' => $this->userId, + ], + ], + 'users' => [ + [ + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => $userSession, + 'participantType' => Participant::USER, + 'userId' => $this->userId, + ], + [ + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => 0, + 'participantType' => Participant::MODERATOR, + 'userId' => $notJoinedUserId, + ], + [ + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => $guestSession, + 'participantType' => Participant::GUEST_MODERATOR, + ], + ], + ], + ], $bodies); + + $this->controller->clearRequests(); + $room->setParticipantType($guestParticipant, Participant::GUEST); + + $requests = $this->controller->getRequests(); + $bodies = array_map(function($request) use ($room) { + return json_decode($this->validateBackendRequest($this->baseUrl . '/api/v1/room/' . $room->getToken(), $request), true); + }, $requests); + $this->assertContains([ + 'type' => 'participants', + 'participants' => [ + 'changed' => [ + [ + 'permissions' => ['publish-media', 'publish-screen'], + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => $guestSession, + 'participantType' => Participant::GUEST, + ], + ], + 'users' => [ + [ + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => $userSession, + 'participantType' => Participant::USER, + 'userId' => $this->userId, + ], + [ + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => 0, + 'participantType' => Participant::MODERATOR, + 'userId' => $notJoinedUserId, + ], + [ + 'inCall' => 0, + 'lastPing' => 0, + 'sessionId' => $guestSession, + 'participantType' => Participant::GUEST, + ], + ], + ], + ], $bodies); } } -- cgit v1.2.3