remove old hook, no longer needed

This commit is contained in:
Bjoern Schiessle 2016-06-27 10:46:39 +02:00
parent 630e4b1b46
commit d4989c8037
No known key found for this signature in database
GPG Key ID: 2378A753E2BF04F6
2 changed files with 17 additions and 32 deletions

View File

@ -145,25 +145,13 @@ class Manager implements IManager {
return;
}
// Let others verify the password
try {
$event = new GenericEvent($password);
$this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
} catch (HintException $e) {
throw new \Exception($e->getHint());
}
// Let others verify the password
$accepted = true;
$message = '';
\OCP\Util::emitHook('\OC\Share', 'verifyPassword', [
'password' => $password,
'accepted' => &$accepted,
'message' => &$message
]);
if (!$accepted) {
throw new \Exception($message);
}
}
/**

View File

@ -20,6 +20,7 @@
*/
namespace Test\Share20;
use OC\HintException;
use OCP\Files\IRootFolder;
use OCP\IUserManager;
use OCP\Share\Exceptions\ShareNotFound;
@ -38,6 +39,7 @@ use OCP\Security\IHasher;
use OCP\Files\Mount\IMountManager;
use OCP\IGroupManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class ManagerTest
@ -549,16 +551,12 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]));
$hookListner = $this->getMockBuilder('Dummy')->setMethods(['listner'])->getMock();
\OCP\Util::connectHook('\OC\Share', 'verifyPassword', $hookListner, 'listner');
$hookListner->expects($this->once())
->method('listner')
->with([
'password' => 'password',
'accepted' => true,
'message' => ''
]);
$this->eventDispatcher->expects($this->once())->method('dispatch')
->willReturnCallback(function($eventName, GenericEvent $event) {
$this->assertSame('OCP\PasswordPolicy::validate', $eventName);
$this->assertSame('password', $event->getSubject());
}
);
$result = $this->invokePrivate($this->manager, 'verifyPassword', ['password']);
$this->assertNull($result);
@ -573,8 +571,14 @@ class ManagerTest extends \Test\TestCase {
['core', 'shareapi_enforce_links_password', 'no', 'no'],
]));
$dummy = new DummyPassword();
\OCP\Util::connectHook('\OC\Share', 'verifyPassword', $dummy, 'listner');
$this->eventDispatcher->expects($this->once())->method('dispatch')
->willReturnCallback(function($eventName, GenericEvent $event) {
$this->assertSame('OCP\PasswordPolicy::validate', $eventName);
$this->assertSame('password', $event->getSubject());
throw new HintException('message', 'password not accepted');
}
);
$this->invokePrivate($this->manager, 'verifyPassword', ['password']);
}
@ -2539,13 +2543,6 @@ class ManagerTest extends \Test\TestCase {
}
}
class DummyPassword {
public function listner($array) {
$array['accepted'] = false;
$array['message'] = 'password not accepted';
}
}
class DummyFactory implements IProviderFactory {
/** @var IShareProvider */