aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php58
-rw-r--r--src/Wallabag/UserBundle/Resources/config/services.yml19
2 files changed, 58 insertions, 19 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..3402b340
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
@@ -0,0 +1,58 @@
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 $client->followRedirects();
23
24 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
25 $user = $em
26 ->getRepository('WallabagUserBundle:User')
27 ->findOneByUsername('admin');
28 $user->setTwoFactorAuthentication(true);
29 $em->persist($user);
30 $em->flush();
31
32 $this->logInAs('admin');
33 $client->request('GET', '/config');
34 $this->assertContains('trusted computer', $client->getResponse()->getContent());
35
36 // restore user
37 $user = $em
38 ->getRepository('WallabagUserBundle:User')
39 ->findOneByUsername('admin');
40 $user->setTwoFactorAuthentication(false);
41 $em->persist($user);
42 $em->flush();
43 }
44
45 public function testTrustedComputer()
46 {
47 $client = $this->getClient();
48 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
49 $user = $em
50 ->getRepository('WallabagUserBundle:User')
51 ->findOneByUsername('admin');
52
53 $date = new \DateTime();
54 $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
55 $this->assertTrue($user->isTrustedComputer('ABCDEF'));
56 $this->assertFalse($user->isTrustedComputer('FEDCBA'));
57 }
58}
diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml
index 9cdd247d..e69de29b 100644
--- a/src/Wallabag/UserBundle/Resources/config/services.yml
+++ b/src/Wallabag/UserBundle/Resources/config/services.yml
@@ -1,19 +0,0 @@
1parameters:
2 wallabag_user.twofactor.email.provider.class: Wallabag\UserBundle\Security\TwoFactor\Email\Helper
3 wallabag_user.twofactor.email.interactive_login_listener.class: Wallabag\UserBundle\Security\TwoFactor\Email\InteractiveLoginListener
4 wallabag_user.twofactor.email.request_listener.class: Wallabag\UserBundle\Security\TwoFactor\Email\RequestListener
5
6services:
7 wallabag_user.twofactor.email.provider:
8 class: %wallabag_user.twofactor.email.provider.class%
9 arguments: ['@doctrine.orm.entity_manager', '@mailer']
10 wallabag_user.twofactor.email.interactive_login_listener:
11 class: %wallabag_user.twofactor.email.interactive_login_listener.class%
12 tags:
13 - { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }
14 arguments: ['@wallabag_user.twofactor.email.provider']
15 wallabag_user.twofactor.email.request_listener:
16 class: %wallabag_user.twofactor.email.request_listener.class%
17 tags:
18 - { name: kernel.event_listener, event: kernel.request, method: onCoreRequest, priority: -1 }
19 arguments: ['@wallabag_user.twofactor.email.provider', '@security.context', '@templating', '@router']