diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-06-29 06:51:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-29 06:51:49 +0200 |
commit | 89b6ee1a45f165346ddcc9120195714087287b47 (patch) | |
tree | a7951e212e099f08cd28b412aaa03b1fe1757523 /apps/dav/tests | |
parent | e6780c4fc7fe0bb6ee6d2a8d4bfb2ca09d6e726a (diff) | |
parent | ab43251a45f9b04a1681a0b206d85676232dd7c3 (diff) | |
download | nextcloud-server-89b6ee1a45f165346ddcc9120195714087287b47.tar.gz nextcloud-server-89b6ee1a45f165346ddcc9120195714087287b47.zip |
Merge pull request #9773 from nextcloud/feature/noid/resource_booking
resource booking
Diffstat (limited to 'apps/dav/tests')
5 files changed, 1298 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php new file mode 100644 index 00000000000..56f768ceda0 --- /dev/null +++ b/apps/dav/tests/unit/BackgroundJob/UpdateCalendarResourcesRoomsBackgroundJobTest.php @@ -0,0 +1,285 @@ +<?php +/** + * @copyright Copyright (c) 2018, Georg Ehrke + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCA\DAV\Tests\unit\BackgroundJob; + +use OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob; + +use OCA\DAV\CalDAV\CalDavBackend; +use OCP\Calendar\BackendTemporarilyUnavailableException; +use OCP\Calendar\Resource\IBackend; +use OCP\Calendar\Resource\IManager as IResourceManager; +use OCP\Calendar\Resource\IResource; +use OCP\Calendar\Room\IManager as IRoomManager; +use Test\TestCase; + +class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase { + + /** @var UpdateCalendarResourcesRoomsBackgroundJob */ + private $backgroundJob; + + /** @var IResourceManager | \PHPUnit_Framework_MockObject_MockObject */ + private $resourceManager; + + /** @var IRoomManager | \PHPUnit_Framework_MockObject_MockObject */ + private $roomManager; + + /** @var CalDavBackend | \PHPUnit_Framework_MockObject_MockObject */ + private $calDavBackend; + + protected function setUp() { + parent::setUp(); + + $this->resourceManager = $this->createMock(IResourceManager::class); + $this->roomManager = $this->createMock(IRoomManager::class); + $this->calDavBackend = $this->createMock(CalDavBackend::class); + + $this->backgroundJob = new UpdateCalendarResourcesRoomsBackgroundJob( + $this->resourceManager, $this->roomManager, self::$realDatabase, + $this->calDavBackend); + } + + protected function tearDown() { + $query = self::$realDatabase->getQueryBuilder(); + $query->delete('calendar_resources_cache')->execute(); + $query->delete('calendar_rooms_cache')->execute(); + } + + /** + * Data in Cache: + * resources: + * [backend1, res1, Beamer1, {}] + * [backend1, res2, TV1, {}] + * [backend2, res3, Beamer2, {}] + * [backend2, res4, TV2, {}] + * [backend3, res5, Beamer3, {}] + * [backend3, res6, Pointer, {foo, bar}] + * + * Data in Backend: + * backend1 gone + * backend2 throws BackendTemporarilyUnavailableException + * [backend3, res6, Pointer123, {foo, biz}] + * [backend3, res7, Resource4, {biz}] + * [backend4, res8, Beamer, {}] + * [backend4, res9, Beamer2, {}] + * + * Expected after run: + * [backend2, res3, Beamer2, {}] + * [backend2, res4, TV2, {}] + * [backend3, res6, Pointer123, {foo, biz}] + * [backend3, res7, Resource4, {biz}] + * [backend4, res8, Beamer, {}] + * [backend4, res9, Beamer2, {}] + */ + + public function testRun() { + $this->createTestResourcesInCache(); + + $backend2 = $this->createMock(IBackend::class); + $backend3 = $this->createMock(IBackend::class); + $backend4 = $this->createMock(IBackend::class); + + $res6 = $this->createMock(IResource::class); + $res7 = $this->createMock(IResource::class); + $res8 = $this->createMock(IResource::class); + $res9 = $this->createMock(IResource::class); + + $backend2->method('getBackendIdentifier') + ->will($this->returnValue('backend2')); + $backend2->method('listAllResources') + ->will($this->throwException(new BackendTemporarilyUnavailableException())); + $backend2->method('getResource') + ->will($this->throwException(new BackendTemporarilyUnavailableException())); + $backend2->method('getAllResources') + ->will($this->throwException(new BackendTemporarilyUnavailableException())); + $backend3->method('getBackendIdentifier') + ->will($this->returnValue('backend3')); + $backend3->method('listAllResources') + ->will($this->returnValue(['res6', 'res7'])); + $backend3->method('getResource') + ->will($this->returnValueMap([ + ['res6', $res6], + ['res7', $res7], + ])); + $backend4->method('getBackendIdentifier') + ->will($this->returnValue('backend4')); + $backend4->method('listAllResources') + ->will($this->returnValue(['res8', 'res9'])); + $backend4->method('getResource') + ->will($this->returnValueMap([ + ['res8', $res8], + ['res9', $res9], + ])); + + $res6->method('getId')->will($this->returnValue('res6')); + $res6->method('getDisplayName')->will($this->returnValue('Pointer123')); + $res6->method('getGroupRestrictions')->will($this->returnValue(['foo', 'biz'])); + $res6->method('getEMail')->will($this->returnValue('res6@foo.bar')); + $res6->method('getBackend')->will($this->returnValue($backend3)); + + $res7->method('getId')->will($this->returnValue('res7')); + $res7->method('getDisplayName')->will($this->returnValue('Resource4')); + $res7->method('getGroupRestrictions')->will($this->returnValue(['biz'])); + $res7->method('getEMail')->will($this->returnValue('res7@foo.bar')); + $res7->method('getBackend')->will($this->returnValue($backend3)); + + $res8->method('getId')->will($this->returnValue('res8')); + $res8->method('getDisplayName')->will($this->returnValue('Beamer')); + $res8->method('getGroupRestrictions')->will($this->returnValue([])); + $res8->method('getEMail')->will($this->returnValue('res8@foo.bar')); + $res8->method('getBackend')->will($this->returnValue($backend4)); + + $res9->method('getId')->will($this->returnValue('res9')); + $res9->method('getDisplayName')->will($this->returnValue('Beamer2')); + $res9->method('getGroupRestrictions')->will($this->returnValue([])); + $res9->method('getEMail')->will($this->returnValue('res9@foo.bar')); + $res9->method('getBackend')->will($this->returnValue($backend4)); + + $this->resourceManager + ->method('getBackends') + ->will($this->returnValue([ + $backend2, $backend3, $backend4 + ])); + $this->resourceManager + ->method('getBackend') + ->will($this->returnValueMap([ + ['backend2', $backend2], + ['backend3', $backend3], + ['backend4', $backend4], + ])); + + $this->backgroundJob->run([]); + + $query = self::$realDatabase->getQueryBuilder(); + $query->select('*')->from('calendar_resources_cache'); + + $rows = []; + $stmt = $query->execute(); + while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { + unset($row['id']); + $rows[] = $row; + } + + $this->assertEquals([ + [ + 'backend_id' => 'backend2', + 'resource_id' => 'res3', + 'displayname' => 'Beamer2', + 'email' => 'res3@foo.bar', + 'group_restrictions' => '[]', + ], + [ + 'backend_id' => 'backend2', + 'resource_id' => 'res4', + 'displayname' => 'TV2', + 'email' => 'res4@foo.bar', + 'group_restrictions' => '[]', + ], + [ + 'backend_id' => 'backend3', + 'resource_id' => 'res6', + 'displayname' => 'Pointer123', + 'email' => 'res6@foo.bar', + 'group_restrictions' => '["foo","biz"]', + ], + [ + 'backend_id' => 'backend3', + 'resource_id' => 'res7', + 'displayname' => 'Resource4', + 'email' => 'res7@foo.bar', + 'group_restrictions' => '["biz"]', + ], + [ + 'backend_id' => 'backend4', + 'resource_id' => 'res8', + 'displayname' => 'Beamer', + 'email' => 'res8@foo.bar', + 'group_restrictions' => '[]', + ], + [ + 'backend_id' => 'backend4', + 'resource_id' => 'res9', + 'displayname' => 'Beamer2', + 'email' => 'res9@foo.bar', + 'group_restrictions' => '[]', + ], + ], $rows); + } + + protected function createTestResourcesInCache() { + $query = self::$realDatabase->getQueryBuilder(); + $query->insert('calendar_resources_cache') + ->values([ + 'backend_id' => $query->createNamedParameter('backend1'), + 'resource_id' => $query->createNamedParameter('res1'), + 'email' => $query->createNamedParameter('res1@foo.bar'), + 'displayname' => $query->createNamedParameter('Beamer1'), + 'group_restrictions' => $query->createNamedParameter('[]'), + ]) + ->execute(); + $query->insert('calendar_resources_cache') + ->values([ + 'backend_id' => $query->createNamedParameter('backend1'), + 'resource_id' => $query->createNamedParameter('res2'), + 'email' => $query->createNamedParameter('res2@foo.bar'), + 'displayname' => $query->createNamedParameter('TV1'), + 'group_restrictions' => $query->createNamedParameter('[]'), + ]) + ->execute(); + $query->insert('calendar_resources_cache') + ->values([ + 'backend_id' => $query->createNamedParameter('backend2'), + 'resource_id' => $query->createNamedParameter('res3'), + 'email' => $query->createNamedParameter('res3@foo.bar'), + 'displayname' => $query->createNamedParameter('Beamer2'), + 'group_restrictions' => $query->createNamedParameter('[]'), + ]) + ->execute(); + $query->insert('calendar_resources_cache') + ->values([ + 'backend_id' => $query->createNamedParameter('backend2'), + 'resource_id' => $query->createNamedParameter('res4'), + 'email' => $query->createNamedParameter('res4@foo.bar'), + 'displayname' => $query->createNamedParameter('TV2'), + 'group_restrictions' => $query->createNamedParameter('[]'), + ]) + ->execute(); + $query->insert('calendar_resources_cache') + ->values([ + 'backend_id' => $query->createNamedParameter('backend3'), + 'resource_id' => $query->createNamedParameter('res5'), + 'email' => $query->createNamedParameter('res5@foo.bar'), + 'displayname' => $query->createNamedParameter('Beamer3'), + 'group_restrictions' => $query->createNamedParameter('[]'), + ]) + ->execute(); + $query->insert('calendar_resources_cache') + ->values([ + 'backend_id' => $query->createNamedParameter('backend3'), + 'resource_id' => $query->createNamedParameter('res6'), + 'email' => $query->createNamedParameter('res6@foo.bar'), + 'displayname' => $query->createNamedParameter('Pointer'), + 'group_restrictions' => $query->createNamedParameter('["foo", "bar"]'), + ]) + ->execute(); + } +} diff --git a/apps/dav/tests/unit/CalDAV/PluginTest.php b/apps/dav/tests/unit/CalDAV/PluginTest.php index 7d283b6d1ed..47190d583f0 100644 --- a/apps/dav/tests/unit/CalDAV/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/PluginTest.php @@ -43,8 +43,12 @@ class PluginTest extends TestCase { 'calendars/MyUserName', ], [ - 'FooFoo', - null, + 'principals/calendar-resources/Resource-ABC', + 'system-calendars/calendar-resources/Resource-ABC', + ], + [ + 'principals/calendar-rooms/Room-ABC', + 'system-calendars/calendar-rooms/Room-ABC', ], ]; } @@ -59,4 +63,11 @@ class PluginTest extends TestCase { $this->assertSame($expected, $this->plugin->getCalendarHomeForPrincipal($input)); } + /** + * @expectedException \LogicException + * @expectedExceptionMessage This is not supposed to happen + */ + public function testGetCalendarHomeForUnknownPrincipal() { + $this->plugin->getCalendarHomeForPrincipal('FOO/BAR/BLUB'); + } } diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php new file mode 100644 index 00000000000..4dee0220fc8 --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php @@ -0,0 +1,930 @@ +<?php +/** + * @copyright Copyright (c) 2018, Georg Ehrke + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCA\DAV\Tests\unit\CalDAV\ResourceBooking; + +use OCP\DB\QueryBuilder\IQueryBuilder; +use OCP\IDBConnection; +use OCP\IGroupManager; +use OCP\ILogger; +use OCP\IUser; +use OCP\IUserSession; +use Sabre\DAV\PropPatch; +use Test\TestCase; + +abstract class AbstractPrincipalBackendTest extends TestCase { + + /** @var \OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend|\OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend */ + protected $principalBackend; + + /** @var IDBConnection|\PHPUnit_Framework_MockObject_MockObject */ + protected $dbConnection; + + /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ + protected $userSession; + + /** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */ + protected $groupManager; + + /** @var ILogger|\PHPUnit_Framework_MockObject_MockObject */ + protected $logger; + + /** @var string */ + protected $expectedDbTable; + + /** @var string */ + protected $principalPrefix; + + public function setUp() { + parent::setUp(); + + $this->dbConnection = $this->createMock(IDBConnection::class); + $this->userSession = $this->createMock(IUserSession::class); + $this->groupManager = $this->createMock(IGroupManager::class); + $this->logger = $this->createMock(ILogger::class); + } + + public function testGetPrincipalsByPrefix() { + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $this->dbConnection->expects($this->once()) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(2)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '123', + 'email' => 'foo@bar.com', + 'displayname' => 'Resource 123' + ])); + $stmt->expects($this->at(1)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 1, + 'backend_id' => 'ldap', + 'resource_id' => '123', + 'email' => 'ldap@bar.com', + 'displayname' => 'Resource 123 ldap' + ])); + $stmt->expects($this->at(2)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 2, + 'backend_id' => 'db', + 'resource_id' => '456', + 'email' => 'bli@bar.com', + 'displayname' => 'Resource 456' + ])); + $stmt->expects($this->at(3)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue(null)); + $stmt->expects($this->at(4)) + ->method('closeCursor') + ->with(); + + $actual = $this->principalBackend->getPrincipalsByPrefix($this->principalPrefix); + $this->assertEquals([ + [ + 'uri' => $this->principalPrefix . '/db-123', + '{DAV:}displayname' => 'Resource 123', + '{http://sabredav.org/ns}email-address' => 'foo@bar.com', + ], + [ + 'uri' => $this->principalPrefix . '/ldap-123', + '{DAV:}displayname' => 'Resource 123 ldap', + '{http://sabredav.org/ns}email-address' => 'ldap@bar.com', + ], + [ + 'uri' => $this->principalPrefix . '/db-456', + '{DAV:}displayname' => 'Resource 456', + '{http://sabredav.org/ns}email-address' => 'bli@bar.com', + ], + ], $actual); + + } + + public function testGetNoPrincipalsByPrefixForWrongPrincipalPrefix() { + $this->dbConnection->expects($this->never()) + ->method('getQueryBuilder'); + + $actual = $this->principalBackend->getPrincipalsByPrefix('principals/users'); + $this->assertEquals([], $actual); + } + + public function testGetPrincipalByPath() { + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['backend_id', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ['resource_id', 'createNamedParameter-2', null, 'WHERE_CLAUSE_2'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['db', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ['123', \PDO::PARAM_STR, null, 'createNamedParameter-2'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(7)) + ->method('andWhere') + ->with('WHERE_CLAUSE_2') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(8)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '123', + 'email' => 'foo@bar.com', + 'displayname' => 'Resource 123' + ])); + + $actual = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/db-123'); + $this->assertEquals([ + 'uri' => $this->principalPrefix . '/db-123', + '{DAV:}displayname' => 'Resource 123', + '{http://sabredav.org/ns}email-address' => 'foo@bar.com', + ], $actual); + } + + public function testGetPrincipalByPathNotFound() { + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['backend_id', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ['resource_id', 'createNamedParameter-2', null, 'WHERE_CLAUSE_2'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['db', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ['123', \PDO::PARAM_STR, null, 'createNamedParameter-2'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(7)) + ->method('andWhere') + ->with('WHERE_CLAUSE_2') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(8)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue(false)); + + $actual = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/db-123'); + $this->assertEquals(null, $actual); + } + + public function testGetPrincipalByPathWrongPrefix() { + $this->dbConnection->expects($this->never()) + ->method('getQueryBuilder'); + + $actual = $this->principalBackend->getPrincipalByPath('principals/users/foo-bar'); + $this->assertEquals(null, $actual); + } + + public function testGetGroupMemberSet() { + $actual = $this->principalBackend->getGroupMemberSet($this->principalPrefix . '/foo-bar'); + $this->assertEquals([], $actual); + } + + public function testGetGroupMembership() { + $actual = $this->principalBackend->getGroupMembership($this->principalPrefix . '/foo-bar'); + $this->assertEquals([], $actual); + } + + /** + * @expectedException \Sabre\DAV\Exception + * @expectedExceptionMessage Setting members of the group is not supported yet + */ + public function testSetGroupMemberSet() { + $this->principalBackend->setGroupMemberSet($this->principalPrefix . '/foo-bar', ['foo', 'bar']); + } + + public function testUpdatePrincipal() { + $propPatch = $this->createMock(PropPatch::class); + $actual = $this->principalBackend->updatePrincipal($this->principalPrefix . '/foo-bar', $propPatch); + + $this->assertEquals(0, $actual); + } + + /** + * @dataProvider dataSearchPrincipals + */ + public function testSearchPrincipals($expected, $test) { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder1 = $this->createMock(IQueryBuilder::class); + $queryBuilder2 = $this->createMock(IQueryBuilder::class); + $stmt1 = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $stmt2 = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr1 = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + $expr2 = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder1)); + $this->dbConnection->expects($this->at(1)) + ->method('escapeLikeParameter') + ->with('foo') + ->will($this->returnValue('escapedFoo')); + $this->dbConnection->expects($this->at(2)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder2)); + $this->dbConnection->expects($this->at(3)) + ->method('escapeLikeParameter') + ->with('bar') + ->will($this->returnValue('escapedBar')); + + $queryBuilder1->method('expr') + ->will($this->returnValue($expr1)); + $queryBuilder2->method('expr') + ->will($this->returnValue($expr2)); + + $expr1->method('iLike') + ->will($this->returnValueMap([ + ['email', 'createNamedParameter-1', null, 'ILIKE_CLAUSE_1'], + ])); + $expr2->method('iLike') + ->will($this->returnValueMap([ + ['displayname', 'createNamedParameter-2', null, 'ILIKE_CLAUSE_2'], + ])); + + $queryBuilder1->method('expr') + ->will($this->returnValue($expr1)); + $queryBuilder2->method('expr') + ->will($this->returnValue($expr2)); + + $queryBuilder1->method('createNamedParameter') + ->will($this->returnValueMap([ + ['%escapedFoo%', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ])); + $queryBuilder2->method('createNamedParameter') + ->will($this->returnValueMap([ + ['%escapedBar%', \PDO::PARAM_STR, null, 'createNamedParameter-2'], + ])); + + $queryBuilder1->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder1)); + $queryBuilder1->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder1)); + $queryBuilder1->expects($this->at(4)) + ->method('where') + ->with('ILIKE_CLAUSE_1') + ->will($this->returnValue($queryBuilder1)); + $queryBuilder1->expects($this->at(5)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt1)); + + $queryBuilder2->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder2)); + $queryBuilder2->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder2)); + $queryBuilder2->expects($this->at(4)) + ->method('where') + ->with('ILIKE_CLAUSE_2') + ->will($this->returnValue($queryBuilder2)); + $queryBuilder2->expects($this->at(5)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt2)); + + $stmt1->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '1', + 'email' => '1', + 'displayname' => 'Resource 1', + 'group_restrictions' => null, + ])); + $stmt1->expects($this->at(1)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 1, + 'backend_id' => 'db', + 'resource_id' => '2', + 'email' => '2', + 'displayname' => 'Resource 2', + 'group_restrictions' => '', + ])); + $stmt1->expects($this->at(2)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 2, + 'backend_id' => 'db', + 'resource_id' => '3', + 'email' => '3', + 'displayname' => 'Resource 3', + 'group_restrictions' => '["group3"]', + ])); + $stmt1->expects($this->at(3)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 99, + 'backend_id' => 'db', + 'resource_id' => '99', + 'email' => '99', + 'displayname' => 'Resource 99', + 'group_restrictions' => '["group1", "group2"]', + ])); + $stmt1->expects($this->at(4)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue(null)); + + $stmt2->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '4', + 'email' => '4', + 'displayname' => 'Resource 4', + 'group_restrictions' => '[]' + ])); + $stmt2->expects($this->at(1)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 1, + 'backend_id' => 'db', + 'resource_id' => '5', + 'email' => '5', + 'displayname' => 'Resource 5', + 'group_restrictions' => '["group1", "group5"]' + ])); + $stmt2->expects($this->at(2)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 99, + 'backend_id' => 'db', + 'resource_id' => '99', + 'email' => '99', + 'displayname' => 'Resource 99', + 'group_restrictions' => '["group1", "group2"]', + ])); + $stmt2->expects($this->at(3)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue(null)); + + $actual = $this->principalBackend->searchPrincipals($this->principalPrefix, [ + '{http://sabredav.org/ns}email-address' => 'foo', + '{DAV:}displayname' => 'bar', + ], $test); + + $this->assertEquals( + str_replace('%prefix%', $this->principalPrefix, $expected), + $actual); + } + + public function dataSearchPrincipals() { + // data providers are called before we subclass + // this class, $this->principalPrefix is null + // at that point, so we need this hack + return [ + [[ + '%prefix%/db-99' + ], 'allof'], + [[ + '%prefix%/db-1', + '%prefix%/db-2', + '%prefix%/db-99', + '%prefix%/db-4', + '%prefix%/db-5', + ], 'anyof'], + ]; + } + + public function testSearchPrincipalsEmptySearchProperties() { + $this->userSession->expects($this->never()) + ->method('getUser'); + $this->groupManager->expects($this->never()) + ->method('getUserGroupIds'); + $this->dbConnection->expects($this->never()) + ->method('getQueryBuilder'); + + $this->principalBackend->searchPrincipals($this->principalPrefix, []); + } + + public function testSearchPrincipalsWrongPrincipalPrefix() { + $this->userSession->expects($this->never()) + ->method('getUser'); + $this->groupManager->expects($this->never()) + ->method('getUserGroupIds'); + $this->dbConnection->expects($this->never()) + ->method('getQueryBuilder'); + + $this->principalBackend->searchPrincipals('principals/users', [ + '{http://sabredav.org/ns}email-address' => 'foo' + ]); + } + + public function testFindByUriByEmail() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['email', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['foo@bar.com', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(5)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '123', + 'email' => 'foo@bar.com', + 'displayname' => 'Resource 123', + 'group_restrictions' => '["group1"]', + ])); + + $actual = $this->principalBackend->findByUri('mailto:foo@bar.com', $this->principalPrefix); + $this->assertEquals($this->principalPrefix . '/db-123', $actual); + } + + public function testFindByUriByEmailForbiddenResource() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['email', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['foo@bar.com', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(5)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '123', + 'email' => 'foo@bar.com', + 'displayname' => 'Resource 123', + 'group_restrictions' => '["group3"]', + ])); + + $actual = $this->principalBackend->findByUri('mailto:foo@bar.com', $this->principalPrefix); + $this->assertEquals(null, $actual); + } + + public function testFindByUriByEmailNotFound() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['email', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['foo@bar.com', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(5)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue(null)); + + $actual = $this->principalBackend->findByUri('mailto:foo@bar.com', $this->principalPrefix); + $this->assertEquals(null, $actual); + } + + public function testFindByUriByPrincipal() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['email', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['foo@bar.com', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(5)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '123', + 'email' => 'foo@bar.com', + 'displayname' => 'Resource 123', + 'group_restrictions' => '["group1"]', + ])); + + $actual = $this->principalBackend->findByUri('mailto:foo@bar.com', $this->principalPrefix); + $this->assertEquals($this->principalPrefix . '/db-123', $actual); + } + + public function testFindByUriByPrincipalForbiddenResource() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['backend_id', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ['resource_id', 'createNamedParameter-2', null, 'WHERE_CLAUSE_2'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['db', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ['123', \PDO::PARAM_STR, null, 'createNamedParameter-2'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(7)) + ->method('andWhere') + ->with('WHERE_CLAUSE_2') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(8)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue([ + 'id' => 0, + 'backend_id' => 'db', + 'resource_id' => '123', + 'email' => 'foo@bar.com', + 'displayname' => 'Resource 123', + 'group_restrictions' => '["group3"]', + ])); + + $actual = $this->principalBackend->findByUri('principal:' . $this->principalPrefix . '/db-123', $this->principalPrefix); + $this->assertEquals(null, $actual); + } + + public function testFindByUriByPrincipalNotFound() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $queryBuilder = $this->createMock(IQueryBuilder::class); + $stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class); + $expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class); + + $this->dbConnection->expects($this->at(0)) + ->method('getQueryBuilder') + ->with() + ->will($this->returnValue($queryBuilder)); + $queryBuilder->method('expr') + ->will($this->returnValue($expr)); + $expr->method('eq') + ->will($this->returnValueMap([ + ['backend_id', 'createNamedParameter-1', null, 'WHERE_CLAUSE_1'], + ['resource_id', 'createNamedParameter-2', null, 'WHERE_CLAUSE_2'], + ])); + $queryBuilder->method('createNamedParameter') + ->will($this->returnValueMap([ + ['db', \PDO::PARAM_STR, null, 'createNamedParameter-1'], + ['123', \PDO::PARAM_STR, null, 'createNamedParameter-2'], + ])); + + $queryBuilder->expects($this->at(0)) + ->method('select') + ->with(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions']) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(1)) + ->method('from') + ->with($this->expectedDbTable) + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(4)) + ->method('where') + ->with('WHERE_CLAUSE_1') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(7)) + ->method('andWhere') + ->with('WHERE_CLAUSE_2') + ->will($this->returnValue($queryBuilder)); + $queryBuilder->expects($this->at(8)) + ->method('execute') + ->with() + ->will($this->returnValue($stmt)); + + $stmt->expects($this->at(0)) + ->method('fetch') + ->with(\PDO::FETCH_ASSOC) + ->will($this->returnValue(null)); + + $actual = $this->principalBackend->findByUri('principal:' . $this->principalPrefix . '/db-123', $this->principalPrefix); + $this->assertEquals(null, $actual); + } + + public function testFindByUriByUnknownUri() { + $user = $this->createMock(IUser::class); + $this->userSession->expects($this->once()) + ->method('getUser') + ->with() + ->will($this->returnValue($user)); + $this->groupManager->expects($this->once()) + ->method('getUserGroupIds') + ->with($user) + ->will($this->returnValue(['group1', 'group2'])); + + $actual = $this->principalBackend->findByUri('foobar:blub', $this->principalPrefix); + $this->assertEquals(null, $actual); + } + +} diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php new file mode 100644 index 00000000000..f2c6b6f5f5e --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php @@ -0,0 +1,35 @@ +<?php +/** + * @copyright Copyright (c) 2018, Georg Ehrke + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCA\DAV\Tests\unit\CalDAV\ResourceBooking; + +use OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend; + +Class ResourcePrincipalBackendTest extends AbstractPrincipalBackendTest { + public function setUp() { + parent::setUp(); + + $this->principalBackend = new ResourcePrincipalBackend($this->dbConnection, + $this->userSession, $this->groupManager, $this->logger); + $this->expectedDbTable = 'calendar_resources_cache'; + $this->principalPrefix = 'principals/calendar-resources'; + } +} diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php new file mode 100644 index 00000000000..f45121f4548 --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php @@ -0,0 +1,35 @@ +<?php +/** + * @copyright Copyright (c) 2018, Georg Ehrke + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ +namespace OCA\DAV\Tests\unit\CalDAV\ResourceBooking; + +use OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend; + +Class RoomPrincipalBackendTest extends AbstractPrincipalBackendTest { + public function setUp() { + parent::setUp(); + + $this->principalBackend = new RoomPrincipalBackend($this->dbConnection, + $this->userSession, $this->groupManager, $this->logger); + $this->expectedDbTable = 'calendar_rooms_cache'; + $this->principalPrefix = 'principals/calendar-rooms'; + } +} |