diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@smile.fr> | 2015-10-15 13:17:21 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@smile.fr> | 2015-10-15 13:17:21 +0200 |
commit | 18cf594f8ad4bb5236274cf1326c5e6ea549a570 (patch) | |
tree | 27553451392797dc1e3ddf43162de76eb33595a3 /src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |
parent | 0d6a7929e17c84052cbb3e494d5e5c195c24ca04 (diff) | |
download | wallabag-18cf594f8ad4bb5236274cf1326c5e6ea549a570.tar.gz wallabag-18cf594f8ad4bb5236274cf1326c5e6ea549a570.tar.zst wallabag-18cf594f8ad4bb5236274cf1326c5e6ea549a570.zip |
move 2factor activation in parameters
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php index 3402b340..b9f5d835 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |||
@@ -19,40 +19,46 @@ class SecurityControllerTest extends WallabagCoreTestCase | |||
19 | public function testLoginWith2Factor() | 19 | public function testLoginWith2Factor() |
20 | { | 20 | { |
21 | $client = $this->getClient(); | 21 | $client = $this->getClient(); |
22 | $client->followRedirects(); | ||
23 | 22 | ||
24 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 23 | if ($client->getContainer()->getParameter('twofactor_auth')) { |
25 | $user = $em | 24 | $client->followRedirects(); |
26 | ->getRepository('WallabagUserBundle:User') | ||
27 | ->findOneByUsername('admin'); | ||
28 | $user->setTwoFactorAuthentication(true); | ||
29 | $em->persist($user); | ||
30 | $em->flush(); | ||
31 | 25 | ||
32 | $this->logInAs('admin'); | 26 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
33 | $client->request('GET', '/config'); | 27 | $user = $em |
34 | $this->assertContains('trusted computer', $client->getResponse()->getContent()); | 28 | ->getRepository('WallabagUserBundle:User') |
35 | 29 | ->findOneByUsername('admin'); | |
36 | // restore user | 30 | $user->setTwoFactorAuthentication(true); |
37 | $user = $em | 31 | $em->persist($user); |
38 | ->getRepository('WallabagUserBundle:User') | 32 | $em->flush(); |
39 | ->findOneByUsername('admin'); | 33 | |
40 | $user->setTwoFactorAuthentication(false); | 34 | $this->logInAs('admin'); |
41 | $em->persist($user); | 35 | $client->request('GET', '/config'); |
42 | $em->flush(); | 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 | } | ||
43 | } | 46 | } |
44 | 47 | ||
45 | public function testTrustedComputer() | 48 | public function testTrustedComputer() |
46 | { | 49 | { |
47 | $client = $this->getClient(); | 50 | $client = $this->getClient(); |
48 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 51 | |
49 | $user = $em | 52 | if ($client->getContainer()->getParameter('twofactor_auth')) { |
50 | ->getRepository('WallabagUserBundle:User') | 53 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
51 | ->findOneByUsername('admin'); | 54 | $user = $em |
52 | 55 | ->getRepository('WallabagUserBundle:User') | |
53 | $date = new \DateTime(); | 56 | ->findOneByUsername('admin'); |
54 | $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); | 57 | |
55 | $this->assertTrue($user->isTrustedComputer('ABCDEF')); | 58 | $date = new \DateTime(); |
56 | $this->assertFalse($user->isTrustedComputer('FEDCBA')); | 59 | $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); |
60 | $this->assertTrue($user->isTrustedComputer('ABCDEF')); | ||
61 | $this->assertFalse($user->isTrustedComputer('FEDCBA')); | ||
62 | } | ||
57 | } | 63 | } |
58 | } | 64 | } |