Merge pull request #24159 from nextcloud/backport/24069/stable20

[stable20] Fix default internal expiration date
This commit is contained in:
Daniel Calviño Sánchez 2020-11-16 17:46:37 +01:00 committed by GitHub
commit cdbb2b3e4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 627 additions and 177 deletions

View File

@ -72,6 +72,19 @@ trait AppConfiguration {
} }
} }
/**
* @param string $app
* @param string $parameter
* @param string $value
*/
protected function deleteServerConfig($app, $parameter) {
$this->sendingTo('DELETE', "/apps/testing/api/v1/app/{$app}/{$parameter}");
$this->theHTTPStatusCodeShouldBe('200');
if ($this->apiVersion === 1) {
$this->theOCSStatusCodeShouldBe('100');
}
}
protected function setStatusTestingApp($enabled) { protected function setStatusTestingApp($enabled) {
$this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing'); $this->sendingTo(($enabled ? 'post' : 'delete'), '/cloud/apps/testing');
$this->theHTTPStatusCodeShouldBe('200'); $this->theHTTPStatusCodeShouldBe('200');

View File

@ -61,16 +61,16 @@ class CapabilitiesContext implements Context, SnippetAcceptingContext {
} }
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_enabled', 'yes'); $this->deleteServerConfig('core', 'shareapi_enabled');
$this->modifyServerConfig('core', 'shareapi_allow_links', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_links');
$this->modifyServerConfig('core', 'shareapi_allow_public_upload', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_public_upload');
$this->modifyServerConfig('core', 'shareapi_allow_resharing', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_resharing');
$this->modifyServerConfig('files_sharing', 'outgoing_server2server_share_enabled', 'yes'); $this->deleteServerConfig('files_sharing', 'outgoing_server2server_share_enabled');
$this->modifyServerConfig('files_sharing', 'incoming_server2server_share_enabled', 'yes'); $this->deleteServerConfig('files_sharing', 'incoming_server2server_share_enabled');
$this->modifyServerConfig('core', 'shareapi_enforce_links_password', 'no'); $this->deleteServerConfig('core', 'shareapi_enforce_links_password');
$this->modifyServerConfig('core', 'shareapi_allow_public_notification', 'no'); $this->deleteServerConfig('core', 'shareapi_allow_public_notification');
$this->modifyServerConfig('core', 'shareapi_default_expire_date', 'no'); $this->deleteServerConfig('core', 'shareapi_default_expire_date');
$this->modifyServerConfig('core', 'shareapi_enforce_expire_date', 'no'); $this->deleteServerConfig('core', 'shareapi_enforce_expire_date');
$this->modifyServerConfig('core', 'shareapi_allow_group_sharing', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_group_sharing');
} }
} }

View File

@ -97,7 +97,7 @@ class FederationContext implements Context, SnippetAcceptingContext {
} }
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('files_sharing', 'incoming_server2server_group_share_enabled', 'no'); $this->deleteServerConfig('files_sharing', 'incoming_server2server_group_share_enabled');
$this->modifyServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled', 'no'); $this->deleteServerConfig('files_sharing', 'outgoing_server2server_group_share_enabled');
} }
} }

View File

@ -36,8 +36,8 @@ class ShareesContext implements Context, SnippetAcceptingContext {
use AppConfiguration; use AppConfiguration;
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_only_share_with_group_members', 'no'); $this->deleteServerConfig('core', 'shareapi_only_share_with_group_members');
$this->modifyServerConfig('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_share_dialog_user_enumeration');
$this->modifyServerConfig('core', 'shareapi_allow_group_sharing', 'yes'); $this->deleteServerConfig('core', 'shareapi_allow_group_sharing');
} }
} }

View File

