aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2024-10-28 10:14:29 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-11-05 10:49:31 +0000
commit44ed7190279391004ba600a5631bb0a9ce8f1cfe (patch)
tree1d2803b771393b277e9ff5fa5af91201ad10befb /tests
parent424668d881b266956e97fdce84ec24e112be7e61 (diff)
downloadnextcloud-server-44ed7190279391004ba600a5631bb0a9ce8f1cfe.tar.gz
nextcloud-server-44ed7190279391004ba600a5631bb0a9ce8f1cfe.zip
fix: Clear pending two factor tokens also from configuration
Otherwise as the tokens were removed from the database but not from the configuration the next time that the tokens were cleared the previous tokens were still got from the configuration, and trying to remove them again from the database ended in a DoesNotExistException being thrown. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index a2655f58649..c741ff068ac 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -715,4 +715,30 @@ class ManagerTest extends TestCase {
$this->assertFalse($this->manager->needsSecondFactor($user));
}
+
+ public function testClearTwoFactorPending() {
+ $this->config->method('getUserKeys')
+ ->with('theUserId', 'login_token_2fa')
+ ->willReturn([
+ '42', '43', '44'
+ ]);
+
+ $this->config->expects($this->exactly(3))
+ ->method('deleteUserValue')
+ ->withConsecutive(
+ ['theUserId', 'login_token_2fa', '42'],
+ ['theUserId', 'login_token_2fa', '43'],
+ ['theUserId', 'login_token_2fa', '44'],
+ );
+
+ $this->tokenProvider->expects($this->exactly(3))
+ ->method('invalidateTokenById')
+ ->withConsecutive(
+ ['theUserId', 42],
+ ['theUserId', 43],
+ ['theUserId', 44],
+ );
+
+ $this->manager->clearTwoFactorPending('theUserId');
+ }
}