|
30 | 30 | use Sabre\DAV\Exception\BadRequest; |
31 | 31 | use Sabre\DAV\Exception\NotFound; |
32 | 32 | use Sabre\DAV\PropPatch; |
| 33 | +use Sabre\DAV\Xml\Property\Complex; |
33 | 34 | use Sabre\DAV\Xml\Property\Href; |
34 | 35 | use Sabre\DAVACL\IACL; |
35 | 36 | use function time; |
@@ -1722,7 +1723,7 @@ public function testGetCalendarsAddsAdditionalProperties(): void { |
1722 | 1723 | $sharedPath = 'calendars/caldav-unit-test/calendar-uri-sharer_shared_by_caldav-unit-test1'; |
1723 | 1724 | $ownPath = 'calendars/caldav-unit-test/calendar-uri-sharee'; |
1724 | 1725 | try { |
1725 | | - // a sharee can override the transparency, other properties only fill in missing values |
| 1726 | + // a sharee can override the transparency, read-only is never applied |
1726 | 1727 | $this->insertProperty('caldav-unit-test', $sharedPath, $transparencyKey, new ScheduleCalendarTransp('opaque')); |
1727 | 1728 | $this->insertProperty('caldav-unit-test', $sharedPath, $enabledKey, '0'); |
1728 | 1729 | $this->insertProperty('caldav-unit-test', $sharedPath, $readOnlyKey, '0'); |
@@ -1767,6 +1768,76 @@ public function testGetCalendarsAddsAdditionalProperties(): void { |
1767 | 1768 | } |
1768 | 1769 | } |
1769 | 1770 |
|
| 1771 | + public function testGetCalendarsIgnoresUnlistedAndInvalidAdditionalProperties(): void { |
| 1772 | + $this->userManager->expects($this->any()) |
| 1773 | + ->method('userExists') |
| 1774 | + ->willReturn(true); |
| 1775 | + $this->principal->expects(self::atLeastOnce()) |
| 1776 | + ->method('findByUri') |
| 1777 | + ->willReturn(self::UNIT_TEST_USER); |
| 1778 | + |
| 1779 | + $sharee = self::UNIT_TEST_USER; |
| 1780 | + $sharer = self::UNIT_TEST_USER1; |
| 1781 | + $ownerPrincipalKey = '{http://owncloud.org/ns}owner-principal'; |
| 1782 | + $publicKey = '{http://owncloud.org/ns}public'; |
| 1783 | + $displayNameKey = '{DAV:}displayname'; |
| 1784 | + $colorKey = '{http://apple.com/ns/ical/}calendar-color'; |
| 1785 | + |
| 1786 | + $this->backend->createCalendar($sharee, 'calendar-uri-sharee', [ |
| 1787 | + $displayNameKey => 'Own', |
| 1788 | + $colorKey => '#000000', |
| 1789 | + ]); |
| 1790 | + $this->backend->createCalendar($sharer, 'calendar-uri-sharer', [ |
| 1791 | + $displayNameKey => 'Shared', |
| 1792 | + $colorKey => '#000000', |
| 1793 | + ]); |
| 1794 | + $sharerCalendar = new Calendar($this->backend, $this->backend->getCalendarsForUser($sharer)[0], $this->createMock(IL10N::class), $this->createMock(IConfig::class), new NullLogger()); |
| 1795 | + $this->backend->updateShares($sharerCalendar, [ |
| 1796 | + [ |
| 1797 | + 'href' => 'principal:' . $sharee, |
| 1798 | + 'readOnly' => true, |
| 1799 | + ], |
| 1800 | + ], []); |
| 1801 | + |
| 1802 | + $sharedPath = 'calendars/caldav-unit-test/calendar-uri-sharer_shared_by_caldav-unit-test1'; |
| 1803 | + $ownPath = 'calendars/caldav-unit-test/calendar-uri-sharee'; |
| 1804 | + try { |
| 1805 | + $this->insertProperty('caldav-unit-test', $ownPath, $ownerPrincipalKey, $sharer); |
| 1806 | + $this->insertProperty('caldav-unit-test', $ownPath, $publicKey, '1'); |
| 1807 | + $this->insertProperty('caldav-unit-test', $ownPath, $displayNameKey, 'Stored'); |
| 1808 | + $this->insertProperty('caldav-unit-test', $ownPath, $colorKey, '#ff0000'); |
| 1809 | + $this->insertProperty('caldav-unit-test', $sharedPath, $publicKey, '1'); |
| 1810 | + $this->insertProperty('caldav-unit-test', $sharedPath, $displayNameKey, new Complex('<x/>')); |
| 1811 | + $this->insertProperty('caldav-unit-test', $sharedPath, $colorKey, '#00ff00'); |
| 1812 | + |
| 1813 | + $ownCalendars = [ |
| 1814 | + $this->backend->getCalendarByUri($sharee, 'calendar-uri-sharee'), |
| 1815 | + $this->backend->getUsersOwnCalendars($sharee)[0], |
| 1816 | + ]; |
| 1817 | + foreach ($this->backend->getCalendarsForUser($sharee) as $calendar) { |
| 1818 | + if ($calendar['uri'] === 'calendar-uri-sharee') { |
| 1819 | + $ownCalendars[] = $calendar; |
| 1820 | + } else { |
| 1821 | + $shared = $calendar; |
| 1822 | + } |
| 1823 | + } |
| 1824 | + |
| 1825 | + $this->assertCount(3, $ownCalendars); |
| 1826 | + foreach ($ownCalendars as $own) { |
| 1827 | + $this->assertNotSame($sharer, $own[$ownerPrincipalKey] ?? null); |
| 1828 | + $this->assertArrayNotHasKey($publicKey, $own); |
| 1829 | + $this->assertSame('Own', $own[$displayNameKey]); |
| 1830 | + $this->assertSame('#000000', $own[$colorKey]); |
| 1831 | + } |
| 1832 | + |
| 1833 | + $this->assertArrayNotHasKey($publicKey, $shared); |
| 1834 | + $this->assertIsString($shared[$displayNameKey]); |
| 1835 | + $this->assertSame('#00ff00', $shared[$colorKey]); |
| 1836 | + } finally { |
| 1837 | + $this->deleteProperties('caldav-unit-test', 'caldav-unit-test1'); |
| 1838 | + } |
| 1839 | + } |
| 1840 | + |
1770 | 1841 | /** |
1771 | 1842 | * @throws \OCP\DB\Exception |
1772 | 1843 | * @throws \Sabre\DAV\Exception\BadRequest |
|
0 commit comments