diff options
author | Kevin Decherf <kevin@kdecherf.com> | 2019-01-30 01:02:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-30 01:02:27 +0100 |
commit | 2e5b3fa361098498a9e42a65396a27e1eb487fba (patch) | |
tree | f20677c3d68c1ea756f0835ff179a0d7d3431a67 /tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php | |
parent | c6024246b744e411175318065f7c396bbb5a213e (diff) | |
parent | 4654a83b6438b88e3b7062a21d18999d9df2fb8e (diff) | |
download | wallabag-2e5b3fa361098498a9e42a65396a27e1eb487fba.tar.gz wallabag-2e5b3fa361098498a9e42a65396a27e1eb487fba.tar.zst wallabag-2e5b3fa361098498a9e42a65396a27e1eb487fba.zip |
Merge pull request #3798 from wallabag/update-two-factor-bundle
Enable OTP 2FA
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php | 28 |
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() |