aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2015-10-15 13:52:52 +0200
committerJeremy Benoist <j0k3r@users.noreply.github.com>2015-10-15 13:52:52 +0200
commit3d3ed955f11006a408c6596eb9151a0afb28e721 (patch)
treeb5bb52afec86a76d39bcca1fb907f4b2d8d5ba82 /src/Wallabag/CoreBundle/Tests/Controller
parentf6af634aecfa08cc925352610968a20f19b94bd8 (diff)
parente9b395ec4b27bdcc4151292836ecc602f21c57a4 (diff)
downloadwallabag-3d3ed955f11006a408c6596eb9151a0afb28e721.tar.gz
wallabag-3d3ed955f11006a408c6596eb9151a0afb28e721.tar.zst
wallabag-3d3ed955f11006a408c6596eb9151a0afb28e721.zip
Merge pull request #1484 from wallabag/v2-2factor-auth
2factor authentication via email
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
new file mode 100644
index 00000000..b9f5d835
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
@@ -0,0 +1,64 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Controller;
4
5use Wallabag\CoreBundle\Tests\WallabagCoreTestCase;
6
7class SecurityControllerTest extends WallabagCoreTestCase
8{
9 public function testLoginWithout2Factor()
10 {
11 $this->logInAs('admin');
12 $client = $this->getClient();
13 $client->followRedirects();
14
15 $client->request('GET', '/config');
16 $this->assertContains('RSS', $client->getResponse()->getContent());
17 }
18
19 public function testLoginWith2Factor()
20 {
21 $client = $this->getClient();
22
23 if ($client->getContainer()->getParameter('twofactor_auth')) {
24 $client->followRedirects();
25
26 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
27 $user = $em
28 ->getRepository('WallabagUserBundle:User')
29 ->findOneByUsername('admin');
30 $user->setTwoFactorAuthentication(true);
31 $em->persist($user);
32 $em->flush();
33
34 $this->logInAs('admin');
35 $client->request('GET', '/config');
36 $this->assertContains('trusted computer', $client->getResponse()->getContent());
37
38 // restore user
39 $user = $em
40 ->getRepository('WallabagUserBundle:User')
41 ->findOneByUsername('admin');
42 $user->setTwoFactorAuthentication(false);
43 $em->persist($user);
44 $em->flush();
45 }
46 }
47
48 public function testTrustedComputer()
49 {
50 $client = $this->getClient();
51
52 if ($client->getContainer()->getParameter('twofactor_auth')) {
53 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
54 $user = $em
55 ->getRepository('WallabagUserBundle:User')
56 ->findOneByUsername('admin');
57
58 $date = new \DateTime();
59 $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
60 $this->assertTrue($user->isTrustedComputer('ABCDEF'));
61 $this->assertFalse($user->isTrustedComputer('FEDCBA'));
62 }
63 }
64}