diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-02-08 13:42:31 +0100 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2023-02-22 13:09:26 +0100 |
commit | 87b20311b0ae075c0a99a09b24a10b0aa3706351 (patch) | |
tree | 1e2a4a74396cdc584b87bf9f2eb3614d4fa9aaaa /tests | |
parent | 3a397142c247c2d1acbb56999965c4e8eedbefc1 (diff) |
Include participant in start/stop requests to the recording server
The participant will be in turn forwarded again to the Nextcloud server
once notified that the recording started or stopped so it retains the
proper participant (for example, in system messages) rather than using
the recording server.
The actor is optional when stopping the recording, as the recording
could be implicitly stopped when the last participant leaves the call.
Nevertheless, this causes the system message to be assigned to a guest
(as the request comes from the recording server), which is unexpected,
so this may need to be adjusted.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/RecordingTrait.php | 22 | ||||
-rw-r--r-- | tests/integration/features/callapi/recording.feature | 54 | ||||
-rw-r--r-- | tests/php/Recording/BackendNotifierTest.php | 62 |
3 files changed, 107 insertions, 31 deletions
diff --git a/tests/integration/features/bootstrap/RecordingTrait.php b/tests/integration/features/bootstrap/RecordingTrait.php index 7b6db6aac..edb096fce 100644 --- a/tests/integration/features/bootstrap/RecordingTrait.php +++ b/tests/integration/features/bootstrap/RecordingTrait.php @@ -69,9 +69,9 @@ trait RecordingTrait { } /** - * @When /^recording server sent started request for "(audio|video)" recording in room "([^"]*)" with (\d+)(?: \((v1)\))?$/ + * @When /^recording server sent started request for "(audio|video)" recording in room "([^"]*)" as "([^"]*)" with (\d+)(?: \((v1)\))?$/ */ - public function recordingServerSentStartedRequestForRecordingInRoomWith(string $recordingType, string $identifier, int $statusCode, string $apiVersion = 'v1') { + public function recordingServerSentStartedRequestForRecordingInRoomAsWith(string $recordingType, string $identifier, string $user, int $statusCode, string $apiVersion = 'v1') { $recordingTypes = [ 'video' => 1, 'audio' => 2, @@ -82,6 +82,10 @@ trait RecordingTrait { 'started' => [ 'token' => FeatureContext::getTokenForIdentifier($identifier), 'status' => $recordingTypes[$recordingType], + 'actor' => [ + 'type' => 'users', + 'id' => $user, + ], ], ]; @@ -92,6 +96,13 @@ trait RecordingTrait { * @When /^recording server sent stopped request for recording in room "([^"]*)" with (\d+)(?: \((v1)\))?$/ */ public function recordingServerSentStoppedRequestForRecordingInRoomWith(string $identifier, int $statusCode, string $apiVersion = 'v1') { + $this->recordingServerSentStoppedRequestForRecordingInRoomAsWith($identifier, null, $statusCode, $apiVersion); + } + + /** + * @When /^recording server sent stopped request for recording in room "([^"]*)" as "([^"]*)" with (\d+)(?: \((v1)\))?$/ + */ + public function recordingServerSentStoppedRequestForRecordingInRoomAsWith(string $identifier, ?string $user, int $statusCode, string $apiVersion = 'v1') { $data = [ 'type' => 'stopped', 'stopped' => [ @@ -99,6 +110,13 @@ trait RecordingTrait { ], ]; + if ($user !== null) { + $data['stopped']['actor'] = [ + 'type' => 'users', + 'id' => $user, + ]; + } + $this->sendBackendRequestFromRecordingServer($data, $statusCode, $apiVersion); } diff --git a/tests/integration/features/callapi/recording.feature b/tests/integration/features/callapi/recording.feature index 1aa815a79..eff03accd 100644 --- a/tests/integration/features/callapi/recording.feature +++ b/tests/integration/features/callapi/recording.feature @@ -15,11 +15,11 @@ Feature: callapi/recording When user "participant1" starts "video" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":1,"owner":"participant1"}} | + | room1 | {"type":"start","start":{"status":1,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 0 | - And recording server sent started request for "video" recording in room "room1" with 200 + And recording server sent started request for "video" recording in room "room1" as "participant1" with 200 Then user "participant1" sees the following system messages in room "room1" with 200 (v1) | room | actorType | actorId | actorDisplayName | systemMessage | | room1 | users | participant1 | participant1-displayname | recording_started | @@ -31,11 +31,11 @@ Feature: callapi/recording When user "participant1" stops recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"stop"} | + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 1 | - And recording server sent stopped request for recording in room "room1" with 200 + And recording server sent stopped request for recording in room "room1" as "participant1" with 200 Then user "participant1" sees the following system messages in room "room1" with 200 (v1) | room | actorType | actorId | actorDisplayName | systemMessage | | room1 | users | participant1 | participant1-displayname | recording_stopped | @@ -58,11 +58,11 @@ Feature: callapi/recording When user "participant1" starts "audio" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":2,"owner":"participant1"}} | + | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 0 | - And recording server sent started request for "audio" recording in room "room1" with 200 + And recording server sent started request for "audio" recording in room "room1" as "participant1" with 200 Then user "participant1" sees the following system messages in room "room1" with 200 (v1) | room | actorType | actorId | actorDisplayName | systemMessage | | room1 | users | participant1 | participant1-displayname | audio_recording_started | @@ -74,11 +74,11 @@ Feature: callapi/recording When user "participant1" stops recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"stop"} | + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 2 | - And recording server sent stopped request for recording in room "room1" with 200 + And recording server sent stopped request for recording in room "room1" as "participant1" with 200 Then user "participant1" sees the following system messages in room "room1" with 200 (v1) | room | actorType | actorId | actorDisplayName | systemMessage | | room1 | users | participant1 | participant1-displayname | audio_recording_stopped | @@ -101,12 +101,12 @@ Feature: callapi/recording When user "participant1" starts "audio" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":2,"owner":"participant1"}} | + | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | And user "participant1" starts "audio" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":2,"owner":"participant1"}} | - And recording server sent started request for "audio" recording in room "room1" with 200 + | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | + And recording server sent started request for "audio" recording in room "room1" as "participant1" with 200 And user "participant1" starts "audio" recording in room "room1" with 400 (v1) Then the response error matches with "recording" And recording server received the following requests @@ -116,12 +116,12 @@ Feature: callapi/recording When user "participant1" stops recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"stop"} | + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | And user "participant1" stops recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"stop"} | - And recording server sent stopped request for recording in room "room1" with 200 + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | + And recording server sent stopped request for recording in room "room1" as "participant1" with 200 And user "participant1" stops recording in room "room1" with 200 (v1) Then recording server received the following requests And user "participant1" is participant of the following unordered rooms (v4) @@ -130,12 +130,12 @@ Feature: callapi/recording When user "participant1" starts "video" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":1,"owner":"participant1"}} | + | room1 | {"type":"start","start":{"status":1,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | And user "participant1" starts "video" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":1,"owner":"participant1"}} | - And recording server sent started request for "video" recording in room "room1" with 200 + | room1 | {"type":"start","start":{"status":1,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | + And recording server sent started request for "video" recording in room "room1" as "participant1" with 200 And user "participant1" starts "video" recording in room "room1" with 400 (v1) Then the response error matches with "recording" And recording server received the following requests @@ -145,12 +145,12 @@ Feature: callapi/recording When user "participant1" stops recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"stop"} | + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | And user "participant1" stops recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"stop"} | - And recording server sent stopped request for recording in room "room1" with 200 + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | + And recording server sent stopped request for recording in room "room1" as "participant1" with 200 And user "participant1" stops recording in room "room1" with 200 (v1) Then recording server received the following requests And user "participant1" is participant of the following unordered rooms (v4) @@ -256,19 +256,19 @@ Feature: callapi/recording And user "participant1" starts "audio" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":2,"owner":"participant1"}} | - And recording server sent started request for "audio" recording in room "room1" with 200 + | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | + And recording server sent started request for "audio" recording in room "room1" as "participant1" with 200 And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 2 | When user "participant1" ends call "room1" with 200 (v4) Then recording server received the following requests | token | data | - | room1 | {"type":"stop"} | + | room1 | {"type":"stop","stop":{"actor":{"type":"users","id":"participant1"}}} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 2 | - And recording server sent stopped request for recording in room "room1" with 200 + And recording server sent stopped request for recording in room "room1" as "participant1" with 200 And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 0 | @@ -285,15 +285,15 @@ Feature: callapi/recording And user "participant1" starts "audio" recording in room "room1" with 200 (v1) And recording server received the following requests | token | data | - | room1 | {"type":"start","start":{"status":2,"owner":"participant1"}} | - And recording server sent started request for "audio" recording in room "room1" with 200 + | room1 | {"type":"start","start":{"status":2,"owner":"participant1","actor":{"type":"users","id":"participant1"}}} | + And recording server sent started request for "audio" recording in room "room1" as "participant1" with 200 And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 2 | When user "participant1" leaves room "room1" with 200 (v4) Then recording server received the following requests | token | data | - | room1 | {"type":"stop"} | + | room1 | {"type":"stop","stop":[]} | And user "participant1" is participant of the following unordered rooms (v4) | type | name | callRecording | | 2 | room1 | 2 | diff --git a/tests/php/Recording/BackendNotifierTest.php b/tests/php/Recording/BackendNotifierTest.php index cbfc42aec..5aefd4d9a 100644 --- a/tests/php/Recording/BackendNotifierTest.php +++ b/tests/php/Recording/BackendNotifierTest.php @@ -31,6 +31,7 @@ use OCA\Talk\Model\SessionMapper; use OCA\Talk\Recording\BackendNotifier; use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; +use OCA\Talk\Service\RoomService; use OCA\Talk\TalkSession; use OCP\App\IAppManager; use OCP\AppFramework\Utility\ITimeFactory; @@ -39,6 +40,7 @@ use OCP\Http\Client\IClientService; use OCP\IGroupManager; use OCP\IL10N; use OCP\IURLGenerator; +use OCP\IUser; use OCP\IUserManager; use OCP\Security\IHasher; use OCP\Security\ISecureRandom; @@ -75,6 +77,8 @@ class BackendNotifierTest extends TestCase { private $urlGenerator; private ?\OCA\Talk\Tests\php\Recording\CustomBackendNotifier $backendNotifier = null; + /** @var ParticipantService|MockObject */ + private $participantService; private ?Manager $manager = null; private ?string $recordingSecret = null; @@ -107,6 +111,8 @@ class BackendNotifierTest extends TestCase { $this->recreateBackendNotifier(); + $this->participantService = \OC::$server->get(ParticipantService::class); + $dbConnection = \OC::$server->getDatabaseConnection(); $this->manager = new Manager( $dbConnection, @@ -115,7 +121,7 @@ class BackendNotifierTest extends TestCase { \OC::$server->get(IAppManager::class), \OC::$server->get(AttendeeMapper::class), \OC::$server->get(SessionMapper::class), - $this->createMock(ParticipantService::class), + $this->participantService, $this->secureRandom, $this->createMock(IUserManager::class), $groupManager, @@ -182,26 +188,78 @@ class BackendNotifierTest extends TestCase { } public function testStart() { + $userId = 'testUser'; + + /** @var IUser|MockObject $testUser */ + $testUser = $this->createMock(IUser::class); + $testUser->expects($this->any()) + ->method('getUID') + ->willReturn($userId); + + $roomService = $this->createMock(RoomService::class); + $roomService->method('verifyPassword') + ->willReturn(['result' => true, 'url' => '']); + $room = $this->manager->createRoom(Room::TYPE_PUBLIC); + $this->participantService->addUsers($room, [[ + 'actorType' => 'users', + 'actorId' => $userId, + ]]); + $participant = $this->participantService->joinRoom($roomService, $room, $testUser, ''); - $this->backendNotifier->start($room, Room::RECORDING_VIDEO, 'participant1'); + $this->backendNotifier->start($room, Room::RECORDING_VIDEO, 'participant1', $participant); $this->assertMessageWasSent($room, [ 'type' => 'start', 'start' => [ 'status' => Room::RECORDING_VIDEO, 'owner' => 'participant1', + 'actor' => [ + 'type' => 'users', + 'id' => $userId, + ], ], ]); } public function testStop() { + $userId = 'testUser'; + + /** @var IUser|MockObject $testUser */ + $testUser = $this->createMock(IUser::class); + $testUser->expects($this->any()) + ->method('getUID') + ->willReturn($userId); + + $roomService = $this->createMock(RoomService::class); + $roomService->method('verifyPassword') + ->willReturn(['result' => true, 'url' => '']); + $room = $this->manager->createRoom(Room::TYPE_PUBLIC); + $this->participantService->addUsers($room, [[ + 'actorType' => 'users', + 'actorId' => $userId, + ]]); + $participant = $this->participantService->joinRoom($roomService, $room, $testUser, ''); + + $this->backendNotifier->stop($room, $participant); + + $this->assertMessageWasSent($room, [ + 'type' => 'stop', + 'stop' => [ + 'actor' => [ + 'type' => 'users', + 'id' => $userId, + ], + ], + ]); $this->backendNotifier->stop($room); $this->assertMessageWasSent($room, [ 'type' => 'stop', + 'stop' => [ + ], ]); } } |