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:
authorVincent Petry <pvince81@owncloud.com>2016-09-19 14:05:32 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2016-09-19 14:06:27 +0300
commit85f45d4bc5929b6e789833bb31b4a841cd5f06e2 (patch)
tree3de532b0a21158174eb0b56a7f800fbe6236a3b3 /tests
parentaed4ee9f81aabdcc6c583321182a8ec6623b8c38 (diff)
[stable9.1] Redirect to challenge page when only one 2FA provider (#26141)
If only one two factor provider exists, spare the user from having to select it and redirect directly to its challenge page.
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/TwoFactorChallengeControllerTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/Core/Controller/TwoFactorChallengeControllerTest.php b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
index 08d8dd1452c..56ba52d58b5 100644
--- a/tests/Core/Controller/TwoFactorChallengeControllerTest.php
+++ b/tests/Core/Controller/TwoFactorChallengeControllerTest.php
@@ -87,6 +87,37 @@ class TwoFactorChallengeControllerTest extends TestCase {
$this->assertEquals($expected, $this->controller->selectChallenge('/some/url'));
}
+ public function testSelectChallengeSingleEntry() {
+ $provider = $this->createMock('\OCP\Authentication\TwoFactorAuth\IProvider');
+ $user = $this->createMock('\OCP\IUser');
+ $providers = [$provider];
+
+ $this->userSession->expects($this->once())
+ ->method('getUser')
+ ->will($this->returnValue($user));
+ $this->twoFactorManager->expects($this->once())
+ ->method('getProviders')
+ ->with($user)
+ ->will($this->returnValue($providers));
+
+ $provider->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('prov1'));
+
+ $url = $this->urlGenerator->linkToRoute(
+ 'core.TwoFactorChallenge.showChallenge',
+ [
+ 'challengeProviderId' => 'prov1',
+ 'redirect_url' => '/some/url',
+ ]
+ );
+ $expected = new RedirectResponse($url);
+
+ $response = $this->controller->selectChallenge('/some/url');
+ $this->assertEquals($expected, $response);
+ $this->assertEquals($url, $response->getRedirectURL());
+ }
+
public function testShowChallenge() {
$user = $this->getMock('\OCP\IUser');
$provider = $this->getMockBuilder('\OCP\Authentication\TwoFactorAuth\IProvider')