diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-10 09:26:40 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-08-10 09:26:40 +0200 |
commit | 1124b87bc0e7606e27c309615bb65d3d73d0a121 (patch) | |
tree | 9a3e848e941521d5887f46a12f615ef3862760ab /tests/lib/Authentication/TwoFactorAuth/ManagerTest.php | |
parent | 103a2c30fb29b0d0f026d56eaa58d50cb68323ed (diff) | |
download | nextcloud-server-1124b87bc0e7606e27c309615bb65d3d73d0a121.tar.gz nextcloud-server-1124b87bc0e7606e27c309615bb65d3d73d0a121.zip |
Fix 2FA being enforced if only backup codes provider is active
Fixes https://github.com/nextcloud/server/issues/10634.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Authentication/TwoFactorAuth/ManagerTest.php')
-rw-r--r-- | tests/lib/Authentication/TwoFactorAuth/ManagerTest.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index 34ce340049a..3d238fbad3f 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -27,6 +27,7 @@ use OC; use OC\Authentication\Token\IProvider as TokenProvider; use OC\Authentication\TwoFactorAuth\Manager; use OC\Authentication\TwoFactorAuth\ProviderLoader; +use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\AppFramework\Utility\ITimeFactory; @@ -160,6 +161,32 @@ class ManagerTest extends TestCase { $this->assertFalse($this->manager->isTwoFactorAuthenticated($this->user)); } + public function testIsTwoFactorAuthenticatedOnlyBackupCodes() { + $this->user->expects($this->once()) + ->method('getUID') + ->will($this->returnValue('user123')); + $this->config->expects($this->once()) + ->method('getUserValue') + ->with('user123', 'core', 'two_factor_auth_disabled', 0) + ->willReturn(0); + $this->providerRegistry->expects($this->once()) + ->method('getProviderStates') + ->willReturn([ + 'backup_codes' => true, + ]); + $backupCodesProvider = $this->createMock(IProvider::class); + $backupCodesProvider + ->method('getId') + ->willReturn('backup_codes'); + $this->providerLoader->expects($this->once()) + ->method('getProviders') + ->willReturn([ + $backupCodesProvider, + ]); + + $this->assertFalse($this->manager->isTwoFactorAuthenticated($this->user)); + } + public function testIsTwoFactorAuthenticatedFailingProviders() { $this->user->expects($this->once()) ->method('getUID') |