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

github.com/nextcloud/twofactor_totp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-04-30 11:09:23 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-08-09 12:05:27 +0300
commit165b0f09e9562c2f4c4f27f6c25ebe941f99533e (patch)
tree53cb3fce9bf9de212acca67c989ed79b69295d61 /tests
parente5af6e9c5e47262a95839c53dbe54fbd8c6759c4 (diff)
Add setup at login
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Provider/AtLoginProviderTest.php58
-rw-r--r--tests/Unit/Provider/TotpProviderTest.php23
2 files changed, 80 insertions, 1 deletions
diff --git a/tests/Unit/Provider/AtLoginProviderTest.php b/tests/Unit/Provider/AtLoginProviderTest.php
new file mode 100644
index 0000000..7f2b341
--- /dev/null
+++ b/tests/Unit/Provider/AtLoginProviderTest.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace OCA\TwoFactorTOTP\Test\Unit\Provider;
+
+use ChristophWurst\Nextcloud\Testing\TestCase;
+use OCA\TwoFactorTOTP\AppInfo\Application;
+use OCA\TwoFactorTOTP\Provider\AtLoginProvider;
+use OCP\IURLGenerator;
+use OCP\Template;
+use PHPUnit\Framework\MockObject\MockObject;
+
+class AtLoginProviderTest extends TestCase {
+
+ /** @var IURLGenerator|MockObject */
+ private $urlGenerator;
+
+ /** @var AtLoginProvider */
+ private $provider;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+
+ $this->provider = new AtLoginProvider(
+ $this->urlGenerator
+ );
+ }
+
+
+ public function testGetBody() {
+ // Not really anything to test, let's see if it does :boom:, though
+ $this->provider->getBody();
+
+ $this->addToAssertionCount(1);
+ }
+
+}
diff --git a/tests/Unit/Provider/TotpProviderTest.php b/tests/Unit/Provider/TotpProviderTest.php
index 2e8376e..813308a 100644
--- a/tests/Unit/Provider/TotpProviderTest.php
+++ b/tests/Unit/Provider/TotpProviderTest.php
@@ -27,9 +27,11 @@ declare(strict_types=1);
namespace OCA\TwoFactorTOTP\Test\Unit\Provider;
use ChristophWurst\Nextcloud\Testing\TestCase;
+use OCA\TwoFactorTOTP\Provider\AtLoginProvider;
use OCA\TwoFactorTOTP\Provider\TotpProvider;
use OCA\TwoFactorTOTP\Service\ITotp;
use OCA\TwoFactorTOTP\Settings\Personal;
+use OCP\AppFramework\IAppContainer;
use OCP\IL10N;
use OCP\IUser;
use PHPUnit\Framework\MockObject\MockObject;
@@ -42,6 +44,9 @@ class TotpProviderTest extends TestCase {
/** @var IL10N|MockObject */
private $l10n;
+ /** @var IAppContainer|MockObject */
+ private $container;
+
/** @var TotpProvider */
private $provider;
@@ -50,10 +55,12 @@ class TotpProviderTest extends TestCase {
$this->totp = $this->createMock(ITotp::class);
$this->l10n = $this->createMock(IL10N::class);
+ $this->container = $this->createMock(IAppContainer::class);
$this->provider = new TotpProvider(
$this->totp,
- $this->l10n
+ $this->l10n,
+ $this->container
);
}
@@ -122,4 +129,18 @@ class TotpProviderTest extends TestCase {
$this->provider->disableFor($user);
}
+ public function testGetSetupProvider() {
+ /** @var IUser|MockObject $user */
+ $user = $this->createMock(IUser::class);
+ $provider = $this->createMock(AtLoginProvider::class);
+ $this->container->expects($this->once())
+ ->method('query')
+ ->with(AtLoginProvider::class)
+ ->willReturn($provider);
+
+ $result = $this->provider->getLoginSetup($user);
+
+ $this->assertSame($provider, $result);
+ }
+
}