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

github.com/nextcloud/twofactor_gateway.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2018-04-11 19:29:45 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2018-04-11 19:29:45 +0300
commit87127e3f043f531729ac9ea49d97416407c22914 (patch)
tree7d2387b0784ec1001b5d8d0220dc61df922b43b4 /tests
parent3e5a02ff45b4e96f096964985f80aa206c3e69af (diff)
Make sure the phone number has been verified and it did not change
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Provider/SmsProviderTest.php11
-rw-r--r--tests/Unit/Service/SetupServiceTest.php12
2 files changed, 16 insertions, 7 deletions
diff --git a/tests/Unit/Provider/SmsProviderTest.php b/tests/Unit/Provider/SmsProviderTest.php
index 15bdd0e..5a805aa 100644
--- a/tests/Unit/Provider/SmsProviderTest.php
+++ b/tests/Unit/Provider/SmsProviderTest.php
@@ -25,6 +25,7 @@ namespace OCA\TwoFactorSms\Tests\Unit\Provider;
use ChristophWurst\Nextcloud\Testing\TestCase;
use OCA\TwoFactorSms\Provider\SmsProvider;
use OCA\TwoFactorSms\Service\ISmsService;
+use OCA\TwoFactorSms\Service\SetupService;
use OCP\IConfig;
use OCP\IL10N;
use OCP\ISession;
@@ -37,6 +38,9 @@ class SmsProviderTest extends TestCase {
/** @var ISmsService|PHPUnit_Framework_MockObject_MockObject */
private $smsService;
+ /** @var SetupService|PHPUnit_Framework_MockObject_MockObject */
+ private $setupService;
+
/** @var ISession|PHPUnit_Framework_MockObject_MockObject */
private $session;
@@ -56,12 +60,13 @@ class SmsProviderTest extends TestCase {
parent::setUp();
$this->smsService = $this->createMock(ISmsService::class);
+ $this->setupService = $this->createMock(SetupService::class);
$this->session = $this->createMock(ISession::class);
$this->random = $this->createMock(ISecureRandom::class);
$this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class);
- $this->provider = new SmsProvider($this->smsService, $this->session, $this->random, $this->config, $this->l10n);
+ $this->provider = new SmsProvider($this->smsService, $this->setupService, $this->session, $this->random, $this->config, $this->l10n);
}
public function testIsTwoFactorAuthEnabledForUser() {
@@ -69,8 +74,8 @@ class SmsProviderTest extends TestCase {
$user->method('getUID')->willReturn('user123');
$this->config->expects($this->once())
->method('getUserValue')
- ->with('user123', 'twofactor_sms', 'verified', false)
- ->willReturn(true);
+ ->with('user123', 'twofactor_sms', 'verified', 'false')
+ ->willReturn('true');
$enabled = $this->provider->isTwoFactorAuthEnabledForUser($user);
diff --git a/tests/Unit/Service/SetupServiceTest.php b/tests/Unit/Service/SetupServiceTest.php
index eb59322..c2bf6cf 100644
--- a/tests/Unit/Service/SetupServiceTest.php
+++ b/tests/Unit/Service/SetupServiceTest.php
@@ -92,7 +92,9 @@ class SetupServiceTest extends TestCase {
->method('getUser')
->with($user)
->willReturn([
- AccountManager::PROPERTY_PHONE => '0123456789',
+ AccountManager::PROPERTY_PHONE => [
+ 'value' => '0123456789',
+ ],
]);
$this->smsService->expects($this->once())
->method('send')
@@ -108,7 +110,9 @@ class SetupServiceTest extends TestCase {
->method('getUser')
->with($user)
->willReturn([
- AccountManager::PROPERTY_PHONE => '0123456789',
+ AccountManager::PROPERTY_PHONE => [
+ 'value' => '0123456789',
+ ],
]);
$this->smsService->expects($this->once())
->method('send');
@@ -124,7 +128,7 @@ class SetupServiceTest extends TestCase {
->with('user123', 'twofactor_sms', 'verification_code', '963852');
$this->config->expects($this->at(2))
->method('setUserValue')
- ->with('user123', 'twofactor_sms', 'verified', false);
+ ->with('user123', 'twofactor_sms', 'verified', 'false');
$this->setupService->startSetup($user);
}
@@ -162,7 +166,7 @@ class SetupServiceTest extends TestCase {
->willReturn('123456');
$this->config->expects($this->once())
->method('setUserValue')
- ->with('user123', 'twofactor_sms', 'verified', true);
+ ->with('user123', 'twofactor_sms', 'verified', 'true');
$this->setupService->finishSetup($user, '123456');
}