Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-10-01 19:13:23 +0300
committerGitHub <noreply@github.com>2018-10-01 19:13:23 +0300
commit6080d9d80acf0281bfc383b222972346b74e7fe5 (patch)
tree29fccebebd6e5397dd4361d67f3267f3b05b4f7b /tests
parent8743fe6bbac350eaa5ad978de5c163fb892a7f6d (diff)
parentc55731426240c0debd3a9bad3cb5e32b6f7e76a8 (diff)
Merge pull request #11462 from nextcloud/feature/11380/2fa_backup_code_generation
Add notification to generate 2FA backup codes
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/RegistryTest.php28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
index 3d2941e009a..08498738fa1 100644
--- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
@@ -27,8 +27,11 @@ namespace Test\Authentication\TwoFactorAuth;
use OC\Authentication\TwoFactorAuth\Db\ProviderUserAssignmentDao;
use OC\Authentication\TwoFactorAuth\Registry;
use OCP\Authentication\TwoFactorAuth\IProvider;
+use OCP\Authentication\TwoFactorAuth\IRegistry;
+use OCP\Authentication\TwoFactorAuth\RegistryEvent;
use OCP\IUser;
use PHPUnit_Framework_MockObject_MockObject;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
class RegistryTest extends TestCase {
@@ -39,12 +42,16 @@ class RegistryTest extends TestCase {
/** @var Registry */
private $registry;
+ /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */
+ private $dispatcher;
+
protected function setUp() {
parent::setUp();
$this->dao = $this->createMock(ProviderUserAssignmentDao::class);
+ $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
- $this->registry = new Registry($this->dao);
+ $this->registry = new Registry($this->dao, $this->dispatcher);
}
public function testGetProviderStates() {
@@ -68,6 +75,15 @@ class RegistryTest extends TestCase {
$this->dao->expects($this->once())->method('persist')->with('p1', 'user123',
true);
+ $this->dispatcher->expects($this->once())
+ ->method('dispatch')
+ ->with(
+ $this->equalTo(IRegistry::EVENT_PROVIDER_ENABLED),
+ $this->callback(function(RegistryEvent $e) use ($user, $provider) {
+ return $e->getUser() === $user && $e->getProvider() === $provider;
+ })
+ );
+
$this->registry->enableProviderFor($provider, $user);
}
@@ -79,6 +95,16 @@ class RegistryTest extends TestCase {
$this->dao->expects($this->once())->method('persist')->with('p1', 'user123',
false);
+
+ $this->dispatcher->expects($this->once())
+ ->method('dispatch')
+ ->with(
+ $this->equalTo(IRegistry::EVENT_PROVIDER_DISABLED),
+ $this->callback(function(RegistryEvent $e) use ($user, $provider) {
+ return $e->getUser() === $user && $e->getProvider() === $provider;
+ })
+ );
+
$this->registry->disableProviderFor($provider, $user);
}