X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FSecurityControllerTest.php;h=3c3354d7f818e433b10b4e3bb12bd5216bd49e9e;hb=531c8d0a5c55fa93438e227a7d349235fbd31d28;hp=08f4676ed010d2b3db60410c6bbc4fe4a057dff4;hpb=77557d289bafc088baf806e4744f110dfd959300;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php index 08f4676e..3c3354d7 100644 --- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php @@ -6,6 +6,16 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; class SecurityControllerTest extends WallabagCoreTestCase { + public function testLoginWithEmail() + { + $this->logInAsUsingHttp('bigboss@wallabag.org'); + $client = $this->getClient(); + $client->followRedirects(); + + $crawler = $client->request('GET', '/config'); + $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); + } + public function testLoginWithout2Factor() { $this->logInAs('admin'); @@ -13,10 +23,10 @@ class SecurityControllerTest extends WallabagCoreTestCase $client->followRedirects(); $crawler = $client->request('GET', '/config'); - $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(['_text'])[0]); + $this->assertContains('config.form_feed.description', $crawler->filter('body')->extract(['_text'])[0]); } - public function testLoginWith2Factor() + public function testLoginWith2FactorEmail() { $client = $this->getClient(); @@ -32,7 +42,7 @@ class SecurityControllerTest extends WallabagCoreTestCase $user = $em ->getRepository('WallabagUserBundle:User') ->findOneByUsername('admin'); - $user->setTwoFactorAuthentication(true); + $user->setEmailTwoFactor(true); $em->persist($user); $em->flush(); @@ -44,12 +54,12 @@ class SecurityControllerTest extends WallabagCoreTestCase $user = $em ->getRepository('WallabagUserBundle:User') ->findOneByUsername('admin'); - $user->setTwoFactorAuthentication(false); + $user->setEmailTwoFactor(false); $em->persist($user); $em->flush(); } - public function testTrustedComputer() + public function testLoginWith2FactorGoogle() { $client = $this->getClient(); @@ -59,15 +69,27 @@ class SecurityControllerTest extends WallabagCoreTestCase return; } + $client->followRedirects(); + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); $user = $em ->getRepository('WallabagUserBundle:User') ->findOneByUsername('admin'); + $user->setGoogleAuthenticatorSecret('26LDIHYGHNELOQEM'); + $em->persist($user); + $em->flush(); + + $this->logInAsUsingHttp('admin'); + $crawler = $client->request('GET', '/config'); + $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]); - $date = new \DateTime(); - $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); - $this->assertTrue($user->isTrustedComputer('ABCDEF')); - $this->assertFalse($user->isTrustedComputer('FEDCBA')); + // restore user + $user = $em + ->getRepository('WallabagUserBundle:User') + ->findOneByUsername('admin'); + $user->setGoogleAuthenticatorSecret(null); + $em->persist($user); + $em->flush(); } public function testEnabledRegistration() @@ -81,7 +103,7 @@ class SecurityControllerTest extends WallabagCoreTestCase } $client->followRedirects(); - $crawler = $client->request('GET', '/register'); - $this->assertContains('registration.submit', $crawler->filter('body')->extract(['_text'])[0]); + $client->request('GET', '/register'); + $this->assertContains('registration.submit', $client->getResponse()->getContent()); } }