aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/TwoFactorAuth/CleanupTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/TwoFactorAuth/CleanupTest.php')
-rw-r--r--tests/Core/Command/TwoFactorAuth/CleanupTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/Core/Command/TwoFactorAuth/CleanupTest.php b/tests/Core/Command/TwoFactorAuth/CleanupTest.php
new file mode 100644
index 00000000000..1d4731ff0c2
--- /dev/null
+++ b/tests/Core/Command/TwoFactorAuth/CleanupTest.php
@@ -0,0 +1,52 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace Core\Command\TwoFactorAuth;
+
+use OC\Core\Command\TwoFactorAuth\Cleanup;
+use OCP\Authentication\TwoFactorAuth\IRegistry;
+use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
+use Symfony\Component\Console\Tester\CommandTester;
+use Test\TestCase;
+
+class CleanupTest extends TestCase {
+ /** @var IRegistry|MockObject */
+ private $registry;
+
+ /** @var IUserManager|MockObject */
+ private $userManager;
+
+ /** @var CommandTester */
+ private $cmd;
+
+ protected function setUp(): void {
+ parent::setUp();
+
+ $this->registry = $this->createMock(IRegistry::class);
+ $this->userManager = $this->createMock(IUserManager::class);
+
+ $cmd = new Cleanup($this->registry, $this->userManager);
+ $this->cmd = new CommandTester($cmd);
+ }
+
+ public function testCleanup(): void {
+ $this->registry->expects($this->once())
+ ->method('cleanUp')
+ ->with('u2f');
+
+ $rc = $this->cmd->execute([
+ 'provider-id' => 'u2f',
+ ]);
+
+ $this->assertEquals(0, $rc);
+ $output = $this->cmd->getDisplay();
+ $this->assertStringContainsString('All user-provider associations for provider u2f have been removed', $output);
+ }
+}