diff options
author | SebastianKrupinski <krupinskis05@gmail.com> | 2024-09-17 07:45:44 -0400 |
---|---|---|
committer | SebastianKrupinski <krupinskis05@gmail.com> | 2024-11-14 20:26:22 -0500 |
commit | 1260ec5f21b84211a795ff03254be5a49eff40c1 (patch) | |
tree | 6f5392d9f2594e2062aecc9479606ed6356c30f0 /apps/dav/tests/unit/CalDAV | |
parent | aba18bacb36c1283619761144e494d3462175263 (diff) | |
download | nextcloud-server-1260ec5f21b84211a795ff03254be5a49eff40c1.tar.gz nextcloud-server-1260ec5f21b84211a795ff03254be5a49eff40c1.zip |
feat: mail provider settingsbackport/48134/stable30
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
Diffstat (limited to 'apps/dav/tests/unit/CalDAV')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php | 127 |
1 files changed, 117 insertions, 10 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index c8dfe257bf2..b459b9da7c8 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -11,7 +11,7 @@ use OCA\DAV\CalDAV\Schedule\IMipPlugin; use OCA\DAV\CalDAV\Schedule\IMipService; use OCP\AppFramework\Utility\ITimeFactory; use OCP\Defaults; -use OCP\IConfig; +use OCP\IAppConfig; use OCP\IUser; use OCP\IUserSession; use OCP\Mail\IAttachment; @@ -52,7 +52,7 @@ class IMipPluginTest extends TestCase { /** @var ITimeFactory|MockObject */ private $timeFactory; - /** @var IConfig|MockObject */ + /** @var IAppConfig|MockObject */ private $config; /** @var IUserSession|MockObject */ @@ -105,7 +105,7 @@ class IMipPluginTest extends TestCase { $this->timeFactory = $this->createMock(ITimeFactory::class); $this->timeFactory->method('getTime')->willReturn(1496912528); // 2017-01-01 - $this->config = $this->createMock(IConfig::class); + $this->config = $this->createMock(IAppConfig::class); $this->user = $this->createMock(IUser::class); @@ -243,7 +243,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -341,7 +341,7 @@ class IMipPluginTest extends TestCase { $this->service->expects(self::never()) ->method('getAttendeeRsvpOrReqForParticipant'); $this->config->expects(self::never()) - ->method('getAppValue'); + ->method('getValueString'); $this->service->expects(self::never()) ->method('createInvitationToken'); $this->service->expects(self::never()) @@ -447,7 +447,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -578,7 +578,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -633,7 +633,7 @@ class IMipPluginTest extends TestCase { ]; // construct system config mock returns $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); // construct user mock returns @@ -708,6 +708,113 @@ class IMipPluginTest extends TestCase { $this->assertEquals('1.1', $message->getScheduleStatus()); } + public function testMailProviderDisabled(): void { + $message = new Message(); + $message->method = 'REQUEST'; + $newVCalendar = new VCalendar(); + $newVevent = new VEvent($newVCalendar, 'one', array_merge([ + 'UID' => 'uid-1234', + 'SEQUENCE' => 1, + 'SUMMARY' => 'Fellowship meeting without (!) Boromir', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00') + ], [])); + $newVevent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $newVevent->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + $message->message = $newVCalendar; + $message->sender = 'mailto:gandalf@wiz.ard'; + $message->senderName = 'Mr. Wizard'; + $message->recipient = 'mailto:' . 'frodo@hobb.it'; + // save the old copy in the plugin + $oldVCalendar = new VCalendar(); + $oldVEvent = new VEvent($oldVCalendar, 'one', [ + 'UID' => 'uid-1234', + 'SEQUENCE' => 0, + 'SUMMARY' => 'Fellowship meeting', + 'DTSTART' => new \DateTime('2016-01-01 00:00:00') + ]); + $oldVEvent->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $oldVEvent->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + $oldVEvent->add('ATTENDEE', 'mailto:' . 'boromir@tra.it.or', ['RSVP' => 'TRUE']); + $oldVCalendar->add($oldVEvent); + $data = ['invitee_name' => 'Mr. Wizard', + 'meeting_title' => 'Fellowship meeting without (!) Boromir', + 'attendee_name' => 'frodo@hobb.it' + ]; + $attendees = $newVevent->select('ATTENDEE'); + $atnd = ''; + foreach ($attendees as $attendee) { + if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { + $atnd = $attendee; + } + } + $this->plugin->setVCalendar($oldVCalendar); + $this->service->expects(self::once()) + ->method('getLastOccurrence') + ->willReturn(1496912700); + $this->mailer->expects(self::once()) + ->method('validateMailAddress') + ->with('frodo@hobb.it') + ->willReturn(true); + $this->eventComparisonService->expects(self::once()) + ->method('findModified') + ->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); + $this->service->expects(self::once()) + ->method('getCurrentAttendee') + ->with($message) + ->willReturn($atnd); + $this->service->expects(self::once()) + ->method('isRoomOrResource') + ->with($atnd) + ->willReturn(false); + $this->service->expects(self::once()) + ->method('buildBodyData') + ->with($newVevent, $oldVEvent) + ->willReturn($data); + $this->user->expects(self::any()) + ->method('getUID') + ->willReturn('user1'); + $this->user->expects(self::any()) + ->method('getDisplayName') + ->willReturn('Mr. Wizard'); + $this->userSession->expects(self::any()) + ->method('getUser') + ->willReturn($this->user); + $this->service->expects(self::once()) + ->method('getFrom'); + $this->service->expects(self::once()) + ->method('addSubjectAndHeading') + ->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', true); + $this->service->expects(self::once()) + ->method('addBulletList') + ->with($this->emailTemplate, $newVevent, $data); + $this->service->expects(self::once()) + ->method('getAttendeeRsvpOrReqForParticipant') + ->willReturn(true); + $this->config->expects(self::once()) + ->method('getValueString') + ->with('dav', 'invitation_link_recipients', 'yes') + ->willReturn('yes'); + $this->config->expects(self::once()) + ->method('getValueBool') + ->with('core', 'mail_providers_enabled', true) + ->willReturn(false); + $this->service->expects(self::once()) + ->method('createInvitationToken') + ->with($message, $newVevent, 1496912700) + ->willReturn('token'); + $this->service->expects(self::once()) + ->method('addResponseButtons') + ->with($this->emailTemplate, 'token'); + $this->service->expects(self::once()) + ->method('addMoreOptionsButton') + ->with($this->emailTemplate, 'token'); + $this->mailer->expects(self::once()) + ->method('send') + ->willReturn([]); + $this->plugin->schedule($message); + $this->assertEquals('1.1', $message->getScheduleStatus()); + } + public function testNoOldEvent(): void { $message = new Message(); $message->method = 'REQUEST'; @@ -779,7 +886,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('yes'); $this->service->expects(self::once()) @@ -872,7 +979,7 @@ class IMipPluginTest extends TestCase { ->method('getAttendeeRsvpOrReqForParticipant') ->willReturn(true); $this->config->expects(self::once()) - ->method('getAppValue') + ->method('getValueString') ->with('dav', 'invitation_link_recipients', 'yes') ->willReturn('no'); $this->service->expects(self::never()) |