diff options
author | Morris Jobke <hey@morrisjobke.de> | 2020-08-13 07:25:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 07:25:01 +0200 |
commit | 725fecee3454dd1fabe1b373a8c9a37f81040fd9 (patch) | |
tree | 8928539bdd919e25295ebd7b0b15ce0828b4ee75 /tests/lib/Authentication | |
parent | 3a39f2ae9165fdbf98ad9fafcb52d7dde7f75df8 (diff) | |
parent | 68794ebc9292cdedaa6a52d190e41e58f6edb1ba (diff) | |
download | nextcloud-server-725fecee3454dd1fabe1b373a8c9a37f81040fd9.tar.gz nextcloud-server-725fecee3454dd1fabe1b373a8c9a37f81040fd9.zip |
Merge pull request #21344 from nextcloud/fix/twofactor-cleanup-event
Emit an event for every disabled 2FA provider during cleanup
Diffstat (limited to 'tests/lib/Authentication')
-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); } |