diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-06-09 15:33:06 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-06-16 15:38:33 +0300 |
commit | 68794ebc9292cdedaa6a52d190e41e58f6edb1ba (patch) | |
tree | 7431b26f51f615f407b000fab7ac9f68be89600e /tests | |
parent | 5e52c110bb149f35ec46472a4834a5f9a25c4892 (diff) |
Emit an event for every disabled 2FA provider during cleanup
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php | 25 | ||||
-rw-r--r-- | tests/lib/Authentication/TwoFactorAuth/RegistryTest.php | 11 |
2 files changed, 30 insertions, 6 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php index 1a21ee047df..7975108c59b 100644 --- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php @@ -136,14 +136,29 @@ class ProviderUserAssignmentDaoTest extends TestCase { $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'); - + $this->dao->persist('twofactor_u2f', 'user2', 0); + + $deleted = $this->dao->deleteByUser('user1'); + + $this->assertEquals( + [ + [ + 'uid' => 'user1', + 'provider_id' => 'twofactor_fail', + 'enabled' => true, + ], + [ + 'uid' => 'user1', + 'provider_id' => 'twofactor_u2f', + 'enabled' => true, + ], + ], + $deleted + ); $statesUser1 = $this->dao->getState('user1'); $statesUser2 = $this->dao->getState('user2'); $this->assertCount(0, $statesUser1); - $this->assertCount(1, $statesUser2); + $this->assertCount(2, $statesUser2); } public function testDeleteAll() { diff --git a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php index 49f4eaa7020..b0d0ef8efef 100644 --- a/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/RegistryTest.php @@ -31,6 +31,7 @@ use OC\Authentication\TwoFactorAuth\Registry; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\Authentication\TwoFactorAuth\IRegistry; use OCP\Authentication\TwoFactorAuth\RegistryEvent; +use OCP\Authentication\TwoFactorAuth\TwoFactorProviderDisabled; use OCP\EventDispatcher\IEventDispatcher; use OCP\IUser; use PHPUnit\Framework\MockObject\MockObject; @@ -115,7 +116,15 @@ class RegistryTest extends TestCase { $user->expects($this->once())->method('getUID')->willReturn('user123'); $this->dao->expects($this->once()) ->method('deleteByUser') - ->with('user123'); + ->with('user123') + ->willReturn([ + [ + 'provider_id' => 'twofactor_u2f', + ] + ]); + $this->dispatcher->expects($this->once()) + ->method('dispatchTyped') + ->with(new TwoFactorProviderDisabled('twofactor_u2f')); $this->registry->deleteUserData($user); } |