summaryrefslogtreecommitdiffstats
path: root/apps/twofactor_backupcodes/tests
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-03-05 20:21:37 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-03-05 20:21:37 +0100
commit3d17ab0936c74c1a60360e06bb99fb7ce3cdc161 (patch)
treeb87e19ddda189e65d752b29711eb97d27e510698 /apps/twofactor_backupcodes/tests
parent1c29a01956f13348281d29f276c8c37c85ed93e3 (diff)
downloadnextcloud-server-3d17ab0936c74c1a60360e06bb99fb7ce3cdc161.tar.gz
nextcloud-server-3d17ab0936c74c1a60360e06bb99fb7ce3cdc161.zip
Do not send notification if no active 2fa
If the job is still present we should also not fire it off if there is not a single active 2FA provider. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/twofactor_backupcodes/tests')
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php31
1 files changed, 30 insertions, 1 deletions
diff --git a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php
index 0e23e032bd8..fe68da8ebf5 100644
--- a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php
@@ -114,6 +114,34 @@ class RememberBackupCodesJobTest extends TestCase {
$this->invokePrivate($this->job, 'run', [['uid' => 'validUID']]);
}
+ public function testNoActiveProvider() {
+ $user = $this->createMock(IUser::class);
+ $user->method('getUID')
+ ->willReturn('validUID');
+ $this->userManager->method('get')
+ ->with('validUID')
+ ->willReturn($user);
+
+ $this->registry->method('getProviderStates')
+ ->with($user)
+ ->willReturn([
+ 'backup_codes' => false,
+ 'foo' => false,
+ ]);
+
+ $this->jobList->expects($this->once())
+ ->method('remove')
+ ->with(
+ RememberBackupCodesJob::class,
+ ['uid' => 'validUID']
+ );
+
+ $this->notificationManager->expects($this->never())
+ ->method($this->anything());
+
+ $this->invokePrivate($this->job, 'run', [['uid' => 'validUID']]);
+ }
+
public function testNotificationSend() {
$user = $this->createMock(IUser::class);
$user->method('getUID')
@@ -125,7 +153,8 @@ class RememberBackupCodesJobTest extends TestCase {
$this->registry->method('getProviderStates')
->with($user)
->willReturn([
- 'backup_codes' => false
+ 'backup_codes' => false,
+ 'foo' => true,
]);
$this->jobList->expects($this->never())