-
Notifications
You must be signed in to change notification settings - Fork 448
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gary Kim <[email protected]>
- Loading branch information
Showing
7 changed files
with
187 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2016, ownCloud, Inc. | ||
* @copyright Copyright (c) 2021 Gary Kim <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* @copyright Copyright (c) 2021 Gary Kim <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
|
||
namespace OCA\Talk\Exceptions; | ||
|
||
class RoomHasNoModeratorException extends \Exception { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,10 @@ | |
use OCA\Talk\Federation\FederationManager; | ||
use OCA\Talk\Federation\Notifications; | ||
use OCA\Talk\Manager; | ||
use OCA\Talk\MatterbridgeManager; | ||
use OCA\Talk\Model\Attendee; | ||
use OCA\Talk\Model\AttendeeMapper; | ||
use OCA\Talk\Participant; | ||
use OCA\Talk\Room; | ||
use OCA\Talk\Service\ParticipantService; | ||
use OCP\BackgroundJob\IJobList; | ||
|
@@ -69,22 +72,30 @@ class FederationTest extends TestCase { | |
/** @var INotificationManager */ | ||
protected $notificationManager; | ||
|
||
/** @var AttendeeMapper */ | ||
protected $attendeeMapper; | ||
|
||
public function setUp(): void { | ||
parent::setUp(); | ||
|
||
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class); | ||
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class); | ||
$this->addressHandler = $this->createMock(AddressHandler::class); | ||
$this->userManager = $this->createMock(IUserManager::class); | ||
$this->attendeeMapper = $this->createMock(AttendeeMapper::class); | ||
|
||
$this->notifications = new Notifications( | ||
$this->cloudFederationFactory, | ||
$this->addressHandler, | ||
$this->createMock(LoggerInterface::class), | ||
$this->cloudFederationProviderManager, | ||
$this->createMock(IJobList::class) | ||
$this->createMock(IJobList::class), | ||
$this->userManager, | ||
$this->attendeeMapper, | ||
$this->createMock(MatterbridgeManager::class), | ||
); | ||
|
||
$this->federationManager = $this->createMock(FederationManager::class); | ||
$this->userManager = $this->createMock(IUserManager::class); | ||
$this->notificationManager = $this->createMock(INotificationManager::class); | ||
|
||
$this->cloudFederationProvider = new CloudFederationProviderTalk( | ||
|
@@ -94,26 +105,82 @@ public function setUp(): void { | |
$this->notificationManager, | ||
$this->createMock(IURLGenerator::class), | ||
$this->createMock(ParticipantService::class), | ||
$this->createMock(AttendeeMapper::class), | ||
$this->attendeeMapper, | ||
$this->createMock(Manager::class) | ||
); | ||
} | ||
|
||
public function testSendRemoteShare() { | ||
public function testSendRemoteShareWithOwner() { | ||
$cloudShare = $this->createMock(ICloudFederationShare::class); | ||
|
||
$providerId = '3'; | ||
$roomId = 5; | ||
$token = 'abcdefghijklmno'; | ||
$shareWith = '[email protected]'; | ||
$name = 'abcdefgh'; | ||
$owner = 'Owner\'s name'; | ||
$ownerFederatedId = '[email protected]'; | ||
$ownerId = 'owner'; | ||
$ownerFederatedId = $ownerId . '@test.local'; | ||
$sharedBy = 'Owner\'s name'; | ||
$sharedByFederatedId = '[email protected]'; | ||
$shareType = 'user'; | ||
$roomType = Room::TYPE_GROUP; | ||
$roomName = 'Room name'; | ||
|
||
$room = $this->createMock(Room::class); | ||
$attendee = $this->createMock(Attendee::class); | ||
$ownerUser = $this->createMock(IUser::class); | ||
|
||
$room->expects($this->once()) | ||
->method('getName') | ||
->with() | ||
->willReturn($roomName); | ||
|
||
$room->expects($this->once()) | ||
->method('getType') | ||
->with() | ||
->willReturn($roomType); | ||
|
||
$room->expects($this->once()) | ||
->method('getToken') | ||
->with() | ||
->willReturn($name); | ||
|
||
$room->expects($this->once()) | ||
->method('getId') | ||
->with() | ||
->willReturn($roomId); | ||
|
||
$attendee->expects($this->once()) | ||
->method('getActorType') | ||
->with() | ||
->willReturn(Attendee::ACTOR_USERS); | ||
|
||
$attendee->expects($this->once()) | ||
->method('getActorId') | ||
->with() | ||
->willReturn($ownerId); | ||
|
||
$this->attendeeMapper->expects($this->once()) | ||
->method('getActorsByParticipantTypes') | ||
->with($roomId, [Participant::OWNER]) | ||
->willReturn([$attendee]); | ||
|
||
$this->userManager->expects($this->once()) | ||
->method('get') | ||
->with($ownerId) | ||
->willReturn($ownerUser); | ||
|
||
$ownerUser->expects($this->once()) | ||
->method('getCloudId') | ||
->with() | ||
->willReturn($ownerFederatedId); | ||
|
||
$ownerUser->expects($this->once()) | ||
->method('getDisplayName') | ||
->with() | ||
->willReturn($owner); | ||
|
||
$this->cloudFederationFactory->expects($this->once()) | ||
->method('getCloudFederationShare') | ||
->with( | ||
|
@@ -140,7 +207,7 @@ public function testSendRemoteShare() { | |
->with($shareWith) | ||
->willReturn(['test', 'remote.test.local']); | ||
|
||
$this->notifications->sendRemoteShare($providerId, $token, $shareWith, $name, $owner, $ownerFederatedId, $sharedBy, $sharedByFederatedId, $shareType, $roomName, (string) $roomType); | ||
$this->notifications->sendRemoteShare($providerId, $token, $shareWith, $sharedBy, $sharedByFederatedId, $shareType, $room); | ||
} | ||
|
||
public function testReceiveRemoteShare() { | ||
|