summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-01-08 10:51:44 +0100
committerBackportbot <backportbot-noreply@rullzer.com>2020-01-09 10:35:04 +0000
commit7768cbb19ef0b0a643e6e7deb8e68719b97f8c3d (patch)
tree75e50e098bda1e34ecfb5a9f4cd167d11d054d3d /tests
parent5fdac43d5b82a9b38bb0be6492ea072fb08f0760 (diff)
downloadnextcloud-server-7768cbb19ef0b0a643e6e7deb8e68719b97f8c3d.tar.gz
nextcloud-server-7768cbb19ef0b0a643e6e7deb8e68719b97f8c3d.zip
Clean up 2FA provider registry when a user is deleted
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php14
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/RegistryTest.php10
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
index 67eb27cfdee..9be2e64e980 100644
--- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php
@@ -131,6 +131,20 @@ class ProviderUserAssignmentDaoTest extends TestCase {
$this->assertCount(1, $data);
}
+ public function testDeleteByUser() {
+ $this->dao->persist('twofactor_fail', 'user1', 1);
+ $this->dao->persist('twofactor_u2f', 'user1', 1);
+ $this->dao->persist('twofactor_fail', 'user2', 0);
+ $this->dao->persist('twofactor_u2f', 'user1', 0);
+
+ $this->dao->deleteByUser('user1');
+
+ $statesUser1 = $this->dao->getState('user1');
+ $statesUser2 = $this->dao->getState('user2');
+ $this->assertCount(0, $statesUser1);
+ $this->assertCount(1, $statesUser2);
+ }
+
public function testDeleteAll() {
$this->dao->persist('twofactor_fail', 'user1', 1);
$this->dao->persist('twofactor_u2f', 'user1', 1);
diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
index 2f59d14992a..90fc4a9d27a 100644
--- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php
@@ -108,6 +108,16 @@ class RegistryTest extends TestCase {
$this->registry->disableProviderFor($provider, $user);
}
+ public function testDeleteUserData() {
+ $user = $this->createMock(IUser::class);
+ $user->expects($this->once())->method('getUID')->willReturn('user123');
+ $this->dao->expects($this->once())
+ ->method('deleteByUser')
+ ->with('user123');
+
+ $this->registry->deleteUserData($user);
+ }
+
public function testCleanUp() {
$this->dao->expects($this->once())
->method('deleteAll')