Fix verifyExpirationDate passwordSet argument

Password set should be false if the password is null.

Also updated the unit tests to tests this now.
remotes/origin/s3patch
Roeland Jago Douma 2016-02-25 15:39:02 +07:00
parent 32f4bea0ae
commit 9412f69104
2 changed files with 4 additions and 3 deletions

@ -280,7 +280,7 @@ class Manager implements IManager {
'expirationDate' => &$expirationDate,
'accepted' => &$accepted,
'message' => &$message,
'passwordSet' => $share->getPassword() === null,
'passwordSet' => $share->getPassword() !== null,
]);
if (!$accepted) {

@ -787,7 +787,7 @@ class ManagerTest extends \Test\TestCase {
$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) {
return $data['expirationDate'] == $expected;
return $data['expirationDate'] == $expected && $data['passwordSet'] === false;
}));
$res = $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);
@ -799,10 +799,11 @@ class ManagerTest extends \Test\TestCase {
$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) {
return $data['expirationDate'] === null;
return $data['expirationDate'] === null && $data['passwordSet'] === true;
}));
$share = $this->manager->newShare();
$share->setPassword('password');
$date = $this->invokePrivate($this->manager, 'validateExpirationDate', [$share]);