diff options
author | Vitor Mattos <vitor@php.rio> | 2023-02-24 16:46:31 -0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2023-02-24 17:12:34 -0300 |
commit | ad768613869a0a3420b8bf17f55e24dff85d8d7b (patch) | |
tree | 29a91389ec428f5d1b4c49b6b98cc934c7e4ed0e /tests | |
parent | befbf82f6bbe3c2efba48cda76315add9a12d3ab (diff) |
Send notification when get upload problem
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 41 | ||||
-rw-r--r-- | tests/integration/features/callapi/recording.feature | 15 | ||||
-rw-r--r-- | tests/php/Service/RecordingServiceTest.php | 16 |
3 files changed, 56 insertions, 16 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 602c5d1c7..f05cb1e2e 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -3247,18 +3247,35 @@ class FeatureContext implements Context, SnippetAcceptingContext { 'TALK_RECORDING_RANDOM' => $validRandom, 'TALK_RECORDING_CHECKSUM' => $validChecksum, ]; - $options = [ - 'multipart' => [ - [ - 'name' => 'file', - 'contents' => $file !== 'invalid' ? fopen(__DIR__ . '/../../../..' . $file, 'r') : '', - ], - [ - 'name' => 'owner', - 'contents' => $user, - ], - ], - ]; + $options = ['multipart' => [['name' => 'owner', 'contents' => $user]]]; + if ($file === 'invalid') { + // Create invalid content + $options['multipart'][] = [ + 'name' => 'file', + 'contents' => '', + ]; + } elseif ($file === 'big') { + // More details about MAX_FILE_SIZE follow the link: + // https://www.php.net/manual/en/features.file-upload.post-method.php + $options['multipart'][] = [ + 'name' => 'MAX_FILE_SIZE', + 'contents' => 1, // Limit the max file size to 1 + ]; + // Create file with big content + $contents = tmpfile(); + fwrite($contents, 'fake content'); // Bigger than 1 + $options['multipart'][] = [ + 'name' => 'file', + 'contents' => $contents, + 'filename' => 'audio.ogg', // to get the mimetype by extension and do the upload + ]; + } else { + // Upload a file + $options['multipart'][] = [ + 'name' => 'file', + 'contents' => fopen(__DIR__ . '/../../../..' . $file, 'r'), + ]; + } $this->sendRequest( 'POST', '/apps/spreed/api/' . $apiVersion . '/recording/' . self::$identifierToToken[$identifier] . '/store', diff --git a/tests/integration/features/callapi/recording.feature b/tests/integration/features/callapi/recording.feature index 917c00a65..e194759d2 100644 --- a/tests/integration/features/callapi/recording.feature +++ b/tests/integration/features/callapi/recording.feature @@ -373,7 +373,7 @@ Feature: callapi/recording | type | name | callRecording | | 2 | room1 | 0 | - Scenario: Store recording + Scenario: Store recording with success Given user "participant1" creates room "room1" (v4) | roomType | 2 | | roomName | room1 | @@ -386,6 +386,19 @@ Feature: callapi/recording | type | name | callRecording | | 2 | room1 | 0 | + Scenario: Store recording with failure + Given user "participant1" creates room "room1" (v4) + | roomType | 2 | + | roomName | room1 | + And user "participant1" joins room "room1" with 200 (v4) + When user "participant1" store recording file "big" in room "room1" with 400 (v1) + Then user "participant1" has the following notifications + | app | object_type | object_id | subject | + | spreed | recording | room1 | Fail to store recording of call room1, reach out to the admin. | + And user "participant1" is participant of the following unordered rooms (v4) + | type | name | callRecording | + | 2 | room1 | 0 | + Scenario: Stop recording automatically when end the call Given recording server is started And user "participant1" creates room "room1" (v4) diff --git a/tests/php/Service/RecordingServiceTest.php b/tests/php/Service/RecordingServiceTest.php index 0cef7668a..44eafb898 100644 --- a/tests/php/Service/RecordingServiceTest.php +++ b/tests/php/Service/RecordingServiceTest.php @@ -38,7 +38,10 @@ namespace OCA\Talk\Tests\php\Service; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Config; use OCA\Talk\Manager; +use OCA\Talk\Model\Attendee; +use OCA\Talk\Participant; use OCA\Talk\Recording\BackendNotifier; +use OCA\Talk\Room; use OCA\Talk\Service\ParticipantService; use OCA\Talk\Service\RecordingService; use OCA\Talk\Service\RoomService; @@ -144,7 +147,14 @@ class RecordingServiceTest extends TestCase { $this->expectExceptionMessage($exceptionMessage); } - $actual = $this->recordingService->getContentFromFileArray($file); + $room = $this->createMock(Room::class); + $attendee = Attendee::fromRow([ + 'actor_type' => Attendee::ACTOR_USERS, + 'actor_id' => 'participant1', + ]); + $participant = new Participant($room, $attendee, null); + + $actual = $this->recordingService->getContentFromFileArray($file, $room, $participant); $this->assertEquals($expected, $actual); $this->assertFileDoesNotExist($file['tmp_name']); } @@ -153,8 +163,8 @@ class RecordingServiceTest extends TestCase { $fileWithContent = tempnam(sys_get_temp_dir(), 'txt'); file_put_contents($fileWithContent, 'bla'); return [ - [['error' => 0, 'tmp_name' => ''], '', 'invalid_file'], - [['error' => 0, 'tmp_name' => 'a'], '', 'invalid_file'], + [['error' => 1, 'tmp_name' => ''], '', 'invalid_file'], + [['error' => 1, 'tmp_name' => 'a'], '', 'invalid_file'], # Empty file [['error' => 0, 'tmp_name' => tempnam(sys_get_temp_dir(), 'txt')], '', 'empty_file'], # file with content |