function setup() { $this->caldavBackend = new CalDAV\Backend\MockSharing(); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $calendars = new CalDAV\CalendarRoot($principalBackend, $this->caldavBackend); $principals = new CalDAV\Principal\Collection($principalBackend); $root = new DAV\SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $this->server = new DAV\Server($root); $this->server->sapi = new HTTP\SapiMock(); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new DAVACL\Plugin()); // CalDAV is also required. $this->server->addPlugin(new CalDAV\Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->defaultUser = '******'; $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV'); $this->server->addPlugin($authPlugin); // This forces a login $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; }
function setup() { $this->caldavBackend = new Backend\Mock(array(array('id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO'))), array('id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', '{urn:ietf:params:xml:ns:caldav}calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set' => new Property\SupportedCalendarComponentSet(array('VEVENT', 'VTODO')))), array(1 => array('UUID-2345' => array('calendardata' => TestUtil::getTestCalendarData())))); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', array('principals/user1')); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', array('principals/user1')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-read')); $principalBackend->addPrincipal(array('uri' => 'principals/admin/calendar-proxy-write')); $calendars = new CalendarRootNode($principalBackend, $this->caldavBackend); $principals = new Principal\Collection($principalBackend); $root = new DAV\SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $objectTree = new DAV\ObjectTree($root); $this->server = new DAV\Server($objectTree); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new DAVACL\Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->defaultUser = '******'; $authPlugin = new DAV\Auth\Plugin($authBackend, 'SabreDAV'); $this->server->addPlugin($authPlugin); $authPlugin->beforeMethod('GET', '/'); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; }
function setup() { $caldavNS = '{urn:ietf:params:xml:ns:caldav}'; $this->caldavBackend = new Backend\Mock([['id' => 1, 'uri' => 'UUID-123467', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar', $caldavNS . 'calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO'])], ['id' => 2, 'uri' => 'UUID-123468', 'principaluri' => 'principals/user1', '{DAV:}displayname' => 'user1 calendar2', $caldavNS . 'calendar-description' => 'Calendar description', '{http://apple.com/ns/ical/}calendar-order' => '1', '{http://apple.com/ns/ical/}calendar-color' => '#FF0000', $caldavNS . 'supported-calendar-component-set' => new Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO'])]], [1 => ['UUID-2345' => ['calendardata' => TestUtil::getTestCalendarData()]]]); $principalBackend = new DAVACL\PrincipalBackend\Mock(); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-read', ['principals/user1']); $principalBackend->setGroupMemberSet('principals/admin/calendar-proxy-write', ['principals/user1']); $principalBackend->addPrincipal(['uri' => 'principals/admin/calendar-proxy-read']); $principalBackend->addPrincipal(['uri' => 'principals/admin/calendar-proxy-write']); $calendars = new CalendarRoot($principalBackend, $this->caldavBackend); $principals = new Principal\Collection($principalBackend); $root = new DAV\SimpleCollection('root'); $root->addChild($calendars); $root->addChild($principals); $this->server = new DAV\Server($root); $this->server->sapi = new HTTP\SapiMock(); $this->server->debugExceptions = true; $this->server->setBaseUri('/'); $this->plugin = new Plugin(); $this->server->addPlugin($this->plugin); // Adding ACL plugin $this->server->addPlugin(new DAVACL\Plugin()); // Adding Auth plugin, and ensuring that we are logged in. $authBackend = new DAV\Auth\Backend\Mock(); $authBackend->setPrincipal('principals/user1'); $authPlugin = new DAV\Auth\Plugin($authBackend); $authPlugin->beforeMethod(new \Sabre\HTTP\Request(), new \Sabre\HTTP\Response()); $this->server->addPlugin($authPlugin); // This forces a login $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response()); $this->response = new HTTP\ResponseMock(); $this->server->httpResponse = $this->response; }
function getServer() { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); $principals = new PrincipalCollection($backend); $dir->addChild($principals); $fakeServer = new DAV\Server(new DAV\ObjectTree($dir)); $fakeServer->httpResponse = new HTTP\ResponseMock(); $plugin = new Plugin($backend, 'realm'); $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; }
function getServer() { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); $principals = new PrincipalCollection($backend); $dir->addChild($principals); $fakeServer = new DAV\Server($dir); $fakeServer->sapi = new HTTP\SapiMock(); $fakeServer->httpResponse = new HTTP\ResponseMock(); $plugin = new Plugin(); $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; }
public function setUp() { parent::setUp(); /** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ $authBackend = $this->getMockBuilder('OCA\\DAV\\Connector\\Sabre\\Auth')->disableOriginalConstructor()->getMock(); $authBackend->method('isDavAuthenticated')->willReturn(true); /** @var IRequest $request */ $request = $this->getMockBuilder('OCP\\IRequest')->disableOriginalConstructor()->getMock(); $this->plugin = new Plugin($authBackend, $request); $root = new SimpleCollection('root'); $this->server = new \Sabre\DAV\Server($root); /** @var SimpleCollection $node */ $this->book = $this->getMockBuilder('OCA\\DAV\\DAV\\Sharing\\IShareable')->disableOriginalConstructor()->getMock(); $this->book->method('getName')->willReturn('addressbook1.vcf'); $root->addChild($this->book); $this->plugin->initialize($this->server); }
function getServer() { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); $principals = new PrincipalCollection($backend); $dir->addChild($principals); $fakeServer = new DAV\Server($dir); $fakeServer->sapi = new HTTP\SapiMock(); $fakeServer->httpResponse = new HTTP\ResponseMock(); $fakeServer->debugExceptions = true; $plugin = new MockPlugin($backend, 'realm'); $plugin->allowAccessToNodesWithoutACL = true; $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; }