summaryrefslogtreecommitdiffstats
path: root/tests/Core
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2016-08-29 19:19:44 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-09-05 08:51:13 +0200
commit8acb734854484e2ffd235929f6e7d0ba4c273844 (patch)
tree3269bc6cc60b51d4fd507d91e8eca3a4ecc262cd /tests/Core
parent8b484eedf029b8e1a9dcef0efb09db381888c4b0 (diff)
downloadnextcloud-server-8acb734854484e2ffd235929f6e7d0ba4c273844.tar.gz
nextcloud-server-8acb734854484e2ffd235929f6e7d0ba4c273844.zip
add 2fa backup codes app
* add backup codes app unit tests * add integration tests for the backup codes app
Diffstat (limited to 'tests/Core')
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index 28f16241e2f..8a1cfb9edf1 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -77,9 +77,14 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('getProviders')
->with($user)
->will($this->returnValue($providers));
+ $this->twoFactorManager->expects($this->once())
+ ->method('getBackupProvider')
+ ->with($user)
+ ->will($this->returnValue('backup'));
$expected = new \OCP\AppFramework\Http\TemplateResponse('core', 'twofactorselectchallenge', [
'providers' => $providers,
+ 'backupProvider' => 'backup',
'redirect_url' => '/some/url',
'logout_attribute' => 'logoutAttribute',
], 'guest');
@@ -92,6 +97,9 @@ class TwoFactorChallengeControllerTest extends TestCase {
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
->disableOriginalConstructor()
->getMock();
+ $backupProvider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')
+ ->disableOriginalConstructor()
+ ->getMock();
$tmpl = $this->getMockBuilder('\OCP\Template')
->disableOriginalConstructor()
->getMock();
@@ -103,6 +111,16 @@ class TwoFactorChallengeControllerTest extends TestCase {
->method('getProvider')
->with($user, 'myprovider')
->will($this->returnValue($provider));
+ $this->twoFactorManager->expects($this->once())
+ ->method('getBackupProvider')
+ ->with($user)
+ ->will($this->returnValue($backupProvider));
+ $provider->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('u2f'));
+ $backupProvider->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('backup_codes'));
$this->session->expects($this->once())
->method('exists')
@@ -122,6 +140,7 @@ class TwoFactorChallengeControllerTest extends TestCase {
$expected = new \OCP\AppFramework\Http\TemplateResponse('core', 'twofactorshowchallenge', [
'error' => true,
'provider' => $provider,
+ 'backupProvider' => $backupProvider,
'logout_attribute' => 'logoutAttribute',
'template' => '<html/>',
], 'guest');