From 5daa9a5417b896246f9c67feca6d39ea9a96b551 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 13 Jun 2016 12:46:45 +0200 Subject: fail hard if 2fa provider can not be loaded (#25061) --- .../Authentication/TwoFactorAuth/ManagerTest.php | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'tests/lib/Authentication/TwoFactorAuth/ManagerTest.php') diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index 9a3426eda2d..363229b01bc 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -85,11 +85,32 @@ class ManagerTest extends TestCase { ])); } + /** + * @expectedException \Exception + * @expectedExceptionMessage Could not load two-factor auth provider \OCA\MyFaulty2faApp\DoesNotExist + */ + public function testFailHardIfProviderCanNotBeLoaded() { + $this->appManager->expects($this->once()) + ->method('getEnabledAppsForUser') + ->with($this->user) + ->will($this->returnValue(['faulty2faapp'])); + + $this->appManager->expects($this->once()) + ->method('getAppInfo') + ->with('faulty2faapp') + ->will($this->returnValue([ + 'two-factor-providers' => [ + '\OCA\MyFaulty2faApp\DoesNotExist', + ], + ])); + + $this->manager->getProviders($this->user); + } + public function testIsTwoFactorAuthenticated() { $this->prepareProviders(); - $user = $this->getMock('\OCP\IUser'); - $user->expects($this->once()) + $this->user->expects($this->once()) ->method('getUID') ->will($this->returnValue('user123')); $this->config->expects($this->once()) @@ -97,7 +118,7 @@ class ManagerTest extends TestCase { ->with('user123', 'core', 'two_factor_auth_disabled', 0) ->will($this->returnValue(0)); - $this->assertTrue($this->manager->isTwoFactorAuthenticated($user)); + $this->assertTrue($this->manager->isTwoFactorAuthenticated($this->user)); } public function testGetProvider() { -- cgit v1.2.3