@ -37,7 +37,13 @@ class SharingContext implements Context, SnippetAcceptingContext {
use CommandLine; use CommandLine;
protected function resetAppConfigs() { protected function resetAppConfigs() {
$this->modifyServerConfig('core', 'shareapi_default_permissions', '31'); $this->deleteServerConfig('core', 'shareapi_default_permissions');
$this->modifyServerConfig('sharebymail', 'enforcePasswordProtection', 'no'); $this->deleteServerConfig('core', 'shareapi_default_internal_expire_date');
$this->deleteServerConfig('core', 'shareapi_internal_expire_after_n_days');
$this->deleteServerConfig('core', 'internal_defaultExpDays');
$this->deleteServerConfig('core', 'shareapi_default_expire_date');
$this->deleteServerConfig('core', 'shareapi_expire_after_n_days');
$this->deleteServerConfig('core', 'link_defaultExpDays');
$this->deleteServerConfig('sharebymail', 'enforcePasswordProtection');
} }
} }

View File

@ -391,6 +391,112 @@ Feature: sharing
And Share fields of last share match with And Share fields of last share match with
| permissions | 7 | | permissions | 7 |
Scenario: Creating a new internal share with default expiration date
Given user "user0" exists
And user "user1" exists
And As an "user0"
And parameter "shareapi_default_internal_expire_date" of app "core" is set to "yes"
And parameter "shareapi_internal_expire_after_n_days" of app "core" is set to "3"
When creating a share with
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| expiration | +3 days |
Scenario: Creating a new internal share with relaxed default expiration date
Given user "user0" exists
And user "user1" exists
And As an "user0"
And parameter "shareapi_default_internal_expire_date" of app "core" is set to "yes"
And parameter "shareapi_internal_expire_after_n_days" of app "core" is set to "3"
And parameter "internal_defaultExpDays" of app "core" is set to "1"
When creating a share with
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| expiration | +1 days |
Scenario: Creating a new internal share with relaxed default expiration date too large
Given user "user0" exists
And user "user1" exists
And As an "user0"
And parameter "shareapi_default_internal_expire_date" of app "core" is set to "yes"
And parameter "shareapi_internal_expire_after_n_days" of app "core" is set to "3"
And parameter "internal_defaultExpDays" of app "core" is set to "10"
When creating a share with
| path | welcome.txt |
| shareWith | user1 |
| shareType | 0 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| expiration | +3 days |
Scenario: Creating a new link share with default expiration date
Given user "user0" exists
And As an "user0"
And parameter "shareapi_default_expire_date" of app "core" is set to "yes"
And parameter "shareapi_expire_after_n_days" of app "core" is set to "3"
When creating a share with
| path | welcome.txt |
| shareType | 3 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| expiration | +3 days |
Scenario: Creating a new link share with relaxed default expiration date
Given user "user0" exists
And As an "user0"
And parameter "shareapi_default_expire_date" of app "core" is set to "yes"
And parameter "shareapi_expire_after_n_days" of app "core" is set to "3"
And parameter "link_defaultExpDays" of app "core" is set to "1"
When creating a share with
| path | welcome.txt |
| shareType | 3 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| expiration | +1 days |
Scenario: Creating a new link share with relaxed default expiration date too large
Given user "user0" exists
And As an "user0"
And parameter "shareapi_default_expire_date" of app "core" is set to "yes"
And parameter "shareapi_expire_after_n_days" of app "core" is set to "3"
And parameter "link_defaultExpDays" of app "core" is set to "10"
When creating a share with
| path | welcome.txt |
| shareType | 3 |
And the OCS status code should be "100"
And the HTTP status code should be "200"
And Getting info of last share
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And Share fields of last share match with
| expiration | +3 days |
Scenario: getting all shares of a user using that user Scenario: getting all shares of a user using that user
Given user "user0" exists Given user "user0" exists
And user "user1" exists And user "user1" exists

View File

@ -409,9 +409,9 @@ class Manager implements IManager {
$expirationDate = new \DateTime(); $expirationDate = new \DateTime();
$expirationDate->setTime(0,0,0); $expirationDate->setTime(0,0,0);
$days = (int)$this->config->getAppValue('core', 'internal_defaultExpDays', $this->shareApiLinkDefaultExpireDays()); $days = (int)$this->config->getAppValue('core', 'internal_defaultExpDays', (string)$this->shareApiInternalDefaultExpireDays());
if ($days > $this->shareApiLinkDefaultExpireDays()) { if ($days > $this->shareApiInternalDefaultExpireDays()) {
$days = $this->shareApiLinkDefaultExpireDays(); $days = $this->shareApiInternalDefaultExpireDays();
} }
$expirationDate->add(new \DateInterval('P'.$days.'D')); $expirationDate->add(new \DateInterval('P'.$days.'D'));
} }

