Update Sabre (and friends) to 4.0tags/v19.0.0beta1
@@ -1 +1 @@ | |||
Subproject commit a70e51b4cce278e006090d91cf26d616cb73e911 | |||
Subproject commit 179b231245bbae294d021b7158f99c3ffe7e2cb6 |
@@ -256,6 +256,7 @@ class BirthdayService { | |||
$vCal = new VCalendar(); | |||
$vCal->VERSION = '2.0'; | |||
$vCal->PRODID = '-//IDN nextcloud.com//Birthday calendar//EN'; | |||
$vEvent = $vCal->createComponent('VEVENT'); | |||
$vEvent->add('DTSTART'); | |||
$vEvent->DTSTART->setDateTime( |
@@ -94,7 +94,7 @@ class InvitationResponseServer { | |||
)); | |||
// wait with registering these until auth is handled and the filesystem is setup | |||
$this->server->on('beforeMethod', function () use ($root) { | |||
$this->server->on('beforeMethod:*', function () use ($root) { | |||
// register plugins from apps | |||
$pluginManager = new PluginManager( | |||
\OC::$server, |
@@ -83,7 +83,7 @@ class Plugin extends ServerPlugin { | |||
*/ | |||
public function initialize(Server $server) { | |||
$this->server = $server; | |||
$server->on('beforeMethod', [$this, 'beforeMethod']); | |||
$server->on('beforeMethod:*', [$this, 'beforeMethod']); | |||
} | |||
/** |
@@ -46,7 +46,7 @@ class AnonymousOptionsPlugin extends ServerPlugin { | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$this->server = $server; | |||
// before auth | |||
$this->server->on('beforeMethod', [$this, 'handleAnonymousOptions'], 9); | |||
$this->server->on('beforeMethod:*', [$this, 'handleAnonymousOptions'], 9); | |||
} | |||
/** |
@@ -74,7 +74,7 @@ class AppEnabledPlugin extends ServerPlugin { | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$this->server = $server; | |||
$this->server->on('beforeMethod', [$this, 'checkAppEnabled'], 30); | |||
$this->server->on('beforeMethod:*', [$this, 'checkAppEnabled'], 30); | |||
} | |||
/** |
@@ -53,7 +53,7 @@ class BlockLegacyClientPlugin extends ServerPlugin { | |||
*/ | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$this->server = $server; | |||
$this->server->on('beforeMethod', [$this, 'beforeHandler'], 200); | |||
$this->server->on('beforeMethod:*', [$this, 'beforeHandler'], 200); | |||
} | |||
/** |
@@ -45,7 +45,7 @@ class LockPlugin extends ServerPlugin { | |||
*/ | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$this->server = $server; | |||
$this->server->on('beforeMethod', [$this, 'getLock'], 50); | |||
$this->server->on('beforeMethod:*', [$this, 'getLock'], 50); | |||
$this->server->on('afterMethod', [$this, 'releaseLock'], 50); | |||
} | |||
@@ -67,7 +67,7 @@ class MaintenancePlugin extends ServerPlugin { | |||
*/ | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$this->server = $server; | |||
$this->server->on('beforeMethod', [$this, 'checkMaintenanceMode'], 1); | |||
$this->server->on('beforeMethod:*', [$this, 'checkMaintenanceMode'], 1); | |||
} | |||
/** |
@@ -140,7 +140,7 @@ class ServerFactory { | |||
} | |||
// wait with registering these until auth is handled and the filesystem is setup | |||
$server->on('beforeMethod', function () use ($server, $objectTree, $viewCallBack) { | |||
$server->on('beforeMethod:*', function () use ($server, $objectTree, $viewCallBack) { | |||
// ensure the skeleton is copied | |||
$userFolder = \OC::$server->getUserFolder(); | |||
@@ -61,7 +61,7 @@ class FilesDropPlugin extends ServerPlugin { | |||
* @throws MethodNotAllowed | |||
*/ | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$server->on('beforeMethod', [$this, 'beforeMethod'], 999); | |||
$server->on('beforeMethod:*', [$this, 'beforeMethod'], 999); | |||
$this->enabled = false; | |||
} | |||
@@ -52,7 +52,7 @@ class PublicLinkCheckPlugin extends ServerPlugin { | |||
* @return void | |||
*/ | |||
public function initialize(\Sabre\DAV\Server $server) { | |||
$server->on('beforeMethod', [$this, 'beforeMethod']); | |||
$server->on('beforeMethod:*', [$this, 'beforeMethod']); | |||
} | |||
public function beforeMethod(RequestInterface $request, ResponseInterface $response){ |
@@ -217,7 +217,7 @@ class Server { | |||
$this->server->addPlugin(new SearchPlugin($lazySearchBackend)); | |||
// wait with registering these until auth is handled and the filesystem is setup | |||
$this->server->on('beforeMethod', function () use ($root, $lazySearchBackend) { | |||
$this->server->on('beforeMethod:*', function () use ($root, $lazySearchBackend) { | |||
// custom properties plugin must be the last one | |||
$userSession = \OC::$server->getUserSession(); | |||
$user = $userSession->getUser(); |
@@ -82,9 +82,8 @@ class PluginTest extends TestCase { | |||
$this->book->expects($this->once())->method('setPublishStatus')->with(true); | |||
// setup request | |||
$request = new Request(); | |||
$request = new Request('POST', 'cal1'); | |||
$request->addHeader('Content-Type', 'application/xml'); | |||
$request->setUrl('cal1'); | |||
$request->setBody('<o:publish-calendar xmlns:o="http://calendarserver.org/ns/"/>'); | |||
$response = new Response(); | |||
$this->plugin->httpPost($request, $response); | |||
@@ -95,9 +94,8 @@ class PluginTest extends TestCase { | |||
$this->book->expects($this->once())->method('setPublishStatus')->with(false); | |||
// setup request | |||
$request = new Request(); | |||
$request = new Request('POST', 'cal1'); | |||
$request->addHeader('Content-Type', 'application/xml'); | |||
$request->setUrl('cal1'); | |||
$request->setBody('<o:unpublish-calendar xmlns:o="http://calendarserver.org/ns/"/>'); | |||
$response = new Response(); | |||
$this->plugin->httpPost($request, $response); |
@@ -91,6 +91,7 @@ class BirthdayServiceTest extends TestCase { | |||
$this->assertNull($cal); | |||
} else { | |||
$this->assertInstanceOf('Sabre\VObject\Component\VCalendar', $cal); | |||
$this->assertEquals('-//IDN nextcloud.com//Birthday calendar//EN', $cal->PRODID->getValue()); | |||
$this->assertTrue(isset($cal->VEVENT)); | |||
$this->assertEquals('FREQ=YEARLY', $cal->VEVENT->RRULE->getValue()); | |||
$this->assertEquals($expectedSummary, $cal->VEVENT->SUMMARY->getValue()); | |||
@@ -259,21 +260,27 @@ class BirthdayServiceTest extends TestCase { | |||
); | |||
} | |||
if ($expectedOp === 'create') { | |||
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar()); | |||
$vCal = new VCalendar(); | |||
$vCal->PRODID = '-//Nextcloud testing//mocked object//'; | |||
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn($vCal); | |||
$this->calDav->expects($this->exactly(3))->method('createCalendarObject')->withConsecutive( | |||
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"] | |||
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"] | |||
); | |||
} | |||
if ($expectedOp === 'update') { | |||
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar()); | |||
$vCal = new VCalendar(); | |||
$vCal->PRODID = '-//Nextcloud testing//mocked object//'; | |||
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn($vCal); | |||
$service->expects($this->exactly(3))->method('birthdayEvenChanged')->willReturn(true); | |||
$this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn(['calendardata' => '']); | |||
$this->calDav->expects($this->exactly(3))->method('updateCalendarObject')->withConsecutive( | |||
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"] | |||
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"], | |||
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"] | |||
); | |||
} | |||
@@ -47,7 +47,7 @@ class PluginTest extends TestCase { | |||
protected function setUp(): void { | |||
parent::setUp(); | |||
/** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ | |||
$authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock(); | |||
$authBackend->method('isDavAuthenticated')->willReturn(true); | |||
@@ -75,9 +75,8 @@ class PluginTest extends TestCase { | |||
]], ['mailto:wilfredo@example.com']); | |||
// setup request | |||
$request = new Request(); | |||
$request = new Request('POST', 'addressbook1.vcf'); | |||
$request->addHeader('Content-Type', 'application/xml'); | |||
$request->setUrl('addressbook1.vcf'); | |||
$request->setBody('<?xml version="1.0" encoding="utf-8" ?><CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"><CS:set><D:href>principal:principals/admin</D:href><CS:read-write/></CS:set> <CS:remove><D:href>mailto:wilfredo@example.com</D:href></CS:remove></CS:share>'); | |||
$response = new Response(); | |||
$this->plugin->httpPost($request, $response); |
@@ -54,7 +54,7 @@ class CopyEtagHeaderPluginTest extends TestCase { | |||
} | |||
public function testCopyEtag() { | |||
$request = new \Sabre\Http\Request(); | |||
$request = new \Sabre\Http\Request('GET', 'dummy.file'); | |||
$response = new \Sabre\Http\Response(); | |||
$response->setHeader('Etag', 'abcd'); | |||
@@ -64,7 +64,7 @@ class CopyEtagHeaderPluginTest extends TestCase { | |||
} | |||
public function testNoopWhenEmpty() { | |||
$request = new \Sabre\Http\Request(); | |||
$request = new \Sabre\Http\Request('GET', 'dummy.file'); | |||
$response = new \Sabre\Http\Response(); | |||
$this->plugin->afterMethod($request, $response); |
@@ -172,7 +172,7 @@ class FakeLockerPluginTest extends TestCase { | |||
$this->assertSame(false, $this->fakeLockerPlugin->fakeLockProvider($request, $response)); | |||
$expectedXml = '<?xml version="1.0" encoding="utf-8"?><d:prop xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:lockdiscovery><d:activelock><d:lockscope><d:exclusive/></d:lockscope><d:locktype><d:write/></d:locktype><d:lockroot><d:href>MyPath</d:href></d:lockroot><d:depth>infinity</d:depth><d:timeout>Second-1800</d:timeout><d:locktoken><d:href>opaquelocktoken:fe4f7f2437b151fbcb4e9f5c8118c6b1</d:href></d:locktoken><d:owner/></d:activelock></d:lockdiscovery></d:prop>'; | |||
$expectedXml = '<?xml version="1.0" encoding="utf-8"?><d:prop xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"><d:lockdiscovery><d:activelock><d:lockscope><d:exclusive/></d:lockscope><d:locktype><d:write/></d:locktype><d:lockroot><d:href>MyPath</d:href></d:lockroot><d:depth>infinity</d:depth><d:timeout>Second-1800</d:timeout><d:locktoken><d:href>opaquelocktoken:fe4f7f2437b151fbcb4e9f5c8118c6b1</d:href></d:locktoken></d:activelock></d:lockdiscovery></d:prop>'; | |||
$this->assertXmlStringEqualsXmlString($expectedXml, $response->getBody()); | |||
} |
@@ -62,7 +62,7 @@ class QuotaPluginTest extends TestCase { | |||
$this->init(0); | |||
$this->plugin->expects($this->never()) | |||
->method('getFileChunking'); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); | |||
$length = $this->plugin->getLength(); | |||
$this->assertEquals($expected, $length); | |||
} | |||
@@ -75,7 +75,7 @@ class QuotaPluginTest extends TestCase { | |||
$this->plugin->expects($this->never()) | |||
->method('getFileChunking'); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); | |||
$result = $this->plugin->checkQuota(''); | |||
$this->assertTrue($result); | |||
} | |||
@@ -90,7 +90,7 @@ class QuotaPluginTest extends TestCase { | |||
$this->plugin->expects($this->never()) | |||
->method('getFileChunking'); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); | |||
$this->plugin->checkQuota(''); | |||
} | |||
@@ -102,7 +102,7 @@ class QuotaPluginTest extends TestCase { | |||
$this->plugin->expects($this->never()) | |||
->method('getFileChunking'); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); | |||
$result = $this->plugin->checkQuota('/sub/test.txt'); | |||
$this->assertTrue($result); | |||
} | |||
@@ -187,7 +187,7 @@ class QuotaPluginTest extends TestCase { | |||
->willReturn($mockChunking); | |||
$headers['OC-CHUNKED'] = 1; | |||
$this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); | |||
$result = $this->plugin->checkQuota('/sub/test.txt-chunking-12345-3-1'); | |||
$this->assertTrue($result); | |||
} | |||
@@ -224,7 +224,7 @@ class QuotaPluginTest extends TestCase { | |||
->willReturn($mockChunking); | |||
$headers['OC-CHUNKED'] = 1; | |||
$this->server->httpRequest = new \Sabre\HTTP\Request(null, null, $headers); | |||
$this->server->httpRequest = new \Sabre\HTTP\Request('POST', 'dummy.file', $headers); | |||
$this->plugin->checkQuota('/sub/test.txt-chunking-12345-3-1'); | |||
} | |||
@@ -92,7 +92,7 @@ abstract class RequestTestCase extends TestCase { | |||
* @return \Sabre\HTTP\Response | |||
* @throws \Exception | |||
*/ | |||
protected function request($view, $user, $password, $method, $url, $body = null, $headers = null) { | |||
protected function request($view, $user, $password, $method, $url, $body = null, $headers = []) { | |||
if (is_string($body)) { | |||
$body = $this->getStream($body); | |||
} |
@@ -47,7 +47,7 @@ class PluginTest extends TestCase { | |||
protected function setUp(): void { | |||
parent::setUp(); | |||
/** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */ | |||
$authBackend = $this->getMockBuilder(Auth::class)->disableOriginalConstructor()->getMock(); | |||
$authBackend->method('isDavAuthenticated')->willReturn(true); | |||
@@ -77,9 +77,8 @@ class PluginTest extends TestCase { | |||
]], ['mailto:wilfredo@example.com']); | |||
// setup request | |||
$request = new Request(); | |||
$request = new Request('POST', 'addressbook1.vcf'); | |||
$request->addHeader('Content-Type', 'application/xml'); | |||
$request->setUrl('addressbook1.vcf'); | |||
$request->setBody('<?xml version="1.0" encoding="utf-8" ?><CS:share xmlns:D="DAV:" xmlns:CS="http://owncloud.org/ns"><CS:set><D:href>principal:principals/admin</D:href><CS:read-write/></CS:set> <CS:remove><D:href>mailto:wilfredo@example.com</D:href></CS:remove></CS:share>'); | |||
$response = new Response(); | |||
$this->plugin->httpPost($request, $response); |
@@ -66,7 +66,7 @@ class FilesDropPluginTest extends TestCase { | |||
$this->server->expects($this->once()) | |||
->method('on') | |||
->with( | |||
$this->equalTo('beforeMethod'), | |||
$this->equalTo('beforeMethod:*'), | |||
$this->equalTo([$this->plugin, 'beforeMethod']), | |||
$this->equalTo(999) | |||
); |
@@ -58,7 +58,7 @@ function handleException($e) { | |||
// we shall not log on RemoteException | |||
$server->addPlugin(new ExceptionLoggerPlugin('webdav', \OC::$server->getLogger())); | |||
} | |||
$server->on('beforeMethod', function () use ($e) { | |||
$server->on('beforeMethod:*', function () use ($e) { | |||
if ($e instanceof RemoteException) { | |||
switch ($e->getCode()) { | |||
case 503: |