diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-06-01 21:27:35 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-06-22 17:59:35 +0200 |
commit | 23634d5d842dabcf5d7475e2becb7e127824239e (patch) | |
tree | b91688722a996c46f27e8fe0542c356424483da3 /src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |
parent | 891a026e31ad54ca90b70f6026f23260cfadb7fd (diff) | |
download | wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.tar.gz wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.tar.zst wallabag-23634d5d842dabcf5d7475e2becb7e127824239e.zip |
Jump to Symfony 3.1
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php deleted file mode 100644 index 2910fa4f..00000000 --- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
6 | |||
7 | class SecurityControllerTest extends WallabagCoreTestCase | ||
8 | { | ||
9 | public function testLoginWithout2Factor() | ||
10 | { | ||
11 | $this->logInAs('admin'); | ||
12 | $client = $this->getClient(); | ||
13 | $client->followRedirects(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/config'); | ||
16 | $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); | ||
17 | } | ||
18 | |||
19 | public function testLoginWith2Factor() | ||
20 | { | ||
21 | $client = $this->getClient(); | ||
22 | |||
23 | if (!$client->getContainer()->getParameter('twofactor_auth')) { | ||
24 | $this->markTestSkipped('twofactor_auth is not enabled.'); | ||
25 | |||
26 | return; | ||
27 | } | ||
28 | |||
29 | $client->followRedirects(); | ||
30 | |||
31 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
32 | $user = $em | ||
33 | ->getRepository('WallabagUserBundle:User') | ||
34 | ->findOneByUsername('admin'); | ||
35 | $user->setTwoFactorAuthentication(true); | ||
36 | $em->persist($user); | ||
37 | $em->flush(); | ||
38 | |||
39 | $this->logInAs('admin'); | ||
40 | $crawler = $client->request('GET', '/config'); | ||
41 | $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]); | ||
42 | |||
43 | // restore user | ||
44 | $user = $em | ||
45 | ->getRepository('WallabagUserBundle:User') | ||
46 | ->findOneByUsername('admin'); | ||
47 | $user->setTwoFactorAuthentication(false); | ||
48 | $em->persist($user); | ||
49 | $em->flush(); | ||
50 | } | ||
51 | |||
52 | public function testTrustedComputer() | ||
53 | { | ||
54 | $client = $this->getClient(); | ||
55 | |||
56 | if (!$client->getContainer()->getParameter('twofactor_auth')) { | ||
57 | $this->markTestSkipped('twofactor_auth is not enabled.'); | ||
58 | |||
59 | return; | ||
60 | } | ||
61 | |||
62 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
63 | $user = $em | ||
64 | ->getRepository('WallabagUserBundle:User') | ||
65 | ->findOneByUsername('admin'); | ||
66 | |||
67 | $date = new \DateTime(); | ||
68 | $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); | ||
69 | $this->assertTrue($user->isTrustedComputer('ABCDEF')); | ||
70 | $this->assertFalse($user->isTrustedComputer('FEDCBA')); | ||
71 | } | ||
72 | } | ||