Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2021-02-08 22:55:52 +0300
committerJoas Schilling <coding@schilljs.com>2021-06-11 10:07:29 +0300
commit7631251c99ec6ec552e0d9a915e12b3e68087b05 (patch)
tree212961f4ece0ade34dd91d3366653239430cc759 /tests
parent3b73e10ca482207bb24b2282ad4c93fb9004d5ed (diff)
Grant permissions in the HPB based on publishing permissions
When a participant does not have publishing permissions the HPB will block signaling messages related to establishing a connection, like sending the candidates. This would prevent participants using clients not supporting yet the publishing permissions (and thus still trying to publish even if they are not allowed to) from sending media in a call. Unfortunately the lack of permissions only prevents the connection from being established. If a participant is already sending media revoking the publishing permissions will not cause the connection to be stopped by the HPB. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/php/Controller/SignalingControllerTest.php109
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/php/Controller/SignalingControllerTest.php b/tests/php/Controller/SignalingControllerTest.php
index 47bf31571..8064d8026 100644
--- a/tests/php/Controller/SignalingControllerTest.php
+++ b/tests/php/Controller/SignalingControllerTest.php
@@ -29,6 +29,7 @@ use OCA\Talk\Events\SignalingEvent;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCA\Talk\Manager;
+use OCA\Talk\Model\Attendee;
use OCA\Talk\Model\AttendeeMapper;
use OCA\Talk\Model\SessionMapper;
use OCA\Talk\Participant;
@@ -384,7 +385,13 @@ class SignalingControllerTest extends \Test\TestCase {
->with($roomToken)
->willReturn($room);
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => Attendee::PUBLISHING_PERMISSIONS_ALL,
+ ]);
$participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
$room->expects($this->once())
->method('getParticipant')
->with($this->userId)
@@ -434,7 +441,13 @@ class SignalingControllerTest extends \Test\TestCase {
->with($roomToken)
->willReturn($room);
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => Attendee::PUBLISHING_PERMISSIONS_ALL,
+ ]);
$participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
$room->expects($this->once())
->method('getParticipant')
->with($this->userId)
@@ -484,7 +497,13 @@ class SignalingControllerTest extends \Test\TestCase {
->with($roomToken)
->willReturn($room);
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => Attendee::PUBLISHING_PERMISSIONS_ALL,
+ ]);
$participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
$participant->expects($this->once())
->method('hasModeratorPermissions')
->with(false)
@@ -540,7 +559,13 @@ class SignalingControllerTest extends \Test\TestCase {
->with($roomToken)
->willReturn($room);
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => Attendee::PUBLISHING_PERMISSIONS_ALL,
+ ]);
$participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
$room->expects($this->once())
->method('getParticipantBySession')
->with($sessionId)
@@ -591,7 +616,13 @@ class SignalingControllerTest extends \Test\TestCase {
->with($roomToken)
->willReturn($room);
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => Attendee::PUBLISHING_PERMISSIONS_ALL,
+ ]);
$participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
$room->expects($this->once())
->method('getParticipantBySession')
->with($sessionId)
@@ -632,6 +663,78 @@ class SignalingControllerTest extends \Test\TestCase {
], $result->getData());
}
+ public function dataBackendRoomUserPublicPublishingPermissions(): array {
+ return [
+ [Attendee::PUBLISHING_PERMISSIONS_NONE, []],
+ [Attendee::PUBLISHING_PERMISSIONS_AUDIO, ['publish-media']],
+ [Attendee::PUBLISHING_PERMISSIONS_VIDEO, ['publish-media']],
+ [Attendee::PUBLISHING_PERMISSIONS_VIDEO | Attendee::PUBLISHING_PERMISSIONS_VIDEO, ['publish-media']],
+ [Attendee::PUBLISHING_PERMISSIONS_SCREENSHARING, ['publish-screen']],
+ [Attendee::PUBLISHING_PERMISSIONS_AUDIO | Attendee::PUBLISHING_PERMISSIONS_SCREENSHARING, ['publish-media', 'publish-screen']],
+ [Attendee::PUBLISHING_PERMISSIONS_VIDEO | Attendee::PUBLISHING_PERMISSIONS_SCREENSHARING, ['publish-media', 'publish-screen']],
+ [Attendee::PUBLISHING_PERMISSIONS_AUDIO | Attendee::PUBLISHING_PERMISSIONS_VIDEO | Attendee::PUBLISHING_PERMISSIONS_SCREENSHARING, ['publish-media', 'publish-screen']],
+ ];
+ }
+
+ /**
+ * @dataProvider dataBackendRoomUserPublicPublishingPermissions
+ *
+ * @param int $publishingPermissions
+ * @param array $expectedBackendPermissions
+ */
+ public function testBackendRoomUserPublicPublishingPermissions(int $publishingPermissions, array $expectedBackendPermissions) {
+ $roomToken = 'the-room';
+ $roomName = 'the-room-name';
+ $room = $this->createMock(Room::class);
+ $this->manager->expects($this->once())
+ ->method('getRoomByToken')
+ ->with($roomToken)
+ ->willReturn($room);
+
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => $publishingPermissions,
+ ]);
+ $participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
+ $room->expects($this->once())
+ ->method('getParticipant')
+ ->with($this->userId)
+ ->willReturn($participant);
+ $room->expects($this->once())
+ ->method('getToken')
+ ->willReturn($roomToken);
+ $room->expects($this->once())
+ ->method('getPropertiesForSignaling')
+ ->with($this->userId)
+ ->willReturn([
+ 'name' => $roomName,
+ 'type' => Room::PUBLIC_CALL,
+ ]);
+
+ $result = $this->performBackendRequest([
+ 'type' => 'room',
+ 'room' => [
+ 'roomid' => $roomToken,
+ 'userid' => $this->userId,
+ 'sessionid' => '',
+ ],
+ ]);
+ $this->assertSame([
+ 'type' => 'room',
+ 'room' => [
+ 'version' => '1.0',
+ 'roomid' => $roomToken,
+ 'properties' => [
+ 'name' => $roomName,
+ 'type' => Room::PUBLIC_CALL,
+ ],
+ 'permissions' => $expectedBackendPermissions,
+ ],
+ ], $result->getData());
+ }
+
public function testBackendRoomAnonymousOneToOne() {
$roomToken = 'the-room';
$sessionId = 'the-session';
@@ -679,7 +782,13 @@ class SignalingControllerTest extends \Test\TestCase {
->with($roomToken)
->willReturn($room);
+ $attendee = Attendee::fromRow([
+ 'publishing_permissions' => Attendee::PUBLISHING_PERMISSIONS_ALL,
+ ]);
$participant = $this->createMock(Participant::class);
+ $participant->expects($this->any())
+ ->method('getAttendee')
+ ->willReturn($attendee);
$room->expects($this->once())
->method('getParticipant')
->with($this->userId)