From 4ff1efa41883f80bb1764ea97dd9dd46b557a979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 13 Apr 2020 16:59:02 +0200 Subject: Added a button to disable 2FA when enabled --- .../CoreBundle/Controller/ConfigControllerTest.php | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests') diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php index fa93c9c2..b3b3a19a 100644 --- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php @@ -1045,6 +1045,29 @@ class ConfigControllerTest extends WallabagCoreTestCase $em->flush(); } + public function testUserDisable2faEmail() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/config/otp/email/disable'); + + $this->assertSame(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.config.notice.otp_disabled', $alert[0]); + + // restore user + $em = $this->getEntityManager(); + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('admin'); + + $this->assertFalse($user->isEmailTwoFactor()); + } + public function testUserEnable2faGoogle() { $this->logInAs('admin'); @@ -1099,6 +1122,30 @@ class ConfigControllerTest extends WallabagCoreTestCase $this->assertEmpty($user->getBackupCodes()); } + public function testUserDisable2faGoogle() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/config/otp/app/disable'); + + $this->assertSame(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); + $this->assertContains('flashes.config.notice.otp_disabled', $alert[0]); + + // restore user + $em = $this->getEntityManager(); + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('admin'); + + $this->assertEmpty($user->getGoogleAuthenticatorSecret()); + $this->assertEmpty($user->getBackupCodes()); + } + public function testExportTaggingRule() { $this->logInAs('admin'); -- cgit v1.2.3