3 namespace Tests\Wallabag\CoreBundle\Controller
;
5 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase
;
7 class SecurityControllerTest
extends WallabagCoreTestCase
9 public function testLoginWithEmail()
11 $this->logInAsUsingHttp('bigboss@wallabag.org');
12 $client = $this->getClient();
13 $client->followRedirects();
15 $crawler = $client->request('GET', '/config');
16 $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]);
19 public function testLoginWithout2Factor()
21 $this->logInAs('admin');
22 $client = $this->getClient();
23 $client->followRedirects();
25 $crawler = $client->request('GET', '/config');
26 $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]);
29 public function testLoginWith2FactorEmail()
31 $client = $this->getClient();
33 if (!$client->getContainer()->getParameter('twofactor_auth')) {
34 $this->markTestSkipped('twofactor_auth is not enabled.');
39 $client->followRedirects();
41 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
43 ->getRepository('WallabagUserBundle:User')
44 ->findOneByUsername('admin');
45 $user->setEmailTwoFactor(true);
49 $this->logInAsUsingHttp('admin');
50 $crawler = $client->request('GET', '/config');
51 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
55 ->getRepository('WallabagUserBundle:User')
56 ->findOneByUsername('admin');
57 $user->setEmailTwoFactor(false);
62 public function testLoginWith2FactorGoogle()
64 $client = $this->getClient();
66 if (!$client->getContainer()->getParameter('twofactor_auth')) {
67 $this->markTestSkipped('twofactor_auth is not enabled.');
72 $client->followRedirects();
74 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
76 ->getRepository('WallabagUserBundle:User')
77 ->findOneByUsername('admin');
78 $user->setGoogleAuthenticatorSecret('26LDIHYGHNELOQEM');
82 $this->logInAsUsingHttp('admin');
83 $crawler = $client->request('GET', '/config');
84 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
88 ->getRepository('WallabagUserBundle:User')
89 ->findOneByUsername('admin');
90 $user->setGoogleAuthenticatorSecret(null);
95 public function testEnabledRegistration()
97 $client = $this->getClient();
99 if (!$client->getContainer()->getParameter('fosuser_registration')) {
100 $this->markTestSkipped('fosuser_registration is not enabled.');
105 $client->followRedirects();
106 $client->request('GET', '/register');
107 $this->assertContains('registration.submit', $client->getResponse()->getContent());