diff options
author | Alexander Piskun <bigcat88@icloud.com> | 2023-12-25 18:12:54 +0300 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-12-29 08:44:13 +0000 |
commit | 1d0b10b12c144591c80b26c2684b88212b1d915e (patch) | |
tree | f4f589fb3d0695beaa0e24794b9a118cb444de95 /tests/lib | |
parent | 525d087b521be3326019afa2bc5335bf035e5164 (diff) | |
download | nextcloud-server-1d0b10b12c144591c80b26c2684b88212b1d915e.tar.gz nextcloud-server-1d0b10b12c144591c80b26c2684b88212b1d915e.zip |
AppAPI: allowed to bypass Two-Factor
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
Diffstat (limited to 'tests/lib')
-rw-r--r-- | tests/lib/Authentication/TwoFactorAuth/ManagerTest.php | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php index 3c82878065e..a2655f58649 100644 --- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php @@ -629,13 +629,26 @@ class ManagerTest extends TestCase { return false; } elseif ($var === 'app_password') { return false; + } elseif ($var === 'app_api') { + return false; } return true; }); + $this->session->method('get') + ->willReturnCallback(function ($var) { + if ($var === Manager::SESSION_UID_KEY) { + return 'user'; + } elseif ($var === 'app_api') { + return true; + } + return null; + }); $this->session->expects($this->once()) ->method('get') - ->with(Manager::SESSION_UID_DONE) - ->willReturn('user'); + ->willReturnMap([ + [Manager::SESSION_UID_DONE, 'user'], + ['app_api', true] + ]); $this->assertFalse($this->manager->needsSecondFactor($user)); } @@ -695,8 +708,10 @@ class ManagerTest extends TestCase { public function testNeedsSecondFactorAppPassword() { $user = $this->createMock(IUser::class); $this->session->method('exists') - ->with('app_password') - ->willReturn(true); + ->willReturnMap([ + ['app_password', true], + ['app_api', true] + ]); $this->assertFalse($this->manager->needsSecondFactor($user)); } |