3 namespace Wallabag\CoreBundle\Tests\Controller
;
5 use Wallabag\CoreBundle\Tests\WallabagCoreTestCase
;
7 class SecurityControllerTest
extends WallabagCoreTestCase
9 public function testLoginWithout2Factor()
11 $this->logInAs('admin');
12 $client = $this->getClient();
13 $client->followRedirects();
15 $client->request('GET', '/config');
16 $this->assertContains('RSS', $client->getResponse()->getContent());
19 public function testLoginWith2Factor()
21 $client = $this->getClient();
22 $client->followRedirects();
24 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
26 ->getRepository('WallabagUserBundle:User')
27 ->findOneByUsername('admin');
28 $user->setTwoFactorAuthentication(true);
32 $this->logInAs('admin');
33 $client->request('GET', '/config');
34 $this->assertContains('trusted computer', $client->getResponse()->getContent());
38 ->getRepository('WallabagUserBundle:User')
39 ->findOneByUsername('admin');
40 $user->setTwoFactorAuthentication(false);
45 public function testTrustedComputer()
47 $client = $this->getClient();
48 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
50 ->getRepository('WallabagUserBundle:User')
51 ->findOneByUsername('admin');
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'));