OutboxTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018, Georg Ehrke
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Georg Ehrke <oc.list@georgehrke.com>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\DAV\Tests\unit\CalDAV;
  26. use OCA\DAV\CalDAV\Outbox;
  27. use OCP\IConfig;
  28. use Test\TestCase;
  29. class OutboxTest extends TestCase {
  30. /** @var IConfig */
  31. private $config;
  32. /** @var Outbox */
  33. private $outbox;
  34. protected function setUp(): void {
  35. parent::setUp();
  36. $this->config = $this->createMock(IConfig::class);
  37. $this->outbox = new Outbox($this->config, 'user-principal-123');
  38. }
  39. public function testGetACLFreeBusyEnabled(): void {
  40. $this->config->expects($this->once())
  41. ->method('getAppValue')
  42. ->with('dav', 'disableFreeBusy', 'no')
  43. ->willReturn('no');
  44. $this->assertEquals([
  45. [
  46. 'privilege' => '{DAV:}read',
  47. 'principal' => 'user-principal-123',
  48. 'protected' => true,
  49. ],
  50. [
  51. 'privilege' => '{DAV:}read',
  52. 'principal' => 'user-principal-123/calendar-proxy-read',
  53. 'protected' => true,
  54. ],
  55. [
  56. 'privilege' => '{DAV:}read',
  57. 'principal' => 'user-principal-123/calendar-proxy-write',
  58. 'protected' => true,
  59. ],
  60. [
  61. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
  62. 'principal' => 'user-principal-123',
  63. 'protected' => true,
  64. ],
  65. [
  66. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send',
  67. 'principal' => 'user-principal-123/calendar-proxy-write',
  68. 'protected' => true,
  69. ],
  70. ], $this->outbox->getACL());
  71. }
  72. public function testGetACLFreeBusyDisabled(): void {
  73. $this->config->expects($this->once())
  74. ->method('getAppValue')
  75. ->with('dav', 'disableFreeBusy', 'no')
  76. ->willReturn('yes');
  77. $this->assertEquals([
  78. [
  79. 'privilege' => '{DAV:}read',
  80. 'principal' => 'user-principal-123',
  81. 'protected' => true,
  82. ],
  83. [
  84. 'privilege' => '{DAV:}read',
  85. 'principal' => 'user-principal-123/calendar-proxy-read',
  86. 'protected' => true,
  87. ],
  88. [
  89. 'privilege' => '{DAV:}read',
  90. 'principal' => 'user-principal-123/calendar-proxy-write',
  91. 'protected' => true,
  92. ],
  93. [
  94. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
  95. 'principal' => 'user-principal-123',
  96. 'protected' => true,
  97. ],
  98. [
  99. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-invite',
  100. 'principal' => 'user-principal-123/calendar-proxy-write',
  101. 'protected' => true,
  102. ],
  103. [
  104. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
  105. 'principal' => 'user-principal-123',
  106. 'protected' => true,
  107. ],
  108. [
  109. 'privilege' => '{urn:ietf:params:xml:ns:caldav}schedule-send-reply',
  110. 'principal' => 'user-principal-123/calendar-proxy-write',
  111. 'protected' => true,
  112. ],
  113. ], $this->outbox->getACL());
  114. }
  115. }