aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-03-09 08:59:08 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-03-20 21:12:22 +0100
commit0d42217e4e8210dd2cf86f35ba9662ca02c8a2dc (patch)
tree4cf8b97ed3c06def270e9172c7b17c5c86048585 /src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
parentd2b4f01d7435e8a8f99b15a2487916427c04e58d (diff)
downloadwallabag-0d42217e4e8210dd2cf86f35ba9662ca02c8a2dc.tar.gz
wallabag-0d42217e4e8210dd2cf86f35ba9662ca02c8a2dc.tar.zst
wallabag-0d42217e4e8210dd2cf86f35ba9662ca02c8a2dc.zip
Convert english translation file
- convert english translation to translate key - remove baggy template for login (never used since user isn't logged in and it'll use the default theme: material) - fix tests about text in response (now checking translation key instead of translated text) - remove all ugly `<div class="hidden">{{ form_rest(form) }}</div>`
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php70
1 files changed, 38 insertions, 32 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
index b9f5d835..5c098cc2 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
@@ -12,53 +12,59 @@ class SecurityControllerTest extends WallabagCoreTestCase
12 $client = $this->getClient(); 12 $client = $this->getClient();
13 $client->followRedirects(); 13 $client->followRedirects();
14 14
15 $client->request('GET', '/config'); 15 $crawler = $client->request('GET', '/config');
16 $this->assertContains('RSS', $client->getResponse()->getContent()); 16 $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(array('_text'))[0]);
17 } 17 }
18 18
19 public function testLoginWith2Factor() 19 public function testLoginWith2Factor()
20 { 20 {
21 $client = $this->getClient(); 21 $client = $this->getClient();
22 22
23 if ($client->getContainer()->getParameter('twofactor_auth')) { 23 if (!$client->getContainer()->getParameter('twofactor_auth')) {
24 $client->followRedirects(); 24 $this->markTestSkipped('twofactor_auth is not enabled.');
25 return;
26 }
25 27
26 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 28 $client->followRedirects();
27 $user = $em
28 ->getRepository('WallabagUserBundle:User')
29 ->findOneByUsername('admin');
30 $user->setTwoFactorAuthentication(true);
31 $em->persist($user);
32 $em->flush();
33 29
34 $this->logInAs('admin'); 30 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
35 $client->request('GET', '/config'); 31 $user = $em
36 $this->assertContains('trusted computer', $client->getResponse()->getContent()); 32 ->getRepository('WallabagUserBundle:User')
33 ->findOneByUsername('admin');
34 $user->setTwoFactorAuthentication(true);
35 $em->persist($user);
36 $em->flush();
37 37
38 // restore user 38 $this->logInAs('admin');
39 $user = $em 39 $crawler = $client->request('GET', '/config');
40 ->getRepository('WallabagUserBundle:User') 40 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(array('_text'))[0]);
41 ->findOneByUsername('admin'); 41
42 $user->setTwoFactorAuthentication(false); 42 // restore user
43 $em->persist($user); 43 $user = $em
44 $em->flush(); 44 ->getRepository('WallabagUserBundle:User')
45 } 45 ->findOneByUsername('admin');
46 $user->setTwoFactorAuthentication(false);
47 $em->persist($user);
48 $em->flush();
46 } 49 }
47 50
48 public function testTrustedComputer() 51 public function testTrustedComputer()
49 { 52 {
50 $client = $this->getClient(); 53 $client = $this->getClient();
51 54
52 if ($client->getContainer()->getParameter('twofactor_auth')) { 55 if (!$client->getContainer()->getParameter('twofactor_auth')) {
53 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 56 $this->markTestSkipped('twofactor_auth is not enabled.');
54 $user = $em 57 return;
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 } 58 }
59
60 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
61 $user = $em
62 ->getRepository('WallabagUserBundle:User')
63 ->findOneByUsername('admin');
64
65 $date = new \DateTime();
66 $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
67 $this->assertTrue($user->isTrustedComputer('ABCDEF'));
68 $this->assertFalse($user->isTrustedComputer('FEDCBA'));
63 } 69 }
64} 70}