aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2018-12-02 12:43:05 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-01-23 13:28:02 +0100
commita6b242a1fd6f8900d80354361449f1bf62506ef9 (patch)
treef69d87208d0ebbdb8517529582280b174af74a16 /tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
parentacd4412080dfb73ecaa7f9983728d1d55bc27ea4 (diff)
downloadwallabag-a6b242a1fd6f8900d80354361449f1bf62506ef9.tar.gz
wallabag-a6b242a1fd6f8900d80354361449f1bf62506ef9.tar.zst
wallabag-a6b242a1fd6f8900d80354361449f1bf62506ef9.zip
Enable OTP 2FA
- Update SchebTwoFactorBundle to version 3 - Enable Google 2fa on the bundle - Disallow ability to use both email and google as 2fa - Update Ocramius Proxy Manager to handle typed function & attributes (from PHP 7) - use `$this->addFlash` shortcut instead of `$this->get('session')->getFlashBag()->add` - update admin to be able to create/reset the 2fa
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php28
1 files changed, 20 insertions, 8 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
index 395208a2..b03c7550 100644
--- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
@@ -26,7 +26,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
26 $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); 26 $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]);
27 } 27 }
28 28
29 public function testLoginWith2Factor() 29 public function testLoginWith2FactorEmail()
30 { 30 {
31 $client = $this->getClient(); 31 $client = $this->getClient();
32 32
@@ -42,7 +42,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
42 $user = $em 42 $user = $em
43 ->getRepository('WallabagUserBundle:User') 43 ->getRepository('WallabagUserBundle:User')
44 ->findOneByUsername('admin'); 44 ->findOneByUsername('admin');
45 $user->setTwoFactorAuthentication(true); 45 $user->setEmailTwoFactor(true);
46 $em->persist($user); 46 $em->persist($user);
47 $em->flush(); 47 $em->flush();
48 48
@@ -54,12 +54,12 @@ class SecurityControllerTest extends WallabagCoreTestCase
54 $user = $em 54 $user = $em
55 ->getRepository('WallabagUserBundle:User') 55 ->getRepository('WallabagUserBundle:User')
56 ->findOneByUsername('admin'); 56 ->findOneByUsername('admin');
57 $user->setTwoFactorAuthentication(false); 57 $user->setEmailTwoFactor(false);
58 $em->persist($user); 58 $em->persist($user);
59 $em->flush(); 59 $em->flush();
60 } 60 }
61 61
62 public function testTrustedComputer() 62 public function testLoginWith2FactorGoogle()
63 { 63 {
64 $client = $this->getClient(); 64 $client = $this->getClient();
65 65
@@ -69,15 +69,27 @@ class SecurityControllerTest extends WallabagCoreTestCase
69 return; 69 return;
70 } 70 }
71 71
72 $client->followRedirects();
73
72 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 74 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
73 $user = $em 75 $user = $em
74 ->getRepository('WallabagUserBundle:User') 76 ->getRepository('WallabagUserBundle:User')
75 ->findOneByUsername('admin'); 77 ->findOneByUsername('admin');
78 $user->setGoogleAuthenticatorSecret('26LDIHYGHNELOQEM');
79 $em->persist($user);
80 $em->flush();
81
82 $this->logInAsUsingHttp('admin');
83 $crawler = $client->request('GET', '/config');
84 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
76 85
77 $date = new \DateTime(); 86 // restore user
78 $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); 87 $user = $em
79 $this->assertTrue($user->isTrustedComputer('ABCDEF')); 88 ->getRepository('WallabagUserBundle:User')
80 $this->assertFalse($user->isTrustedComputer('FEDCBA')); 89 ->findOneByUsername('admin');
90 $user->setGoogleAuthenticatorSecret(null);
91 $em->persist($user);
92 $em->flush();
81 } 93 }
82 94
83 public function testEnabledRegistration() 95 public function testEnabledRegistration()