View File

@ -764,11 +764,294 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'generalCreateChecks', [$share]); self::invokePrivate($this->manager, 'generalCreateChecks', [$share]);
} }
public function testValidateExpirationDateInternalInPast() {
public function testvalidateExpirationDateInPast() {
$this->expectException(\OCP\Share\Exceptions\GenericShareException::class); $this->expectException(\OCP\Share\Exceptions\GenericShareException::class);
$this->expectExceptionMessage('Expiration date is in the past'); $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('Cant 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 // Expire date in the past
$past = new \DateTime(); $past = new \DateTime();
@ -780,8 +1063,7 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
} }
public function testValidateExpirationDateEnforceButNotSet() {
public function testvalidateExpirationDateEnforceButNotSet() {
$this->expectException(\InvalidArgumentException::class); $this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Expiration date is enforced'); $this->expectExceptionMessage('Expiration date is enforced');
@ -797,7 +1079,7 @@ class ManagerTest extends \Test\TestCase {
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); self::invokePrivate($this->manager, 'validateExpirationDate', [$share]);
} }
public function testvalidateExpirationDateEnforceButNotEnabledAndNotSet() { public function testValidateExpirationDateEnforceButNotEnabledAndNotSet() {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setProviderId('foo')->setId('bar'); $share->setProviderId('foo')->setId('bar');
@ -811,7 +1093,7 @@ class ManagerTest extends \Test\TestCase {
$this->assertNull($share->getExpirationDate()); $this->assertNull($share->getExpirationDate());
} }
public function testvalidateExpirationDateEnforceButNotSetNewShare() { public function testValidateExpirationDateEnforceButNotSetNewShare() {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$this->config->method('getAppValue') $this->config->method('getAppValue')
@ -832,8 +1114,31 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
} }
public function testvalidateExpirationDateEnforceToFarIntoFuture() { public function testValidateExpirationDateEnforceRelaxedDefaultButNotSetNewShare() {
// Expire date in the past $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('Cant set expiration date more than 3 days in the future');
$future = new \DateTime(); $future = new \DateTime();
$future->add(new \DateInterval('P7D')); $future->add(new \DateInterval('P7D'));
@ -844,26 +1149,19 @@ class ManagerTest extends \Test\TestCase {
->willReturnMap([ ->willReturnMap([
['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'], ['core', 'shareapi_expire_after_n_days', '7', '3'],
['core', 'shareapi_default_expire_date', 'no', 'yes'],
]); ]);
try {
self::invokePrivate($this->manager, 'validateExpirationDate', [$share]); 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() { public function testValidateExpirationDateEnforceValid() {
// Expire date in the past
$future = new \DateTime(); $future = new \DateTime();
$future->add(new \DateInterval('P2D')); $future->add(new \DateInterval('P2D'));
$future->setTime(0,0,0); $future->setTime(1,2,3);
$expected = clone $future; $expected = clone $future;
$future->setTime(1,2,3); $expected->setTime(0,0,0);
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($future); $share->setExpirationDate($future);
@ -872,11 +1170,12 @@ class ManagerTest extends \Test\TestCase {
->willReturnMap([ ->willReturnMap([
['core', 'shareapi_enforce_expire_date', 'no', 'yes'], ['core', 'shareapi_enforce_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'], ['core', 'shareapi_expire_after_n_days', '7', '3'],
['core', 'shareapi_default_expire_date', 'no', 'yes'],
]); ]);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($future) { $hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($future) {
return $data['expirationDate'] == $future; return $data['expirationDate'] == $future;
})); }));
@ -885,9 +1184,10 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
} }
public function testvalidateExpirationDateNoDateNoDefaultNull() { public function testValidateExpirationDateNoDefault() {
$date = new \DateTime(); $date = new \DateTime();
$date->add(new \DateInterval('P5D')); $date->add(new \DateInterval('P5D'));
$date->setTime(1,2,3);
$expected = clone $date; $expected = clone $date;
$expected->setTime(0,0,0); $expected->setTime(0,0,0);
@ -895,9 +1195,9 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($date); $share->setExpirationDate($date);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) { $hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
return $data['expirationDate'] == $expected && $data['passwordSet'] === false; return $data['expirationDate'] == $expected && $data['passwordSet'] === false;
})); }));
@ -906,10 +1206,10 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($expected, $share->getExpirationDate()); $this->assertEquals($expected, $share->getExpirationDate());
} }
public function testvalidateExpirationDateNoDateNoDefault() { public function testValidateExpirationDateNoDateNoDefault() {
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) { $hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) {
return $data['expirationDate'] === null && $data['passwordSet'] === true; return $data['expirationDate'] === null && $data['passwordSet'] === true;
})); }));
@ -921,12 +1221,38 @@ class ManagerTest extends \Test\TestCase {
$this->assertNull($share->getExpirationDate()); $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 = new \DateTime();
$future->add(new \DateInterval('P3D')); $future->add(new \DateInterval('P5D'));
$future->setTime(0,0,0); $future->setTime(1,2,3);
$expected = clone $future; $expected = clone $future;
$expected->setTime(0,0,0);
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($future); $share->setExpirationDate($future);
@ -935,11 +1261,12 @@ class ManagerTest extends \Test\TestCase {
->willReturnMap([ ->willReturnMap([
['core', 'shareapi_default_expire_date', 'no', 'yes'], ['core', 'shareapi_default_expire_date', 'no', 'yes'],
['core', 'shareapi_expire_after_n_days', '7', '3'], ['core', 'shareapi_expire_after_n_days', '7', '3'],
['core', 'link_defaultExpDays', 3, '1'],
]); ]);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListner->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) { $hookListener->expects($this->once())->method('listener')->with($this->callback(function ($data) use ($expected) {
return $data['expirationDate'] == $expected; return $data['expirationDate'] == $expected;
})); }));
@ -955,9 +1282,9 @@ class ManagerTest extends \Test\TestCase {
$save = clone $nextWeek; $save = clone $nextWeek;
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListner->expects($this->once())->method('listener')->willReturnCallback(function ($data) { $hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
$data['expirationDate']->sub(new \DateInterval('P2D')); $data['expirationDate']->sub(new \DateInterval('P2D'));
}); });
@ -970,7 +1297,6 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals($save, $share->getExpirationDate()); $this->assertEquals($save, $share->getExpirationDate());
} }
public function testValidateExpirationDateHookException() { public function testValidateExpirationDateHookException() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid date!'); $this->expectExceptionMessage('Invalid date!');
@ -982,9 +1308,9 @@ class ManagerTest extends \Test\TestCase {
$share = $this->manager->newShare(); $share = $this->manager->newShare();
$share->setExpirationDate($nextWeek); $share->setExpirationDate($nextWeek);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['listener'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListner, 'listener'); \OCP\Util::connectHook('\OC\Share', 'verifyExpirationDate', $hookListener, 'listener');
$hookListner->expects($this->once())->method('listener')->willReturnCallback(function ($data) { $hookListener->expects($this->once())->method('listener')->willReturnCallback(function ($data) {
$data['accepted'] = false; $data['accepted'] = false;
$data['message'] = 'Invalid date!'; $data['message'] = 'Invalid date!';
}); });
@ -1008,7 +1334,6 @@ class ManagerTest extends \Test\TestCase {
$this->assertEquals(null, $share->getExpirationDate()); $this->assertEquals(null, $share->getExpirationDate());
} }
public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() { public function testUserCreateChecksShareWithGroupMembersOnlyDifferentGroups() {
$this->expectException(\Exception::class); $this->expectException(\Exception::class);
$this->expectExceptionMessage('Sharing is only allowed with group members'); $this->expectExceptionMessage('Sharing is only allowed with group members');
@ -2606,16 +2931,16 @@ class ManagerTest extends \Test\TestCase {
->with($share) ->with($share)
->willReturn($share); ->willReturn($share);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$this->rootFolder->method('getUserFolder')->with('newUser')->willReturnSelf(); $this->rootFolder->method('getUserFolder')->with('newUser')->willReturnSelf();
$this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath'); $this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener2, 'post');
$hookListner2->expects($this->once())->method('post')->with([ $hookListener2->expects($this->once())->method('post')->with([
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 100, 'itemSource' => 100,
'shareType' => IShare::TYPE_USER, 'shareType' => IShare::TYPE_USER,
@ -2663,13 +2988,13 @@ class ManagerTest extends \Test\TestCase {
->with($share) ->with($share)
->willReturn($share); ->willReturn($share);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -2725,18 +3050,18 @@ class ManagerTest extends \Test\TestCase {
->with($share) ->with($share)
->willReturn($share); ->willReturn($share);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->once())->method('post')->with([ $hookListener->expects($this->once())->method('post')->with([
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 100, 'itemSource' => 100,
'date' => $tomorrow, 'date' => $tomorrow,
'uidOwner' => 'owner', 'uidOwner' => 'owner',
]); ]);
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->once())->method('post')->with([ $hookListener2->expects($this->once())->method('post')->with([
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 100, 'itemSource' => 100,
'uidOwner' => 'owner', 'uidOwner' => 'owner',
@ -2744,9 +3069,9 @@ class ManagerTest extends \Test\TestCase {
'disabled' => false, 'disabled' => false,
]); ]);
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
@ -2806,17 +3131,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -2875,13 +3200,13 @@ class ManagerTest extends \Test\TestCase {
->with($share, 'password') ->with($share, 'password')
->willReturn($share); ->willReturn($share);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->once())->method('post')->with([ $hookListener2->expects($this->once())->method('post')->with([
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 100, 'itemSource' => 100,
'uidOwner' => 'owner', 'uidOwner' => 'owner',
@ -2889,9 +3214,9 @@ class ManagerTest extends \Test\TestCase {
'disabled' => false, 'disabled' => false,
]); ]);
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -2953,13 +3278,13 @@ class ManagerTest extends \Test\TestCase {
->with($share, 'password') ->with($share, 'password')
->willReturn($share); ->willReturn($share);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->once())->method('post')->with([ $hookListener2->expects($this->once())->method('post')->with([
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 100, 'itemSource' => 100,
'uidOwner' => 'owner', 'uidOwner' => 'owner',
@ -2967,9 +3292,9 @@ class ManagerTest extends \Test\TestCase {
'disabled' => false, 'disabled' => false,
]); ]);
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3036,13 +3361,13 @@ class ManagerTest extends \Test\TestCase {
->with($share, 'password') ->with($share, 'password')
->willReturn($share); ->willReturn($share);
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->once())->method('post')->with([ $hookListener2->expects($this->once())->method('post')->with([
'itemType' => 'file', 'itemType' => 'file',
'itemSource' => 100, 'itemSource' => 100,
'uidOwner' => 'owner', 'uidOwner' => 'owner',
@ -3050,9 +3375,9 @@ class ManagerTest extends \Test\TestCase {
'disabled' => false, 'disabled' => false,
]); ]);
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3113,17 +3438,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3185,17 +3510,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3257,17 +3582,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3334,17 +3659,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3410,17 +3735,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }
@ -3484,17 +3809,17 @@ class ManagerTest extends \Test\TestCase {
$this->defaultProvider->expects($this->never()) $this->defaultProvider->expects($this->never())
->method('update'); ->method('update');
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListner, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
$hookListner->expects($this->never())->method('post'); $hookListener->expects($this->never())->method('post');
$hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListner2, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
$hookListner2->expects($this->never())->method('post'); $hookListener2->expects($this->never())->method('post');
$hookListner3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock(); $hookListener3 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
\OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListner3, 'post'); \OCP\Util::connectHook('OCP\Share', 'post_update_permissions', $hookListener3, 'post');
$hookListner3->expects($this->never())->method('post'); $hookListener3->expects($this->never())->method('post');
$manager->updateShare($share); $manager->updateShare($share);
} }