OutboxTest.php 3.3 KB

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