|
|
|
|
@ -485,7 +485,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
public function testVerifyPasswordNullButEnforced() {
|
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
|
$this->expectExceptionMessage('Passwords are enforced for link shares');
|
|
|
|
|
$this->expectExceptionMessage('Passwords are enforced for link and mail shares');
|
|
|
|
|
|
|
|
|
|
$this->config->method('getAppValue')->willReturnMap([
|
|
|
|
|
['core', 'shareapi_enforce_links_password', 'no', 'yes'],
|
|
|
|
|
@ -2203,17 +2203,19 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())
|
|
|
|
|
->method('generalCreateChecks')
|
|
|
|
|
->with($share);
|
|
|
|
|
;
|
|
|
|
|
$manager->expects($this->never())
|
|
|
|
|
|
|
|
|
|
$manager->expects($this->once())
|
|
|
|
|
->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())
|
|
|
|
|
->method('pathCreateChecks')
|
|
|
|
|
->with($path);
|
|
|
|
|
$manager->expects($this->never())
|
|
|
|
|
->method('validateExpirationDateLink');
|
|
|
|
|
$manager->expects($this->never())
|
|
|
|
|
$manager->expects($this->once())
|
|
|
|
|
->method('validateExpirationDateLink')
|
|
|
|
|
->with($share)
|
|
|
|
|
->willReturn($share);
|
|
|
|
|
$manager->expects($this->once())
|
|
|
|
|
->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())
|
|
|
|
|
$manager->expects($this->once())
|
|
|
|
|
->method('setLinkParent');
|
|
|
|
|
|
|
|
|
|
$this->secureRandom->method('generate')
|
|
|
|
|
@ -3203,8 +3205,8 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->once())->method('verifyPassword')->with('password');
|
|
|
|
|
$manager->expects($this->once())->method('pathCreateChecks')->with($file);
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
$this->hasher->expects($this->once())
|
|
|
|
|
->method('hash')
|
|
|
|
|
@ -3218,7 +3220,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
$hookListener->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'date' => $tomorrow,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
@ -3281,8 +3288,8 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->once())->method('verifyPassword')->with('password');
|
|
|
|
|
$manager->expects($this->once())->method('pathCreateChecks')->with($file);
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
$this->hasher->expects($this->once())
|
|
|
|
|
->method('hash')
|
|
|
|
|
@ -3296,7 +3303,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
$hookListener->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'date' => $tomorrow,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
@ -3359,8 +3371,8 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->once())->method('verifyPassword')->with('password');
|
|
|
|
|
$manager->expects($this->once())->method('pathCreateChecks')->with($file);
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
$this->hasher->expects($this->once())
|
|
|
|
|
->method('verify')
|
|
|
|
|
@ -3379,7 +3391,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
$hookListener = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_set_expiration_date', $hookListener, 'post');
|
|
|
|
|
$hookListener->expects($this->never())->method('post');
|
|
|
|
|
$hookListener->expects($this->once())->method('post')->with([
|
|
|
|
|
'itemType' => 'file',
|
|
|
|
|
'itemSource' => 100,
|
|
|
|
|
'date' => $tomorrow,
|
|
|
|
|
'uidOwner' => 'owner',
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$hookListener2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
|
|
|
|
|
\OCP\Util::connectHook('OCP\Share', 'post_update_password', $hookListener2, 'post');
|
|
|
|
|
@ -3400,7 +3417,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
public function testUpdateShareMailEnableSendPasswordByTalkWithNoPassword() {
|
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
|
$this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
|
|
|
|
|
$this->expectExceptionMessage('Can’t enable sending the password by Talk with an empty password');
|
|
|
|
|
|
|
|
|
|
$manager = $this->createManagerMock()
|
|
|
|
|
->setMethods([
|
|
|
|
|
@ -3445,9 +3462,10 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->never())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())->method('pathCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
// If the password is empty, we have nothing to hash
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('hash');
|
|
|
|
|
|
|
|
|
|
@ -3472,7 +3490,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() {
|
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
|
$this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
|
|
|
|
|
$this->expectExceptionMessage('Can’t enable sending the password by Talk with an empty password');
|
|
|
|
|
|
|
|
|
|
$manager = $this->createManagerMock()
|
|
|
|
|
->setMethods([
|
|
|
|
|
@ -3515,11 +3533,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('canShare')->willReturn(true);
|
|
|
|
|
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->never())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->once())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())->method('pathCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
// If the password is empty, we have nothing to hash
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('hash');
|
|
|
|
|
|
|
|
|
|
@ -3544,7 +3563,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
|
|
public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithEmptyString() {
|
|
|
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
|
|
|
$this->expectExceptionMessage('Can’t enable sending the password by Talk without setting a new password');
|
|
|
|
|
$this->expectExceptionMessage('Can’t enable sending the password by Talk with an empty password');
|
|
|
|
|
|
|
|
|
|
$manager = $this->createManagerMock()
|
|
|
|
|
->setMethods([
|
|
|
|
|
@ -3587,11 +3606,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('canShare')->willReturn(true);
|
|
|
|
|
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->never())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->once())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())->method('pathCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
// If the password is empty, we have nothing to hash
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('hash');
|
|
|
|
|
|
|
|
|
|
@ -3633,7 +3653,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$originalShare = $this->manager->newShare();
|
|
|
|
|
$originalShare->setShareType(IShare::TYPE_EMAIL)
|
|
|
|
|
->setPermissions(\OCP\Constants::PERMISSION_ALL)
|
|
|
|
|
->setPassword('passwordHash')
|
|
|
|
|
->setPassword('password')
|
|
|
|
|
->setSendPasswordByTalk(false);
|
|
|
|
|
|
|
|
|
|
$tomorrow = new \DateTime();
|
|
|
|
|
@ -3661,14 +3681,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->never())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())->method('pathCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
$this->hasher->expects($this->once())
|
|
|
|
|
->method('verify')
|
|
|
|
|
->with('password', 'passwordHash')
|
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
|
|
// If the old & new passwords are the same, we don't do anything
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('verify');
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('hash');
|
|
|
|
|
|
|
|
|
|
@ -3726,7 +3744,7 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
->setToken('token')
|
|
|
|
|
->setSharedBy('owner')
|
|
|
|
|
->setShareOwner('owner')
|
|
|
|
|
->setPassword('password')
|
|
|
|
|
->setPassword('passwordHash')
|
|
|
|
|
->setSendPasswordByTalk(false)
|
|
|
|
|
->setExpirationDate($tomorrow)
|
|
|
|
|
->setNode($file)
|
|
|
|
|
@ -3737,14 +3755,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->never())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())->method('pathCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
$this->hasher->expects($this->once())
|
|
|
|
|
->method('verify')
|
|
|
|
|
->with('password', 'passwordHash')
|
|
|
|
|
->willReturn(true);
|
|
|
|
|
|
|
|
|
|
// If the old & new passwords are the same, we don't do anything
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('verify');
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('hash');
|
|
|
|
|
|
|
|
|
|
@ -3813,12 +3829,12 @@ class ManagerTest extends \Test\TestCase {
|
|
|
|
|
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
|
|
|
|
|
$manager->expects($this->never())->method('verifyPassword');
|
|
|
|
|
$manager->expects($this->never())->method('pathCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->once())->method('linkCreateChecks');
|
|
|
|
|
$manager->expects($this->never())->method('validateExpirationDateLink');
|
|
|
|
|
|
|
|
|
|
// If the old & new passwords are the same, we don't do anything
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('verify');
|
|
|
|
|
|
|
|
|
|
$this->hasher->expects($this->never())
|
|
|
|
|
->method('hash');
|
|
|
|
|
|
|
|
|
|
|