|
|
|
@ -767,11 +767,294 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
self::invokePrivate($this->manager, 'generalCreateChecks', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateInPast() {
|
|
|
|
|
public function testValidateExpirationDateInternalInPast() {
|
|
|
|
|
$this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
|
|
|
|
|
$this->expectExceptionMessage('Expiration date is in the past');
|
|
|
|
|
|
|
|
|
|
// Expire date in the past
|
|
|
|
|
$past = new \DateTime();
|
|
|
|
|
$past->sub(new \DateInterval('P1D'));
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($past);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalEnforceButNotSet() {
|
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
|
$this->expectExceptionMessage('Expiration date is enforced');
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setProviderId('foo')->setId('bar');
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_enforce_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalEnforceButNotEnabledAndNotSet() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setProviderId('foo')->setId('bar');
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertNull($share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalEnforceButNotSetNewShare() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'internal_defaultExpDays', '3', '3'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$expected = new \DateTime();
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
$expected->add(new \DateInterval('P3D'));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($share->getExpirationDate());
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalEnforceRelaxedDefaultButNotSetNewShare() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'internal_defaultExpDays', '3', '1'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$expected = new \DateTime();
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
$expected->add(new \DateInterval('P1D'));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($share->getExpirationDate());
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalEnforceTooFarIntoFuture() {
|
|
|
|
|
$this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
|
|
|
|
|
$this->expectExceptionMessage('Can’t set expiration date more than 3 days in the future');
|
|
|
|
|
|
|
|
|
|
$future = new \DateTime();
|
|
|
|
|
$future->add(new \DateInterval('P7D'));
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($future);
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalEnforceValid() {
|
|
|
|
|
$future = new \DateTime();
|
|
|
|
|
$future->add(new \DateInterval('P2D'));
|
|
|
|
|
$future->setTime(1,2,3);
|
|
|
|
|
|
|
|
|
|
$expected = clone $future;
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($future);
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($future) {
|
|
|
|
|
return $data['expirationDate'] == $future;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalNoDefault() {
|
|
|
|
|
$date = new \DateTime();
|
|
|
|
|
$date->add(new \DateInterval('P5D'));
|
|
|
|
|
$date->setTime(1,2,3);
|
|
|
|
|
|
|
|
|
|
$expected = clone $date;
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($date);
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
return $data['expirationDate'] == $expected && $data['passwordSet'] === false;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalNoDateNoDefault() {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) {
|
|
|
|
|
return $data['expirationDate'] === null && $data['passwordSet'] === true;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setPassword('password');
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertNull($share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalNoDateDefault() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$expected = new \DateTime();
|
|
|
|
|
$expected->add(new \DateInterval('P3D'));
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'internal_defaultExpDays', '3', '3'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
return $data['expirationDate'] == $expected;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalDefault() {
|
|
|
|
|
$future = new \DateTime();
|
|
|
|
|
$future->add(new \DateInterval('P5D'));
|
|
|
|
|
$future->setTime(1,2,3);
|
|
|
|
|
|
|
|
|
|
$expected = clone $future;
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($future);
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'internal_defaultExpDays', '3', '1'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
return $data['expirationDate'] == $expected;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalHookModification() {
|
|
|
|
|
$nextWeek = new \DateTime();
|
|
|
|
|
$nextWeek->add(new \DateInterval('P7D'));
|
|
|
|
|
$nextWeek->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$save = clone $nextWeek;
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
|
|
|
|
|
$data['expirationDate']->sub(new \DateInterval('P2D'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($nextWeek);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$save->sub(new \DateInterval('P2D'));
|
|
|
|
|
$this->assertEquals($save, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalHookException() {
|
|
|
|
|
$this->expectException(\Exception::class);
|
|
|
|
|
$this->expectExceptionMessage('Invalid date!');
|
|
|
|
|
|
|
|
|
|
$nextWeek = new \DateTime();
|
|
|
|
|
$nextWeek->add(new \DateInterval('P7D'));
|
|
|
|
|
$nextWeek->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($nextWeek);
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
|
|
|
|
|
$data['accepted'] = false;
|
|
|
|
|
$data['message'] = 'Invalid date!';
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInternalExistingShareNoDefault() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$share->setId('42')->setProviderId('foo');
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_default_internal_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_internal_expire_after_n_days', '7', '6'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDateInternal', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(null, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateInPast() {
|
|
|
|
|
$this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
|
|
|
|
|
$this->expectExceptionMessage('Expiration date is in the past');
|
|
|
|
|
|
|
|
|
|
// Expire date in the past
|
|
|
|
|
$past = new \DateTime();
|
|
|
|
@ -783,8 +1066,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateEnforceButNotSet() {
|
|
|
|
|
public function testValidateExpirationDateEnforceButNotSet() {
|
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
|
$this->expectExceptionMessage('Expiration date is enforced');
|
|
|
|
|
|
|
|
|
@ -800,7 +1082,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateEnforceButNotEnabledAndNotSet() {
|
|
|
|
|
public function testValidateExpirationDateEnforceButNotEnabledAndNotSet() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setProviderId('foo')->setId('bar');
|
|
|
|
|
|
|
|
|
@ -814,7 +1096,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertNull($share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateEnforceButNotSetNewShare() {
|
|
|
|
|
public function testValidateExpirationDateEnforceButNotSetNewShare() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
@ -835,8 +1117,31 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateEnforceToFarIntoFuture() {
|
|
|
|
|
// Expire date in the past
|
|
|
|
|
public function testValidateExpirationDateEnforceRelaxedDefaultButNotSetNewShare() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'link_defaultExpDays', 3, '1'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$expected = new \DateTime();
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
$expected->add(new \DateInterval('P1D'));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertNotNull($share->getExpirationDate());
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateEnforceTooFarIntoFuture() {
|
|
|
|
|
$this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
|
|
|
|
|
$this->expectExceptionMessage('Can’t set expiration date more than 3 days in the future');
|
|
|
|
|
|
|
|
|
|
$future = new \DateTime();
|
|
|
|
|
$future->add(new \DateInterval('P7D'));
|
|
|
|
|
|
|
|
|
@ -847,26 +1152,19 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
|
|
|
|
$this->addToAssertionCount(1);
|
|
|
|
|
} catch (\OCP\Share\Exceptions\GenericShareException $e) {
|
|
|
|
|
$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getMessage());
|
|
|
|
|
$this->assertEquals('Cannot set expiration date more than 3 days in the future', $e->getHint());
|
|
|
|
|
$this->assertEquals(404, $e->getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateEnforceValid() {
|
|
|
|
|
// Expire date in the past
|
|
|
|
|
public function testValidateExpirationDateEnforceValid() {
|
|
|
|
|
$future = new \DateTime();
|
|
|
|
|
$future->add(new \DateInterval('P2D'));
|
|
|
|
|
$future->setTime(0,0,0);
|
|
|
|
|
$future->setTime(1,2,3);
|
|
|
|
|
|
|
|
|
|
$expected = clone $future;
|
|
|
|
|
$future->setTime(1,2,3);
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($future);
|
|
|
|
@ -875,11 +1173,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener');
|
|
|
|
|
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($future) {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($future) {
|
|
|
|
|
return $data['expirationDate'] == $future;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
@ -888,9 +1187,10 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateNoDateNoDefaultNull() {
|
|
|
|
|
public function testValidateExpirationDateNoDefault() {
|
|
|
|
|
$date = new \DateTime();
|
|
|
|
|
$date->add(new \DateInterval('P5D'));
|
|
|
|
|
$date->setTime(1,2,3);
|
|
|
|
|
|
|
|
|
|
$expected = clone $date;
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
@ -898,9 +1198,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($date);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener');
|
|
|
|
|
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
return $data['expirationDate'] == $expected && $data['passwordSet'] === false;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
@ -909,10 +1209,10 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateNoDateNoDefault() {
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener');
|
|
|
|
|
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) {
|
|
|
|
|
public function testValidateExpirationDateNoDateNoDefault() {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) {
|
|
|
|
|
return $data['expirationDate'] === null && $data['passwordSet'] === true;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
@ -924,12 +1224,38 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertNull($share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testvalidateExpirationDateNoDateDefault() {
|
|
|
|
|
public function testValidateExpirationDateNoDateDefault() {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
|
|
|
|
|
$expected = new \DateTime();
|
|
|
|
|
$expected->add(new \DateInterval('P3D'));
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'link_defaultExpDays', 3, '3'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
return $data['expirationDate'] == $expected;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateDefault() {
|
|
|
|
|
$future = new \DateTime();
|
|
|
|
|
$future->add(new \DateInterval('P3D'));
|
|
|
|
|
$future->setTime(0,0,0);
|
|
|
|
|
$future->add(new \DateInterval('P5D'));
|
|
|
|
|
$future->setTime(1,2,3);
|
|
|
|
|
|
|
|
|
|
$expected = clone $future;
|
|
|
|
|
$expected->setTime(0,0,0);
|
|
|
|
|
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($future);
|
|
|
|
@ -938,11 +1264,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->willReturnMap([
|
|
|
|
|
['core', 'shareapi_default_expire_date', 'no', 'yes'],
|
|
|
|
|
['core', 'shareapi_expire_after_n_days', '7', '3'],
|
|
|
|
|
['core', 'link_defaultExpDays', 3, '1'],
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener');
|
|
|
|
|
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
|
|
|
|
|
return $data['expirationDate'] == $expected;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
@ -958,9 +1285,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
$save = clone $nextWeek;
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener');
|
|
|
|
|
$hookListner->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
|
|
|
|
|
$data['expirationDate']->sub(new \DateInterval('P2D'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -973,7 +1300,6 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertEquals($save, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testValidateExpirationDateHookException() {
|
|
|
|
|
$this->expectException(\Exception::class);
|
|
|
|
|
$this->expectExceptionMessage('Invalid date!');
|
|
|
|
@ -985,9 +1311,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$share = $this->manager->newShare();
|
|
|
|
|
$share->setExpirationDate($nextWeek);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener');
|
|
|
|
|
$hookListner->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
|
|
|
|
|
$hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
|
|
|
|
|
$data['accepted'] = false;
|
|
|
|
|
$data['message'] = 'Invalid date!';
|
|
|
|
|
});
|
|
|
|
@ -1011,7 +1337,6 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->assertEquals(null, $share->getExpirationDate());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() {
|
|
|
|
|
$this->expectException(\Exception::class);
|
|
|
|
|
$this->expectExceptionMessage('Sharing is only allowed with group members');
|
|
|
|
@ -2609,16 +2934,16 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->with($share)
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$this->rootFolder->method('getUserFolder')->with('newUser')->willReturnSelf();
|
|
|
|
|
$this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->once())->method('post')->with([
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'shareType' => IShare::TYPE_USER,
|
|
|
|
@ -2666,13 +2991,13 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->with($share)
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -2728,18 +3053,18 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->with($share)
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->once())->method('post')->with([
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'date' => $tomorrow,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->once())->method('post')->with([
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
@ -2747,9 +3072,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
'disabled' => false,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
@ -2809,17 +3134,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -2878,13 +3203,13 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->with($share, 'password')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->once())->method('post')->with([
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
@ -2892,9 +3217,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
'disabled' => false,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -2956,13 +3281,13 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->with($share, 'password')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->once())->method('post')->with([
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
@ -2970,9 +3295,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
'disabled' => false,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3039,13 +3364,13 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->with($share, 'password')
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->once())->method('post')->with([
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
@ -3053,9 +3378,9 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
'disabled' => false,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3116,17 +3441,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3188,17 +3513,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3260,17 +3585,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3337,17 +3662,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3413,17 +3738,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
@ -3487,17 +3812,17 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$this->defaultProvider->expects($this->never())
|
|
|
|
|
->method('update');
|
|
|
|
|
|
|
|
|
|
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post');
|
|
|
|
|
$hookListner->expects($this->never())->method('post');
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post');
|
|
|
|
|
$hookListner2->expects($this->never())->method('post');
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
$hookListener2->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post');
|
|
|
|
|
$hookListner3->expects($this->never())->method('post');
|
|
|
|
|
$hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
|
|
|
|
|
$hookListener3->expects($this->never())->method('post');
|
|
|
|
|
|
|
|
|
|
$manager->updateShare($share);
|
|
|
|
|
}
|
|
|
|
|