summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2023-03-08 10:01:35 +0100
committerGitHub <noreply@github.com>2023-03-08 10:01:35 +0100
commitafd74b4aecc4a853d70ca9086bb960a527be47cb (patch)
treed06a978670247ae450b4dd82c33d9c03ec9bdd1e /tests
parent0196aeff779e59f22a3143c39279a43476d1e2f1 (diff)
parenta0fef98d616f26f2aabd2216a366dd64cfc8615a (diff)
Merge pull request #8846 from nextcloud/feature/send-notification-when-get-upload-problem
Send notification when get upload problem
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php41
-rw-r--r--tests/integration/features/callapi/recording.feature15
-rw-r--r--tests/php/Chat/NotifierTest.php16
-rw-r--r--tests/php/Service/RecordingServiceTest.php16
4 files changed, 62 insertions, 26 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 8f2c83bbf..5f6f014c6 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -3254,18 +3254,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..7195a3361 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_information | room1 | Failed to upload call recording |
+ 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/Chat/NotifierTest.php b/tests/php/Chat/NotifierTest.php
index 5a5636b24..944321079 100644
--- a/tests/php/Chat/NotifierTest.php
+++ b/tests/php/Chat/NotifierTest.php
@@ -282,16 +282,12 @@ class NotifierTest extends TestCase {
->with('spreed')
->willReturnSelf();
- $notification->expects($this->exactly(3))
+ $notification->expects($this->atLeastOnce())
->method('setObject')
- ->withConsecutive(
- ['chat', 'Token123'],
- ['room', 'Token123'],
- ['call', 'Token123']
- )
+ ->with($this->anything(), 'Token123')
->willReturnSelf();
- $this->notificationManager->expects($this->exactly(3))
+ $this->notificationManager->expects($this->atLeastOnce())
->method('markProcessed')
->with($notification);
@@ -315,12 +311,12 @@ class NotifierTest extends TestCase {
->with('spreed')
->willReturnSelf();
- $notification->expects($this->exactly(1))
+ $notification->expects($this->atLeastOnce())
->method('setObject')
- ->with('chat', 'Token123')
+ ->with($this->anything(), 'Token123')
->willReturnSelf();
- $this->notificationManager->expects($this->exactly(1))
+ $this->notificationManager->expects($this->atLeastOnce())
->method('markProcessed')
->with($notification);
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