OutboxTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Tests\unit\CalDAV;
  7. use OCA\DAV\CalDAV\Outbox;
  8. use OCP\IConfig;
  9. use Test\TestCase;
  10. class OutboxTest extends TestCase {
  11. /** @var IConfig */
  12. private $config;
  13. /** @var Outbox */
  14. private $outbox;
  15. protected function setUp(): void {
  16. parent::setUp();
  17. $this->config = $this->createMock(IConfig::class);
  18. $this->outbox = new Outbox($this->config, 'user-principal-123');
  19. }
  20. public function testGetACLFreeBusyEnabled(): void {
  21. $this->config->expects($this->once())
  22. ->method('getAppValue')
  23. ->with('dav', 'disableFreeBusy', 'no')
  24. ->willReturn('no');
  25. $this->assertEquals([
  26. [
  27. 'privilege' => '{DAV:}read',
  28. 'principal' => 'user-principal-123',
  29. 'protected' => true,
  30. ],
  31. [
  32. 'privilege' => '{DAV:}read',
  33. 'principal' => 'user-principal-123/calendar-proxy-read',
  34. 'protected' => true,
  35. ],
  36. [
  37. 'privilege' => '{DAV:}read',
  38. 'principal' => 'user-principal-123/calendar-proxy-write',
  39. 'protected' => true,
  40. ],
  41. [
  42. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
  43. 'principal' => 'user-principal-123',
  44. 'protected' => true,
  45. ],
  46. [
  47. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
  48. 'principal' => 'user-principal-123/calendar-proxy-write',
  49. 'protected' => true,
  50. ],
  51. ], $this->outbox->getACL());
  52. }
  53. public function testGetACLFreeBusyDisabled(): void {
  54. $this->config->expects($this->once())
  55. ->method('getAppValue')
  56. ->with('dav', 'disableFreeBusy', 'no')
  57. ->willReturn('yes');
  58. $this->assertEquals([
  59. [
  60. 'privilege' => '{DAV:}read',
  61. 'principal' => 'user-principal-123',
  62. 'protected' => true,
  63. ],
  64. [
  65. 'privilege' => '{DAV:}read',
  66. 'principal' => 'user-principal-123/calendar-proxy-read',
  67. 'protected' => true,
  68. ],
  69. [
  70. 'privilege' => '{DAV:}read',
  71. 'principal' => 'user-principal-123/calendar-proxy-write',
  72. 'protected' => true,
  73. ],
  74. [
  75. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
  76. 'principal' => 'user-principal-123',
  77. 'protected' => true,
  78. ],
  79. [
  80. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
  81. 'principal' => 'user-principal-123/calendar-proxy-write',
  82. 'protected' => true,
  83. ],
  84. [
  85. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
  86. 'principal' => 'user-principal-123',
  87. 'protected' => true,
  88. ],
  89. [
  90. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
  91. 'principal' => 'user-principal-123/calendar-proxy-write',
  92. 'protected' => true,
  93. ],
  94. ], $this->outbox->getACL());
  95. }
  96. }