Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace Tests\Wallabag\Controller; use Doctrine\ORM\EntityManagerInterface; use S..
Decoded Output download
<?php
namespace Tests\Wallabag\Controller; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Tests\Wallabag\WallabagTestCase; use Wallabag\Entity\Annotation; use Wallabag\Entity\Config as ConfigEntity; use Wallabag\Entity\Entry; use Wallabag\Entity\IgnoreOriginUserRule; use Wallabag\Entity\Tag; use Wallabag\Entity\TaggingRule; use Wallabag\Entity\User; class ConfigControllerTest extends WallabagTestCase { public function testLogin() { $client = $this->getTestClient(); $client->request("GET", "/new"); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("login", $client->getResponse()->headers->get("location")); } public function testIndex() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertCount(1, $crawler->filter("button[id=config_save]")); $this->assertCount(1, $crawler->filter("button[id=change_passwd_save]")); $this->assertCount(1, $crawler->filter("button[id=update_user_save]")); $this->assertCount(1, $crawler->filter("button[id=feed_config_save]")); } public function testUpdate() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=config_save]")->form(); $data = array("config[items_per_page]" => "30", "config[reading_speed]" => "100", "config[action_mark_as_read]" => "0", "config[language]" => "en"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.config_saved", $crawler->filter("body")->extract(array("_text"))[0]); } public function testChangeReadingSpeed() { $this->logInAs("admin"); $client = $this->getTestClient(); $entry = new Entry($this->getLoggedInUser()); $entry->setUrl("http://0.0.0.0/test-entry1")->setReadingTime(22); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); $this->getEntityManager()->clear(); $crawler = $client->request("GET", "/unread/list"); $form = $crawler->filter("button[id=submit-filter]")->form(); $dataFilters = array("entry_filter[readingTime][right_number]" => 22, "entry_filter[readingTime][left_number]" => 22); $crawler = $client->submit($form, $dataFilters); $this->assertCount(0, $crawler->filter("div[class=entry]")); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("button[id=config_save]")->form(); $data = array("config[reading_speed]" => "400"); $client->submit($form, $data); $crawler = $client->request("GET", "/unread/list"); $form = $crawler->filter("button[id=submit-filter]")->form(); $crawler = $client->submit($form, $dataFilters); $this->assertCount(0, $crawler->filter("div[class=entry]")); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("button[id=config_save]")->form(); $data = array("config[reading_speed]" => "100"); $client->submit($form, $data); } public function dataForUpdateFailed() { return array(array(array("config[items_per_page]" => '', "config[language]" => "en"))); } public function testUpdateFailed($data) { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=config_save]")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("This value should not be blank", $alert[0]); } public function dataForChangePasswordFailed() { return array(array(array("change_passwd[old_password]" => "material", "change_passwd[new_password][first]" => '', "change_passwd[new_password][second]" => ''), "validator.password_wrong_value"), array(array("change_passwd[old_password]" => "mypassword", "change_passwd[new_password][first]" => '', "change_passwd[new_password][second]" => ''), "This value should not be blank"), array(array("change_passwd[old_password]" => "mypassword", "change_passwd[new_password][first]" => "hop", "change_passwd[new_password][second]" => ''), "validator.password_must_match"), array(array("change_passwd[old_password]" => "mypassword", "change_passwd[new_password][first]" => "hop", "change_passwd[new_password][second]" => "hop"), "validator.password_too_short")); } public function testChangePasswordFailed($data, $expectedMessage) { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=change_passwd_save]")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString($expectedMessage, $alert[0]); } public function testChangePassword() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=change_passwd_save]")->form(); $data = array("change_passwd[old_password]" => "mypassword", "change_passwd[new_password][first]" => "mypassword", "change_passwd[new_password][second]" => "mypassword"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.password_updated", $crawler->filter("body")->extract(array("_text"))[0]); } public function dataForUserFailed() { return array(array(array("update_user[name]" => '', "update_user[email]" => ''), "fos_user.email.blank"), array(array("update_user[name]" => '', "update_user[email]" => "test"), "fos_user.email.invalid")); } public function testUserFailed($data, $expectedMessage) { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=update_user_save]")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString($expectedMessage, $alert[0]); } public function testUserUpdate() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=update_user_save]")->form(); $data = array("update_user[name]" => "new name", "update_user[email]" => "[email protected]"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertGreaterThan(1, $alert = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("flashes.config.notice.user_updated", $alert[0]); } public function testFeedUpdateResetToken() { $this->logInAs("admin"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = $em->getRepository(User::class)->findOneByUsername("admin"); if (!$user) { $this->markTestSkipped("No user found in db."); } $config = $user->getConfig(); $config->setFeedToken(null); $em->persist($config); $em->flush(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("config.form_feed.no_token", $body[0]); $client->request("GET", "/generate-token"); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("config.form_feed.token_reset", $body[0]); } public function testGenerateTokenAjax() { $this->logInAs("admin"); $client = $this->getTestClient(); $client->request("GET", "/generate-token", array(), array(), array("HTTP_X-Requested-With" => "XMLHttpRequest")); $this->assertSame(200, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); $this->assertArrayHasKey("token", $content); } public function testRevokeTokenAjax() { $this->logInAs("admin"); $client = $this->getTestClient(); $client->request("GET", "/revoke-token", array(), array(), array("HTTP_X-Requested-With" => "XMLHttpRequest")); $this->assertSame(200, $client->getResponse()->getStatusCode()); } public function testFeedUpdate() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=feed_config_save]")->form(); $data = array("feed_config[feed_limit]" => 12); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.feed_updated", $crawler->filter("body")->extract(array("_text"))[0]); } public function dataForFeedFailed() { return array(array(array("feed_config[feed_limit]" => 0), "This value should be between 1 and 100000."), array(array("feed_config[feed_limit]" => 1000000000000), "validator.feed_limit_too_high")); } public function testFeedFailed($data, $expectedMessage) { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=feed_config_save]")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString($expectedMessage, $alert[0]); } public function testTaggingRuleCreation() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=tagging_rule_save]")->form(); $data = array("tagging_rule[rule]" => "readingTime <= 3", "tagging_rule[tags]" => "short reading"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.tagging_rules_updated", $crawler->filter("body")->extract(array("_text"))[0]); $editLink = $crawler->filter(".mode_edit_tagging_rule")->last()->link(); $crawler = $client->click($editLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("?tagging-rule=", $client->getResponse()->headers->get("location")); $crawler = $client->followRedirect(); $form = $crawler->filter("button[id=tagging_rule_save]")->form(); $data = array("tagging_rule[rule]" => "readingTime <= 30", "tagging_rule[tags]" => "short reading"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.tagging_rules_updated", $crawler->filter("body")->extract(array("_text"))[0]); $this->assertStringContainsString("readingTime <= 30", $crawler->filter("body")->extract(array("_text"))[0]); $deleteLink = $crawler->filter(".delete_tagging_rule")->last()->link(); $crawler = $client->click($deleteLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.tagging_rules_deleted", $crawler->filter("body")->extract(array("_text"))[0]); } public function dataForTaggingRuleFailed() { return array(array(array("tagging_rule[rule]" => "unknownVar <= 3", "tagging_rule[tags]" => "cool tag"), array("The variable", "does not exist.")), array(array("tagging_rule[rule]" => "length(domainName) <= 42", "tagging_rule[tags]" => "cool tag"), array("The operator", "does not exist."))); } public function testTaggingRuleCreationFail($data, $messages) { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=tagging_rule_save]")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); foreach ($messages as $message) { $this->assertStringContainsString($message, $body[0]); } } public function testTaggingRuleTooLong() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=tagging_rule_save]")->form(); $crawler = $client->submit($form, array("tagging_rule[rule]" => str_repeat("title", 60), "tagging_rule[tags]" => "cool tag")); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("255 characters", $body[0]); } public function testDeletingTaggingRuleFromAnOtherUser() { $this->logInAs("bob"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(TaggingRule::class)->findAll()[0]; $crawler = $client->request("GET", "/tagging-rule/delete/" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("You can not access this rule", $body[0]); } public function testEditingTaggingRuleFromAnOtherUser() { $this->logInAs("bob"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(TaggingRule::class)->findAll()[0]; $crawler = $client->request("GET", "/tagging-rule/edit/" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("You can not access this rule", $body[0]); } public function testIgnoreOriginRuleCreation() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=ignore_origin_user_rule_save]")->form(); $data = array("ignore_origin_user_rule[rule]" => "host = "example.com""); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.ignore_origin_rules_updated", $crawler->filter("body")->extract(array("_text"))[0]); $editLink = $crawler->filter("div[id=set6] a.mode_edit")->last()->link(); $crawler = $client->click($editLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("?ignore-origin-user-rule=", $client->getResponse()->headers->get("location")); $crawler = $client->followRedirect(); $form = $crawler->filter("button[id=ignore_origin_user_rule_save]")->form(); $data = array("ignore_origin_user_rule[rule]" => "host = "example.org""); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.ignore_origin_rules_updated", $crawler->filter("body")->extract(array("_text"))[0]); $this->assertStringContainsString("host = "example.org"", $crawler->filter("body")->extract(array("_text"))[0]); $deleteLink = $crawler->filter("div[id=set6] a.delete")->last()->link(); $crawler = $client->click($deleteLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("flashes.config.notice.ignore_origin_rules_deleted", $crawler->filter("body")->extract(array("_text"))[0]); } public function dataForIgnoreOriginRuleCreationFail() { return array(array(array("ignore_origin_user_rule[rule]" => "foo = "bar""), array("The variable", "does not exist.")), array(array("ignore_origin_user_rule[rule]" => "_all != "none""), array("The operator", "does not exist."))); } public function testIgnoreOriginRuleCreationFail($data, $messages) { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=ignore_origin_user_rule_save]")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); foreach ($messages as $message) { $this->assertStringContainsString($message, $body[0]); } } public function testDeletingIgnoreOriginRuleFromAnOtherUser() { $this->logInAs("bob"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(IgnoreOriginUserRule::class)->findAll()[0]; $crawler = $client->request("GET", "/ignore-origin-user-rule/edit/" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("You can not access this rule", $body[0]); } public function testEditingIgnoreOriginRuleFromAnOtherUser() { $this->logInAs("bob"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(IgnoreOriginUserRule::class)->findAll()[0]; $crawler = $client->request("GET", "/ignore-origin-user-rule/edit/" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("You can not access this rule", $body[0]); } public function testDeleteUserButtonVisibility() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringContainsString("config.form_user.delete.button", $body[0]); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = $em->getRepository(User::class)->findOneByUsername("empty"); $user->setEnabled(false); $em->persist($user); $user = $em->getRepository(User::class)->findOneByUsername("bob"); $user->setEnabled(false); $em->persist($user); $em->flush(); $crawler = $client->request("GET", "/config"); $this->assertGreaterThan(1, $body = $crawler->filter("body")->extract(array("_text"))); $this->assertStringNotContainsString("config.form_user.delete.button", $body[0]); $client->request("POST", "/account/delete"); $this->assertSame(403, $client->getResponse()->getStatusCode()); $user = $em->getRepository(User::class)->findOneByUsername("empty"); $user->setEnabled(true); $em->persist($user); $user = $em->getRepository(User::class)->findOneByUsername("bob"); $user->setEnabled(true); $em->persist($user); $em->flush(); } public function testDeleteAccount() { $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = new User(); $user->setName("Wallace"); $user->setEmail("[email protected]"); $user->setUsername("wallace"); $user->setPlainPassword("wallace"); $user->setEnabled(true); $user->addRole("ROLE_SUPER_ADMIN"); $em->persist($user); $config = new ConfigEntity($user); $config->setItemsPerPage(30); $config->setReadingSpeed(200); $config->setLanguage("en"); $config->setPocketConsumerKey("xxxxx"); $em->persist($config); $em->flush(); $this->logInAs("wallace"); $loggedInUserId = $this->getLoggedInUserId(); $crawler = $client->request("GET", "/new"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("form[name=entry]")->form(); $data = array("entry[url]" => $url = "https://github.com/wallabag/wallabag"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->request("GET", "/config"); $deleteForm = $crawler->filter("form[name=delete-account]")->form(); $client->submit($deleteForm); $this->assertSame(302, $client->getResponse()->getStatusCode()); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = $em->getRepository(User::class)->createQueryBuilder("u")->where("u.username = :username")->setParameter("username", "wallace")->getQuery()->getOneOrNullResult(); $this->assertNull($user); $entries = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUser($loggedInUserId); $this->assertEmpty($entries); } public function testReset() { $this->logInAs("empty"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); \assert($user instanceof User); $tag = new Tag(); $tag->setLabel("super"); $em->persist($tag); $entry = new Entry($user); $entry->setUrl("https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html"); $entry->setContent("Youhou"); $entry->setTitle("Youhou"); $entry->addTag($tag); $em->persist($entry); $entry2 = new Entry($user); $entry2->setUrl("http://www.lemonde.de/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html"); $entry2->setContent("Youhou"); $entry2->setTitle("Youhou"); $entry2->addTag($tag); $em->persist($entry2); $annotation = new Annotation($user); $annotation->setText("annotated"); $annotation->setQuote("annotated"); $annotation->setRanges(array()); $annotation->setEntry($entry); $em->persist($annotation); $em->flush(); $crawler = $client->request("GET", "/config#set3"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("form[name=reset-annotations]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.annotations_reset", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $annotationsReset = $em->getRepository(Annotation::class)->findByEntryIdAndUserId($entry->getId(), $user->getId()); $this->assertEmpty($annotationsReset, "Annotations were reset"); $crawler = $client->request("GET", "/config#set3"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("form[name=reset-tags]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.tags_reset", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $tagReset = $em->getRepository(Tag::class)->countAllTags($user->getId()); $this->assertSame(0, $tagReset, "Tags were reset"); $crawler = $client->request("GET", "/config#set3"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("form[name=reset-entries]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.entries_reset", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $entryReset = $em->getRepository(Entry::class)->countAllEntriesByUser($user->getId()); $this->assertSame(0, $entryReset, "Entries were reset"); } public function testResetArchivedEntries() { $this->logInAs("empty"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); \assert($user instanceof User); $tag = new Tag(); $tag->setLabel("super"); $em->persist($tag); $entry = new Entry($user); $entry->setUrl("https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html"); $entry->setContent("Youhou"); $entry->setTitle("Youhou"); $entry->addTag($tag); $em->persist($entry); $annotation = new Annotation($user); $annotation->setText("annotated"); $annotation->setQuote("annotated"); $annotation->setRanges(array()); $annotation->setEntry($entry); $em->persist($annotation); $tagArchived = new Tag(); $tagArchived->setLabel("super"); $em->persist($tagArchived); $entryArchived = new Entry($user); $entryArchived->setUrl("https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html"); $entryArchived->setContent("Youhou"); $entryArchived->setTitle("Youhou"); $entryArchived->addTag($tagArchived); $entryArchived->updateArchived(true); $em->persist($entryArchived); $annotationArchived = new Annotation($user); $annotationArchived->setText("annotated"); $annotationArchived->setQuote("annotated"); $annotationArchived->setRanges(array()); $annotationArchived->setEntry($entryArchived); $em->persist($annotationArchived); $em->flush(); $crawler = $client->request("GET", "/config#set3"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("form[name=reset-archived]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.archived_reset", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $entryReset = $em->getRepository(Entry::class)->countAllEntriesByUser($user->getId()); $this->assertSame(1, $entryReset, "Entries were reset"); $tagReset = $em->getRepository(Tag::class)->countAllTags($user->getId()); $this->assertSame(1, $tagReset, "Tags were reset"); $annotationsReset = $em->getRepository(Annotation::class)->findByEntryIdAndUserId($annotationArchived->getId(), $user->getId()); $this->assertEmpty($annotationsReset, "Annotations were reset"); } public function testResetEntriesCascade() { $this->logInAs("empty"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); \assert($user instanceof User); $tag = new Tag(); $tag->setLabel("super"); $em->persist($tag); $entry = new Entry($user); $entry->setUrl("https://www.lemonde.fr/europe/article/2016/10/01/pour-le-psoe-chaque-election-s-est-transformee-en-une-agonie_5006476_3214.html"); $entry->setContent("Youhou"); $entry->setTitle("Youhou"); $entry->addTag($tag); $em->persist($entry); $annotation = new Annotation($user); $annotation->setText("annotated"); $annotation->setQuote("annotated"); $annotation->setRanges(array()); $annotation->setEntry($entry); $em->persist($annotation); $em->flush(); $crawler = $client->request("GET", "/config#set3"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("form[name=reset-entries]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.entries_reset", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $entryReset = $em->getRepository(Entry::class)->countAllEntriesByUser($user->getId()); $this->assertSame(0, $entryReset, "Entries were reset"); $tagReset = $em->getRepository(Tag::class)->countAllTags($user->getId()); $this->assertSame(0, $tagReset, "Tags were reset"); $annotationsReset = $em->getRepository(Annotation::class)->findByEntryIdAndUserId($entry->getId(), $user->getId()); $this->assertEmpty($annotationsReset, "Annotations were reset"); } public function testSwitchViewMode() { $this->logInAs("admin"); $client = $this->getTestClient(); $client->request("GET", "/unread/list"); $this->assertStringContainsString("row data", $client->getResponse()->getContent()); $client->request("GET", "/config/view-mode"); $crawler = $client->followRedirect(); $client->request("GET", "/unread/list"); $this->assertStringContainsString("collection", $client->getResponse()->getContent()); $client->request("GET", "/config/view-mode"); } public function testChangeLocaleWithoutReferer() { $client = $this->getTestClient(); $client->request("GET", "/locale/de"); $client->followRedirect(); $this->assertSame("de", $client->getRequest()->getLocale()); $this->assertSame("de", $client->getContainer()->get(SessionInterface::class)->get("_locale")); } public function testChangeLocaleWithReferer() { $client = $this->getTestClient(); $client->request("GET", "/login"); $client->request("GET", "/locale/de"); $client->followRedirect(); $this->assertSame("de", $client->getRequest()->getLocale()); $this->assertSame("de", $client->getContainer()->get(SessionInterface::class)->get("_locale")); } public function testChangeLocaleToBadLocale() { $client = $this->getTestClient(); $client->request("GET", "/login"); $client->request("GET", "/locale/yuyuyuyu"); $client->followRedirect(); $this->assertNotSame("yuyuyuyu", $client->getRequest()->getLocale()); $this->assertNotSame("yuyuyuyu", $client->getContainer()->get(SessionInterface::class)->get("_locale")); } public function testUserEnable2faEmail() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("form[name=config_otp_email]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.otp_enabled", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("admin"); $this->assertTrue($user->isEmailTwoFactor()); $user->setEmailTwoFactor(false); $em->persist($user); $em->flush(); } public function testUserDisable2faEmail() { $this->logInAs("admin"); $client = $this->getTestClient(); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("admin"); $user->setEmailTwoFactor(true); $em->persist($user); $em->flush(); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("form[name=disable_otp_email]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.otp_disabled", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("admin"); $this->assertFalse($user->isEmailTwoFactor()); } public function testUserEnable2faGoogle() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("form[name=config_otp_app]")->form(); $client->submit($form); $this->assertSame(200, $client->getResponse()->getStatusCode()); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("admin"); $this->assertTrue($user->isGoogleTwoFactor()); $this->assertGreaterThan(0, $user->getBackupCodes()); $user->setGoogleAuthenticatorSecret(false); $user->setBackupCodes(null); $em->persist($user); $em->flush(); } public function testUserDisable2faGoogle() { $this->logInAs("admin"); $client = $this->getTestClient(); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("admin"); $user->setGoogleAuthenticatorSecret("Google2FA"); $em->persist($user); $em->flush(); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("form[name=disable_otp_app]")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("flashes.config.notice.otp_disabled", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("notice")[0]); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("admin"); $this->assertEmpty($user->getGoogleAuthenticatorSecret()); $this->assertEmpty($user->getBackupCodes()); } public function testExportTaggingRule() { $this->logInAs("admin"); $client = $this->getTestClient(); ob_start(); $crawler = $client->request("GET", "/tagging-rule/export"); ob_end_clean(); $this->assertSame(200, $client->getResponse()->getStatusCode()); $headers = $client->getResponse()->headers; $this->assertSame("application/json", $headers->get("content-type")); $this->assertSame("attachment; filename="tagging_rules_admin.json"", $headers->get("content-disposition")); $this->assertSame("UTF-8", $headers->get("content-transfer-encoding")); $content = json_decode($client->getResponse()->getContent(), true); $this->assertCount(4, $content); $this->assertSame("content matches "spurs"", $content[0]["rule"]); $this->assertSame("sport", $content[0]["tags"][0]); } public function testImportTagginfRuleBadFile() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("form[name=upload_tagging_rule_file] > button[type=submit]")->form(); $data = array("upload_tagging_rule_file[file]" => ''); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); } public function testImportTagginfRuleFile() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $form = $crawler->filter("form[name=upload_tagging_rule_file] > button[type=submit]")->form(); $file = new UploadedFile(__DIR__ . "/../fixtures/tagging_rules_admin.json", "tagging_rules_admin.json"); $data = array("upload_tagging_rule_file[file]" => $file); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $user = static::getContainer()->get("fos_user.user_manager")->findUserBy(array("username" => "admin")); \assert($user instanceof User); $taggingRules = $user->getConfig()->getTaggingRules()->toArray(); $this->assertCount(5, $taggingRules); $this->assertSame("title matches "football"", $taggingRules[4]->getRule()); } public function testSwitchDisplayThumbnails() { $this->logInAs("admin"); $client = $this->getTestClient(); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=config_save]")->form(); $data = array("config[display_thumbnails]" => true); $client->submit($form, $data); $client->followRedirect(); $client->request("GET", "/unread/list"); $this->assertStringContainsString("class="preview"", $client->getResponse()->getContent()); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=config_save]")->form(); $data = array("config[display_thumbnails]" => false); $client->submit($form, $data); $client->followRedirect(); $client->request("GET", "/unread/list"); $this->assertStringNotContainsString("class="preview"", $client->getResponse()->getContent()); $client->request("GET", "/config/view-mode"); } public function testGeneratedCSS() { $this->logInAs("admin"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $entry = $em->getRepository(Entry::class)->findByUrlAndUserId("http://0.0.0.0/entry1", $this->getLoggedInUserId()); $client->request("GET", "/view/" . $entry->getId()); $this->assertStringNotContainsString("font-family: "OpenDyslexicRegular"", $client->getResponse()->getContent()); $this->assertStringNotContainsString("max-width: 60em", $client->getResponse()->getContent()); $this->assertStringNotContainsString("line-height: 2em", $client->getResponse()->getContent()); $this->assertStringNotContainsString("font-size: 2em", $client->getResponse()->getContent()); $crawler = $client->request("GET", "/config"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("button[id=config_save]")->form(); $data = array("config[font]" => "OpenDyslexicRegular", "config[fontsize]" => 2.0, "config[lineHeight]" => 2.0, "config[maxWidth]" => 60); $client->submit($form, $data); $client->followRedirect(); $client->request("GET", "/view/" . $entry->getId()); $this->assertStringContainsString("font-family: "OpenDyslexicRegular"", $client->getResponse()->getContent()); $this->assertStringContainsString("max-width: 60em", $client->getResponse()->getContent()); $this->assertStringContainsString("line-height: 2em", $client->getResponse()->getContent()); $this->assertStringContainsString("font-size: 2em", $client->getResponse()->getContent()); } } ?>
Did this file decode correctly?
Original Code
<?php
namespace Tests\Wallabag\Controller; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Tests\Wallabag\WallabagTestCase; use Wallabag\Entity\Annotation; use Wallabag\Entity\Config as ConfigEntity; use Wallabag\Entity\Entry; use Wallabag\Entity\IgnoreOriginUserRule; use Wallabag\Entity\Tag; use Wallabag\Entity\TaggingRule; use Wallabag\Entity\User; class ConfigControllerTest extends WallabagTestCase { public function testLogin() { $client = $this->getTestClient(); $client->request("\107\105\124", "\57\x6e\145\167"); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\154\157\147\151\x6e", $client->getResponse()->headers->get("\x6c\x6f\x63\x61\x74\151\157\156")); } public function testIndex() { $this->logInAs("\x61\144\x6d\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\x45\x54", "\57\143\157\156\146\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertCount(1, $crawler->filter("\x62\165\x74\164\157\x6e\133\151\144\75\x63\x6f\156\146\151\147\137\x73\141\166\x65\135")); $this->assertCount(1, $crawler->filter("\142\165\x74\x74\157\156\x5b\x69\x64\x3d\x63\150\141\156\147\x65\x5f\x70\141\x73\x73\167\x64\137\x73\141\x76\145\135")); $this->assertCount(1, $crawler->filter("\x62\x75\x74\164\157\x6e\x5b\151\x64\x3d\165\x70\x64\141\x74\145\x5f\x75\x73\145\162\137\163\x61\x76\x65\x5d")); $this->assertCount(1, $crawler->filter("\x62\x75\x74\x74\x6f\x6e\x5b\x69\144\75\146\x65\145\x64\x5f\143\157\156\146\151\147\x5f\x73\141\x76\145\135")); } public function testUpdate() { $this->logInAs("\x61\x64\x6d\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\x47\x45\124", "\x2f\143\x6f\x6e\x66\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\x75\164\164\x6f\x6e\133\151\144\x3d\x63\x6f\x6e\x66\151\147\137\x73\141\x76\145\135")->form(); $data = array("\143\157\x6e\x66\151\147\133\151\164\x65\x6d\163\137\160\145\x72\x5f\160\141\x67\x65\x5d" => "\x33\x30", "\143\157\x6e\146\x69\147\133\x72\x65\x61\x64\x69\x6e\147\137\x73\160\145\145\x64\x5d" => "\61\x30\60", "\x63\x6f\x6e\146\x69\147\133\x61\143\164\x69\157\x6e\137\155\141\x72\153\137\141\x73\137\162\145\141\144\x5d" => "\x30", "\143\x6f\156\x66\151\x67\133\154\141\x6e\x67\165\x61\147\x65\x5d" => "\x65\156"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\x66\x6c\x61\x73\150\x65\x73\x2e\143\x6f\156\146\x69\x67\56\x6e\157\164\x69\x63\145\56\143\157\x6e\x66\x69\x67\x5f\163\x61\166\145\144", $crawler->filter("\142\x6f\x64\171")->extract(array("\137\x74\x65\x78\x74"))[0]); } public function testChangeReadingSpeed() { $this->logInAs("\x61\144\155\x69\x6e"); $client = $this->getTestClient(); $entry = new Entry($this->getLoggedInUser()); $entry->setUrl("\150\x74\x74\160\72\x2f\57\x30\56\60\56\60\56\60\57\x74\145\x73\x74\x2d\145\x6e\x74\162\171\61")->setReadingTime(22); $this->getEntityManager()->persist($entry); $this->getEntityManager()->flush(); $this->getEntityManager()->clear(); $crawler = $client->request("\107\105\x54", "\x2f\x75\x6e\x72\145\x61\x64\x2f\154\x69\163\x74"); $form = $crawler->filter("\x62\x75\164\x74\157\156\133\151\144\75\x73\165\x62\x6d\151\x74\55\x66\x69\x6c\164\x65\162\x5d")->form(); $dataFilters = array("\x65\x6e\x74\162\x79\137\146\151\154\x74\145\162\x5b\x72\x65\141\144\x69\x6e\147\124\151\x6d\145\135\x5b\162\151\147\x68\164\137\156\165\155\142\145\x72\x5d" => 22, "\145\x6e\x74\162\x79\x5f\146\x69\x6c\164\145\162\x5b\162\x65\x61\144\151\x6e\x67\x54\151\155\x65\x5d\133\x6c\x65\x66\164\x5f\156\x75\155\142\145\x72\x5d" => 22); $crawler = $client->submit($form, $dataFilters); $this->assertCount(0, $crawler->filter("\x64\151\166\133\x63\x6c\141\163\163\x3d\145\x6e\164\x72\171\x5d")); $crawler = $client->request("\107\105\x54", "\x2f\143\157\156\x66\x69\147"); $form = $crawler->filter("\142\x75\164\x74\x6f\x6e\133\151\x64\75\x63\x6f\156\146\x69\x67\x5f\163\x61\166\x65\135")->form(); $data = array("\143\x6f\x6e\x66\151\x67\133\x72\x65\141\x64\151\x6e\x67\x5f\x73\x70\145\145\x64\x5d" => "\x34\60\x30"); $client->submit($form, $data); $crawler = $client->request("\107\x45\124", "\57\x75\156\x72\x65\x61\144\x2f\154\x69\x73\164"); $form = $crawler->filter("\142\x75\164\x74\157\x6e\x5b\x69\144\x3d\163\x75\x62\155\151\164\55\146\151\154\164\145\162\x5d")->form(); $crawler = $client->submit($form, $dataFilters); $this->assertCount(0, $crawler->filter("\x64\x69\166\x5b\x63\x6c\141\x73\163\x3d\x65\x6e\164\162\171\x5d")); $crawler = $client->request("\x47\x45\x54", "\x2f\143\157\156\146\151\147"); $form = $crawler->filter("\x62\x75\164\x74\x6f\156\x5b\151\144\x3d\143\x6f\x6e\x66\151\147\137\x73\141\x76\145\135")->form(); $data = array("\143\157\x6e\x66\x69\x67\133\x72\145\141\x64\151\x6e\x67\x5f\163\x70\x65\145\144\135" => "\x31\60\x30"); $client->submit($form, $data); } public function dataForUpdateFailed() { return array(array(array("\x63\x6f\x6e\x66\151\x67\x5b\x69\x74\145\155\x73\137\x70\x65\x72\x5f\160\x61\x67\x65\135" => '', "\143\x6f\x6e\146\x69\x67\133\x6c\141\x6e\x67\165\141\147\x65\135" => "\x65\x6e"))); } public function testUpdateFailed($data) { $this->logInAs("\x61\144\155\x69\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\x45\x54", "\57\x63\157\156\146\151\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\165\164\164\x6f\156\133\x69\x64\x3d\x63\x6f\x6e\146\x69\147\x5f\x73\141\166\145\x5d")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("\142\157\144\171")->extract(array("\137\164\145\170\x74"))); $this->assertStringContainsString("\124\x68\151\x73\x20\166\141\x6c\165\145\x20\163\150\x6f\165\154\x64\40\156\x6f\164\x20\x62\145\40\x62\154\x61\156\153", $alert[0]); } public function dataForChangePasswordFailed() { return array(array(array("\143\150\141\x6e\x67\145\x5f\x70\x61\163\163\x77\x64\133\157\154\144\137\160\141\x73\163\x77\x6f\162\x64\x5d" => "\155\x61\164\145\162\151\x61\x6c", "\x63\x68\x61\x6e\x67\145\137\160\141\x73\x73\167\144\133\x6e\145\x77\x5f\x70\141\x73\163\x77\x6f\x72\144\135\133\x66\x69\162\x73\x74\x5d" => '', "\143\x68\141\x6e\147\145\137\160\141\163\x73\x77\144\133\x6e\145\x77\137\160\141\163\x73\x77\157\x72\144\x5d\133\x73\x65\143\157\156\144\135" => ''), "\x76\141\154\x69\x64\141\x74\157\x72\x2e\160\141\163\163\167\x6f\x72\144\137\167\x72\157\x6e\147\137\166\x61\x6c\x75\x65"), array(array("\143\150\x61\x6e\x67\145\137\x70\141\x73\163\x77\144\x5b\157\x6c\x64\x5f\160\141\x73\163\167\x6f\162\144\x5d" => "\155\171\x70\141\163\163\167\157\162\x64", "\143\150\141\156\x67\x65\137\160\x61\163\163\x77\x64\133\156\x65\167\137\x70\x61\x73\163\167\157\162\x64\x5d\133\146\151\162\x73\164\135" => '', "\143\150\x61\x6e\x67\x65\137\x70\x61\x73\163\x77\x64\x5b\x6e\x65\x77\137\x70\x61\x73\x73\167\x6f\x72\144\135\x5b\163\145\x63\157\x6e\144\135" => ''), "\124\x68\x69\x73\40\166\141\x6c\x75\145\x20\x73\x68\157\x75\x6c\144\40\x6e\157\x74\40\x62\145\40\142\154\141\156\153"), array(array("\x63\x68\141\x6e\147\x65\137\x70\141\163\x73\x77\x64\x5b\157\154\x64\x5f\160\141\163\x73\167\x6f\x72\144\135" => "\x6d\x79\x70\x61\163\163\167\x6f\162\x64", "\143\150\141\x6e\x67\145\x5f\160\141\163\x73\x77\x64\x5b\x6e\x65\167\137\x70\141\163\x73\167\x6f\162\144\x5d\x5b\146\151\162\163\x74\135" => "\150\x6f\160", "\143\150\x61\156\147\145\x5f\160\141\x73\x73\167\144\133\x6e\145\x77\x5f\160\x61\x73\163\167\x6f\x72\x64\x5d\133\x73\x65\x63\157\x6e\144\x5d" => ''), "\166\141\x6c\x69\x64\x61\x74\157\x72\x2e\160\141\x73\x73\167\157\x72\144\x5f\x6d\x75\x73\x74\x5f\155\x61\164\x63\x68"), array(array("\143\150\141\156\147\x65\x5f\160\141\x73\163\167\144\133\x6f\154\x64\x5f\160\141\163\x73\x77\x6f\162\144\135" => "\155\171\x70\141\163\163\x77\157\162\144", "\x63\150\x61\x6e\147\x65\x5f\160\141\163\163\167\144\x5b\x6e\x65\x77\137\160\x61\x73\x73\167\x6f\x72\x64\x5d\x5b\146\x69\162\x73\x74\x5d" => "\x68\x6f\x70", "\x63\150\x61\156\147\x65\137\x70\141\x73\x73\167\x64\133\x6e\145\167\137\x70\x61\x73\x73\x77\x6f\162\x64\x5d\133\163\145\143\x6f\x6e\144\135" => "\x68\157\x70"), "\x76\x61\154\x69\144\x61\x74\x6f\x72\x2e\160\x61\x73\x73\x77\x6f\x72\x64\x5f\x74\157\x6f\137\163\x68\157\x72\164")); } public function testChangePasswordFailed($data, $expectedMessage) { $this->logInAs("\x61\144\155\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\x47\x45\x54", "\57\x63\x6f\156\x66\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\165\x74\164\157\156\x5b\151\144\75\x63\150\141\156\147\x65\x5f\160\141\163\x73\167\144\137\163\141\x76\x65\135")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("\142\x6f\x64\x79")->extract(array("\x5f\x74\145\170\x74"))); $this->assertStringContainsString($expectedMessage, $alert[0]); } public function testChangePassword() { $this->logInAs("\141\x64\155\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\x45\124", "\57\x63\x6f\x6e\x66\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\x75\164\164\157\156\133\151\144\75\x63\150\x61\156\147\145\137\x70\x61\163\x73\167\x64\137\163\141\x76\145\135")->form(); $data = array("\x63\x68\x61\x6e\147\x65\x5f\160\x61\x73\x73\x77\x64\133\x6f\x6c\x64\x5f\160\x61\163\x73\x77\157\162\x64\135" => "\155\x79\x70\x61\163\163\167\157\162\x64", "\x63\x68\141\x6e\147\145\x5f\160\x61\163\x73\167\144\133\156\x65\x77\137\160\141\163\x73\167\x6f\x72\144\x5d\x5b\x66\151\x72\163\x74\x5d" => "\155\x79\x70\x61\163\163\x77\x6f\x72\144", "\143\150\141\156\x67\145\x5f\x70\x61\163\x73\167\x64\133\156\x65\167\137\160\141\x73\163\167\x6f\162\144\x5d\133\x73\145\143\x6f\156\x64\x5d" => "\x6d\171\160\x61\163\163\167\x6f\x72\x64"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\146\154\141\163\150\145\x73\56\x63\x6f\156\x66\151\147\56\x6e\157\164\151\143\145\x2e\160\141\x73\163\x77\x6f\162\x64\x5f\165\x70\144\x61\164\x65\144", $crawler->filter("\x62\x6f\x64\x79")->extract(array("\137\164\145\170\x74"))[0]); } public function dataForUserFailed() { return array(array(array("\165\160\x64\x61\x74\x65\137\165\163\145\162\x5b\156\141\155\x65\135" => '', "\165\x70\x64\141\164\x65\x5f\x75\x73\145\162\133\145\155\x61\x69\x6c\x5d" => ''), "\146\x6f\163\x5f\x75\163\x65\x72\x2e\x65\x6d\x61\151\x6c\56\142\154\x61\x6e\x6b"), array(array("\165\x70\x64\141\x74\145\137\x75\x73\145\x72\133\156\x61\x6d\145\x5d" => '', "\x75\160\x64\141\164\x65\x5f\165\x73\x65\162\x5b\x65\155\x61\151\x6c\x5d" => "\164\145\163\164"), "\x66\x6f\163\x5f\x75\x73\x65\162\56\x65\x6d\141\151\x6c\x2e\151\x6e\x76\x61\x6c\151\x64")); } public function testUserFailed($data, $expectedMessage) { $this->logInAs("\x61\144\155\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\x54", "\57\x63\x6f\156\x66\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\x75\164\x74\157\156\x5b\x69\x64\75\x75\x70\144\x61\x74\145\x5f\x75\163\145\162\137\x73\x61\166\145\x5d")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("\142\x6f\144\x79")->extract(array("\137\x74\145\x78\x74"))); $this->assertStringContainsString($expectedMessage, $alert[0]); } public function testUserUpdate() { $this->logInAs("\x61\x64\x6d\151\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\107\x45\x54", "\57\143\157\156\x66\x69\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\165\164\164\157\156\133\151\x64\x3d\x75\x70\x64\141\164\145\137\x75\163\145\x72\x5f\x73\x61\x76\x65\135")->form(); $data = array("\165\160\x64\x61\x74\x65\137\165\163\145\x72\x5b\156\x61\x6d\x65\135" => "\x6e\145\167\x20\x6e\x61\155\145", "\165\x70\x64\x61\x74\145\x5f\165\163\x65\162\133\x65\155\141\x69\x6c\135" => "\x61\144\x6d\151\x6e\100\167\x61\154\154\x61\142\141\x67\x2e\151\157"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertGreaterThan(1, $alert = $crawler->filter("\142\157\x64\171")->extract(array("\x5f\164\145\170\x74"))); $this->assertStringContainsString("\x66\x6c\x61\x73\150\145\x73\56\x63\157\x6e\146\x69\x67\56\x6e\x6f\x74\151\x63\145\x2e\165\x73\x65\x72\137\165\160\x64\x61\164\x65\x64", $alert[0]); } public function testFeedUpdateResetToken() { $this->logInAs("\x61\x64\x6d\x69\x6e"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = $em->getRepository(User::class)->findOneByUsername("\141\144\155\x69\x6e"); if (!$user) { $this->markTestSkipped("\x4e\157\40\165\x73\145\x72\40\x66\157\x75\156\x64\40\x69\156\40\x64\x62\56"); } $config = $user->getConfig(); $config->setFeedToken(null); $em->persist($config); $em->flush(); $crawler = $client->request("\107\105\x54", "\x2f\x63\x6f\156\146\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\142\157\144\x79")->extract(array("\137\x74\145\170\x74"))); $this->assertStringContainsString("\x63\x6f\x6e\146\151\x67\x2e\x66\x6f\x72\155\137\x66\x65\x65\x64\56\156\157\137\x74\157\153\x65\x6e", $body[0]); $client->request("\107\x45\124", "\57\147\145\156\145\x72\x61\164\145\x2d\x74\157\x6b\145\x6e"); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertGreaterThan(1, $body = $crawler->filter("\142\x6f\144\x79")->extract(array("\137\x74\145\x78\164"))); $this->assertStringContainsString("\x63\157\x6e\x66\x69\x67\x2e\146\x6f\162\x6d\137\146\145\145\144\56\x74\157\x6b\145\156\137\x72\145\163\145\x74", $body[0]); } public function testGenerateTokenAjax() { $this->logInAs("\141\x64\155\151\x6e"); $client = $this->getTestClient(); $client->request("\x47\105\124", "\57\x67\145\156\x65\x72\141\x74\x65\x2d\164\157\x6b\145\156", array(), array(), array("\x48\x54\124\x50\137\x58\55\122\145\161\x75\145\163\x74\x65\x64\x2d\127\x69\x74\x68" => "\x58\x4d\114\x48\164\x74\160\122\x65\x71\165\x65\163\x74")); $this->assertSame(200, $client->getResponse()->getStatusCode()); $content = json_decode($client->getResponse()->getContent(), true); $this->assertArrayHasKey("\164\x6f\153\145\156", $content); } public function testRevokeTokenAjax() { $this->logInAs("\141\x64\x6d\x69\156"); $client = $this->getTestClient(); $client->request("\107\x45\124", "\57\162\145\166\x6f\153\x65\55\x74\x6f\153\145\156", array(), array(), array("\110\124\x54\x50\137\130\55\x52\145\161\165\145\x73\x74\x65\144\55\127\151\x74\150" => "\130\x4d\114\110\164\164\160\x52\x65\161\x75\x65\x73\164")); $this->assertSame(200, $client->getResponse()->getStatusCode()); } public function testFeedUpdate() { $this->logInAs("\141\x64\155\x69\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\x54", "\57\143\157\x6e\x66\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\165\164\164\x6f\156\x5b\x69\144\x3d\146\x65\x65\144\x5f\x63\x6f\156\x66\x69\147\137\163\x61\166\145\x5d")->form(); $data = array("\146\145\x65\144\137\143\157\156\146\x69\x67\x5b\x66\x65\145\x64\x5f\x6c\151\155\151\x74\x5d" => 12); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\146\x6c\x61\163\150\145\163\x2e\x63\x6f\156\x66\x69\x67\x2e\x6e\157\x74\151\143\145\56\x66\145\x65\144\137\165\x70\x64\141\164\145\x64", $crawler->filter("\142\157\144\x79")->extract(array("\137\x74\145\x78\x74"))[0]); } public function dataForFeedFailed() { return array(array(array("\x66\145\145\144\x5f\143\157\156\x66\x69\147\133\x66\x65\x65\144\137\x6c\151\x6d\x69\x74\135" => 0), "\x54\x68\151\x73\40\x76\x61\x6c\165\x65\x20\x73\x68\157\x75\154\x64\40\x62\145\x20\x62\x65\x74\167\x65\145\x6e\40\x31\x20\141\156\x64\40\61\x30\60\x30\x30\x30\56"), array(array("\146\x65\x65\x64\x5f\x63\x6f\x6e\x66\x69\147\133\146\145\145\144\137\x6c\x69\155\x69\164\135" => 1000000000000), "\x76\141\x6c\x69\x64\x61\164\x6f\162\56\146\x65\145\x64\x5f\x6c\151\x6d\x69\164\137\164\x6f\x6f\137\150\x69\147\150")); } public function testFeedFailed($data, $expectedMessage) { $this->logInAs("\x61\144\x6d\x69\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\x54", "\x2f\x63\x6f\156\146\x69\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\165\164\164\157\x6e\133\151\144\x3d\146\x65\145\x64\137\x63\x6f\x6e\146\151\147\x5f\x73\141\x76\x65\135")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $alert = $crawler->filter("\142\x6f\x64\x79")->extract(array("\137\x74\x65\170\x74"))); $this->assertStringContainsString($expectedMessage, $alert[0]); } public function testTaggingRuleCreation() { $this->logInAs("\141\x64\x6d\x69\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\x54", "\57\x63\157\156\x66\151\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\165\x74\x74\157\156\133\151\144\x3d\x74\x61\147\x67\151\156\147\137\162\165\x6c\145\137\163\141\166\x65\135")->form(); $data = array("\x74\141\147\x67\x69\156\x67\137\x72\165\x6c\145\x5b\162\165\x6c\145\135" => "\x72\x65\x61\144\x69\156\x67\x54\151\x6d\145\x20\x3c\75\40\63", "\x74\x61\147\x67\x69\156\147\137\162\165\x6c\x65\133\164\x61\147\x73\x5d" => "\x73\150\x6f\162\164\x20\x72\145\x61\144\151\x6e\x67"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\146\154\141\x73\150\x65\x73\x2e\x63\x6f\x6e\146\x69\147\56\x6e\x6f\x74\x69\x63\145\56\x74\x61\x67\147\x69\x6e\x67\x5f\x72\165\154\x65\x73\x5f\x75\x70\x64\x61\164\x65\144", $crawler->filter("\142\x6f\x64\171")->extract(array("\137\164\145\x78\x74"))[0]); $editLink = $crawler->filter("\x2e\155\x6f\144\x65\x5f\x65\144\151\164\x5f\x74\141\147\147\151\156\147\x5f\162\165\154\x65")->last()->link(); $crawler = $client->click($editLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x3f\x74\x61\x67\x67\x69\x6e\147\x2d\x72\165\154\145\x3d", $client->getResponse()->headers->get("\154\x6f\143\x61\164\x69\157\156")); $crawler = $client->followRedirect(); $form = $crawler->filter("\142\165\x74\164\157\156\133\x69\144\75\x74\x61\147\147\151\x6e\147\x5f\162\165\x6c\x65\137\163\x61\166\145\x5d")->form(); $data = array("\164\141\147\x67\151\x6e\x67\137\162\x75\154\x65\133\162\x75\x6c\145\135" => "\x72\145\141\144\x69\x6e\147\x54\x69\155\x65\40\74\75\40\x33\60", "\164\x61\147\147\x69\156\147\x5f\162\x75\x6c\x65\133\x74\x61\x67\x73\135" => "\163\x68\157\162\x74\40\x72\145\x61\x64\x69\x6e\147"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\x66\x6c\141\x73\150\145\163\x2e\x63\157\156\146\151\147\x2e\156\157\x74\151\x63\145\x2e\164\141\x67\x67\x69\156\x67\137\x72\x75\x6c\x65\x73\x5f\165\160\144\141\164\145\144", $crawler->filter("\x62\x6f\x64\171")->extract(array("\137\x74\145\x78\x74"))[0]); $this->assertStringContainsString("\162\x65\x61\x64\x69\156\x67\124\x69\x6d\145\40\74\75\x20\x33\x30", $crawler->filter("\142\x6f\144\171")->extract(array("\137\164\145\170\164"))[0]); $deleteLink = $crawler->filter("\56\x64\x65\154\x65\x74\x65\137\x74\141\x67\x67\x69\156\147\x5f\162\x75\154\x65")->last()->link(); $crawler = $client->click($deleteLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\146\x6c\141\163\150\145\x73\x2e\143\x6f\x6e\x66\151\147\56\x6e\157\164\151\143\x65\x2e\164\x61\x67\147\x69\x6e\147\x5f\x72\165\154\145\x73\x5f\x64\x65\154\x65\x74\x65\x64", $crawler->filter("\x62\x6f\144\x79")->extract(array("\x5f\x74\145\170\x74"))[0]); } public function dataForTaggingRuleFailed() { return array(array(array("\164\141\x67\147\x69\x6e\x67\137\x72\165\x6c\145\133\x72\165\x6c\x65\x5d" => "\x75\156\x6b\156\157\167\x6e\x56\x61\162\40\x3c\x3d\40\x33", "\164\x61\x67\x67\151\x6e\147\137\162\165\154\x65\133\x74\x61\x67\163\x5d" => "\x63\157\157\154\x20\x74\141\147"), array("\124\x68\x65\40\x76\141\x72\x69\141\x62\154\145", "\144\157\145\163\40\x6e\x6f\164\x20\145\x78\151\163\164\56")), array(array("\164\x61\147\147\151\156\147\137\x72\x75\154\145\x5b\x72\x75\x6c\x65\x5d" => "\154\x65\x6e\147\164\x68\50\x64\x6f\155\141\151\x6e\116\x61\155\x65\x29\40\x3c\75\40\64\62", "\x74\141\147\x67\151\x6e\147\x5f\162\x75\154\x65\133\x74\x61\x67\163\x5d" => "\x63\157\157\x6c\40\164\x61\x67"), array("\124\x68\x65\x20\x6f\x70\x65\x72\141\x74\157\162", "\144\x6f\145\x73\40\x6e\x6f\164\40\x65\x78\151\x73\164\56"))); } public function testTaggingRuleCreationFail($data, $messages) { $this->logInAs("\x61\x64\155\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\x47\x45\x54", "\x2f\x63\x6f\156\x66\x69\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\x75\164\164\x6f\156\133\x69\144\75\164\141\x67\147\151\156\147\x5f\162\x75\154\x65\x5f\163\141\x76\145\x5d")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\x62\157\x64\x79")->extract(array("\x5f\164\145\x78\x74"))); foreach ($messages as $message) { $this->assertStringContainsString($message, $body[0]); } } public function testTaggingRuleTooLong() { $this->logInAs("\141\144\x6d\151\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\x47\x45\x54", "\57\143\157\156\146\151\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\165\164\164\x6f\x6e\x5b\151\x64\x3d\164\x61\147\147\x69\156\x67\x5f\x72\x75\x6c\x65\x5f\x73\141\x76\x65\x5d")->form(); $crawler = $client->submit($form, array("\x74\x61\147\x67\151\156\147\137\162\165\154\145\133\x72\165\x6c\x65\135" => str_repeat("\x74\x69\164\x6c\x65", 60), "\164\x61\x67\x67\x69\156\x67\x5f\162\x75\154\145\133\164\x61\x67\163\x5d" => "\x63\157\x6f\154\40\x74\x61\147")); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\x62\x6f\144\x79")->extract(array("\x5f\164\145\x78\164"))); $this->assertStringContainsString("\62\x35\65\40\143\x68\x61\162\141\x63\164\x65\x72\x73", $body[0]); } public function testDeletingTaggingRuleFromAnOtherUser() { $this->logInAs("\142\x6f\x62"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(TaggingRule::class)->findAll()[0]; $crawler = $client->request("\x47\x45\124", "\57\x74\x61\147\147\x69\156\x67\55\x72\165\154\x65\57\x64\x65\154\145\164\x65\57" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\142\157\144\x79")->extract(array("\137\164\x65\x78\164"))); $this->assertStringContainsString("\131\157\x75\x20\x63\x61\156\x20\x6e\157\164\x20\x61\143\143\x65\163\x73\x20\164\150\x69\x73\40\162\x75\154\x65", $body[0]); } public function testEditingTaggingRuleFromAnOtherUser() { $this->logInAs("\142\x6f\x62"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(TaggingRule::class)->findAll()[0]; $crawler = $client->request("\x47\x45\124", "\x2f\164\x61\x67\x67\x69\x6e\147\x2d\162\x75\154\x65\57\x65\x64\151\164\x2f" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\142\157\x64\x79")->extract(array("\137\164\145\x78\x74"))); $this->assertStringContainsString("\131\x6f\x75\40\143\x61\x6e\x20\156\x6f\x74\40\141\143\x63\145\x73\x73\40\164\150\151\x73\x20\x72\165\x6c\x65", $body[0]); } public function testIgnoreOriginRuleCreation() { $this->logInAs("\x61\x64\155\151\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\107\x45\124", "\57\143\x6f\156\x66\x69\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\x75\164\164\157\x6e\x5b\151\144\75\151\147\156\157\x72\x65\137\157\162\x69\x67\151\x6e\x5f\165\x73\x65\162\137\x72\x75\154\145\x5f\163\141\166\x65\135")->form(); $data = array("\x69\x67\x6e\157\x72\145\137\x6f\162\x69\x67\151\x6e\137\x75\x73\x65\x72\137\x72\165\154\x65\133\x72\x75\x6c\x65\135" => "\150\x6f\163\x74\x20\x3d\x20\42\145\170\x61\x6d\160\154\x65\x2e\143\157\x6d\x22"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\x66\154\x61\x73\x68\145\163\x2e\143\x6f\156\146\151\x67\x2e\x6e\x6f\164\151\x63\x65\x2e\x69\147\156\x6f\x72\x65\x5f\157\162\151\147\151\156\137\x72\x75\154\145\163\x5f\165\x70\x64\141\x74\x65\x64", $crawler->filter("\x62\x6f\144\171")->extract(array("\x5f\x74\x65\x78\x74"))[0]); $editLink = $crawler->filter("\x64\x69\166\133\151\144\x3d\x73\x65\x74\66\x5d\40\x61\x2e\155\x6f\144\145\137\x65\x64\x69\164")->last()->link(); $crawler = $client->click($editLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x3f\x69\x67\156\x6f\x72\145\x2d\x6f\162\151\147\151\156\55\x75\x73\x65\x72\x2d\162\165\154\x65\75", $client->getResponse()->headers->get("\x6c\157\x63\141\x74\151\x6f\156")); $crawler = $client->followRedirect(); $form = $crawler->filter("\142\165\164\164\157\156\x5b\151\x64\75\151\147\x6e\x6f\x72\x65\137\157\162\151\x67\x69\x6e\137\165\x73\x65\x72\137\162\x75\x6c\145\137\163\x61\x76\145\135")->form(); $data = array("\151\147\x6e\157\162\x65\137\157\162\x69\147\151\x6e\137\x75\163\x65\162\137\x72\x75\x6c\145\133\162\x75\154\145\135" => "\150\x6f\x73\164\x20\75\x20\42\145\170\141\x6d\160\154\x65\56\x6f\x72\x67\x22"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\146\154\x61\x73\x68\145\163\x2e\143\157\x6e\146\x69\x67\x2e\x6e\x6f\x74\151\x63\x65\56\x69\147\156\157\x72\x65\x5f\157\162\x69\x67\151\x6e\137\162\x75\154\x65\x73\137\165\x70\144\141\164\145\144", $crawler->filter("\x62\157\x64\x79")->extract(array("\137\164\x65\170\164"))[0]); $this->assertStringContainsString("\x68\157\x73\x74\40\x3d\x20\42\145\x78\141\x6d\x70\154\145\56\x6f\x72\x67\x22", $crawler->filter("\x62\157\144\x79")->extract(array("\x5f\x74\145\170\164"))[0]); $deleteLink = $crawler->filter("\144\151\x76\133\x69\144\x3d\x73\145\x74\x36\x5d\40\x61\x2e\x64\145\x6c\x65\x74\145")->last()->link(); $crawler = $client->click($deleteLink); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->followRedirect(); $this->assertStringContainsString("\146\x6c\x61\x73\150\145\163\56\143\157\156\146\151\147\x2e\x6e\x6f\164\x69\143\x65\56\x69\147\x6e\x6f\162\145\137\157\162\151\x67\x69\x6e\x5f\x72\165\x6c\x65\163\x5f\x64\x65\x6c\x65\164\x65\144", $crawler->filter("\142\x6f\144\171")->extract(array("\137\164\x65\x78\x74"))[0]); } public function dataForIgnoreOriginRuleCreationFail() { return array(array(array("\x69\x67\x6e\157\x72\145\137\x6f\x72\151\147\151\156\x5f\x75\x73\145\162\x5f\x72\x75\154\x65\133\x72\x75\154\x65\135" => "\146\x6f\157\40\75\40\x22\x62\141\162\42"), array("\x54\x68\145\40\166\x61\x72\x69\x61\x62\154\145", "\x64\x6f\x65\163\x20\x6e\x6f\x74\x20\x65\170\x69\163\164\56")), array(array("\151\147\x6e\x6f\162\x65\137\x6f\162\151\x67\151\x6e\x5f\165\163\x65\x72\x5f\162\x75\x6c\145\133\x72\x75\x6c\145\135" => "\x5f\x61\154\154\x20\x21\75\40\42\x6e\x6f\x6e\x65\x22"), array("\124\150\x65\x20\157\x70\x65\162\141\x74\x6f\x72", "\144\157\145\x73\40\156\x6f\164\40\145\x78\151\x73\x74\56"))); } public function testIgnoreOriginRuleCreationFail($data, $messages) { $this->logInAs("\x61\x64\x6d\x69\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\x47\x45\x54", "\57\143\x6f\x6e\x66\x69\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\165\164\164\x6f\156\133\x69\x64\75\151\147\156\157\x72\145\137\x6f\162\151\147\x69\156\137\165\163\x65\x72\x5f\162\x75\154\145\137\163\x61\166\145\135")->form(); $crawler = $client->submit($form, $data); $this->assertSame(200, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\x62\157\144\171")->extract(array("\x5f\x74\145\x78\x74"))); foreach ($messages as $message) { $this->assertStringContainsString($message, $body[0]); } } public function testDeletingIgnoreOriginRuleFromAnOtherUser() { $this->logInAs("\142\157\142"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(IgnoreOriginUserRule::class)->findAll()[0]; $crawler = $client->request("\107\105\124", "\x2f\x69\x67\156\x6f\x72\x65\x2d\157\x72\x69\147\151\156\x2d\x75\x73\145\x72\55\162\x75\154\x65\57\x65\144\x69\164\57" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\142\157\x64\171")->extract(array("\x5f\164\x65\170\x74"))); $this->assertStringContainsString("\131\x6f\x75\x20\x63\x61\x6e\x20\156\x6f\x74\x20\x61\143\x63\x65\x73\x73\40\164\x68\x69\x73\x20\162\165\154\x65", $body[0]); } public function testEditingIgnoreOriginRuleFromAnOtherUser() { $this->logInAs("\142\157\142"); $client = $this->getTestClient(); $rule = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(IgnoreOriginUserRule::class)->findAll()[0]; $crawler = $client->request("\107\105\x54", "\57\151\147\x6e\x6f\162\145\x2d\157\162\151\x67\151\x6e\55\165\163\x65\162\55\x72\x75\x6c\145\57\145\x64\x69\164\57" . $rule->getId()); $this->assertSame(403, $client->getResponse()->getStatusCode()); $this->assertGreaterThan(1, $body = $crawler->filter("\x62\x6f\144\x79")->extract(array("\137\164\145\x78\164"))); $this->assertStringContainsString("\x59\157\165\x20\143\x61\x6e\x20\x6e\x6f\x74\40\x61\143\143\145\163\163\x20\164\150\x69\x73\40\x72\165\x6c\x65", $body[0]); } public function testDeleteUserButtonVisibility() { $this->logInAs("\141\144\x6d\x69\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\x54", "\57\143\x6f\x6e\x66\151\147"); $this->assertGreaterThan(1, $body = $crawler->filter("\142\x6f\x64\x79")->extract(array("\137\164\x65\170\x74"))); $this->assertStringContainsString("\143\157\156\x66\151\x67\56\146\x6f\162\155\x5f\165\x73\145\x72\x2e\144\x65\x6c\145\164\x65\56\142\165\164\x74\157\x6e", $body[0]); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = $em->getRepository(User::class)->findOneByUsername("\x65\x6d\160\164\x79"); $user->setEnabled(false); $em->persist($user); $user = $em->getRepository(User::class)->findOneByUsername("\142\x6f\142"); $user->setEnabled(false); $em->persist($user); $em->flush(); $crawler = $client->request("\107\x45\124", "\x2f\143\157\x6e\x66\151\x67"); $this->assertGreaterThan(1, $body = $crawler->filter("\x62\157\x64\x79")->extract(array("\137\x74\145\x78\x74"))); $this->assertStringNotContainsString("\143\x6f\x6e\x66\151\147\x2e\146\157\x72\x6d\137\165\163\145\162\x2e\x64\x65\154\x65\164\x65\56\142\165\164\164\157\156", $body[0]); $client->request("\x50\117\x53\x54", "\x2f\x61\143\x63\x6f\x75\x6e\164\x2f\144\x65\154\x65\x74\x65"); $this->assertSame(403, $client->getResponse()->getStatusCode()); $user = $em->getRepository(User::class)->findOneByUsername("\x65\155\160\164\171"); $user->setEnabled(true); $em->persist($user); $user = $em->getRepository(User::class)->findOneByUsername("\x62\157\x62"); $user->setEnabled(true); $em->persist($user); $em->flush(); } public function testDeleteAccount() { $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = new User(); $user->setName("\127\141\154\154\x61\143\x65"); $user->setEmail("\167\141\x6c\154\x61\x63\x65\x40\167\141\x6c\x6c\141\142\x61\x67\x2e\x6f\162\147"); $user->setUsername("\167\x61\154\x6c\141\143\145"); $user->setPlainPassword("\x77\141\154\154\141\143\x65"); $user->setEnabled(true); $user->addRole("\x52\117\114\x45\137\x53\125\x50\105\122\x5f\x41\104\x4d\111\x4e"); $em->persist($user); $config = new ConfigEntity($user); $config->setItemsPerPage(30); $config->setReadingSpeed(200); $config->setLanguage("\145\156"); $config->setPocketConsumerKey("\170\170\x78\170\170"); $em->persist($config); $em->flush(); $this->logInAs("\x77\141\154\x6c\141\143\145"); $loggedInUserId = $this->getLoggedInUserId(); $crawler = $client->request("\x47\105\x54", "\x2f\x6e\145\x77"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x66\x6f\x72\155\133\x6e\x61\x6d\145\75\145\x6e\164\162\x79\x5d")->form(); $data = array("\x65\x6e\x74\x72\171\x5b\165\162\x6c\135" => $url = "\150\164\x74\x70\163\72\57\x2f\147\x69\164\x68\165\142\56\143\x6f\x6d\57\x77\x61\154\x6c\x61\142\141\x67\x2f\167\141\x6c\154\x61\x62\x61\x67"); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $crawler = $client->request("\x47\x45\x54", "\x2f\143\157\x6e\146\x69\147"); $deleteForm = $crawler->filter("\146\x6f\x72\x6d\x5b\x6e\141\x6d\145\x3d\x64\145\154\x65\164\x65\55\141\143\x63\x6f\165\x6e\164\x5d")->form(); $client->submit($deleteForm); $this->assertSame(302, $client->getResponse()->getStatusCode()); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = $em->getRepository(User::class)->createQueryBuilder("\165")->where("\165\56\x75\163\145\x72\x6e\x61\x6d\145\x20\75\40\x3a\x75\x73\145\x72\156\141\155\145")->setParameter("\x75\x73\145\x72\x6e\x61\x6d\x65", "\x77\x61\x6c\x6c\141\x63\145")->getQuery()->getOneOrNullResult(); $this->assertNull($user); $entries = $client->getContainer()->get(EntityManagerInterface::class)->getRepository(Entry::class)->findByUser($loggedInUserId); $this->assertEmpty($entries); } public function testReset() { $this->logInAs("\x65\155\x70\164\x79"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); \assert($user instanceof User); $tag = new Tag(); $tag->setLabel("\x73\x75\160\145\162"); $em->persist($tag); $entry = new Entry($user); $entry->setUrl("\150\164\164\x70\x73\x3a\x2f\x2f\x77\x77\167\56\154\x65\155\x6f\156\144\145\56\x66\162\57\145\165\x72\x6f\160\145\57\141\162\x74\151\x63\154\145\57\x32\x30\61\x36\57\x31\x30\x2f\x30\x31\57\x70\x6f\165\162\55\x6c\x65\x2d\160\163\x6f\x65\x2d\x63\150\141\161\x75\145\x2d\145\x6c\x65\143\164\x69\x6f\156\55\x73\x2d\145\163\x74\55\164\x72\x61\x6e\x73\x66\x6f\162\x6d\x65\145\55\145\x6e\x2d\x75\156\145\x2d\x61\147\157\156\x69\145\x5f\65\x30\60\66\x34\67\66\137\x33\62\61\x34\x2e\150\x74\155\154"); $entry->setContent("\131\157\x75\x68\x6f\165"); $entry->setTitle("\x59\157\x75\x68\x6f\165"); $entry->addTag($tag); $em->persist($entry); $entry2 = new Entry($user); $entry2->setUrl("\150\164\x74\160\x3a\x2f\x2f\167\167\x77\56\154\145\155\x6f\x6e\144\x65\56\144\145\57\145\165\x72\x6f\x70\145\57\141\162\164\151\x63\x6c\145\57\62\x30\x31\66\x2f\x31\60\x2f\x30\61\57\x70\x6f\x75\162\55\154\x65\x2d\160\163\x6f\x65\x2d\x63\150\x61\161\x75\145\55\145\154\145\143\x74\x69\157\156\x2d\x73\x2d\145\x73\x74\55\x74\162\x61\x6e\163\x66\x6f\x72\155\x65\x65\x2d\145\x6e\55\x75\x6e\x65\x2d\x61\147\x6f\x6e\151\145\137\x35\x30\60\x36\x34\67\x36\x5f\63\x32\x31\x34\x2e\150\164\155\154"); $entry2->setContent("\x59\157\x75\x68\157\165"); $entry2->setTitle("\x59\x6f\165\x68\157\165"); $entry2->addTag($tag); $em->persist($entry2); $annotation = new Annotation($user); $annotation->setText("\x61\156\x6e\x6f\x74\x61\164\145\144"); $annotation->setQuote("\x61\156\156\x6f\164\141\164\x65\x64"); $annotation->setRanges(array()); $annotation->setEntry($entry); $em->persist($annotation); $em->flush(); $crawler = $client->request("\107\105\x54", "\x2f\143\157\x6e\146\151\147\43\x73\x65\x74\63"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x66\157\162\155\x5b\156\141\x6d\x65\75\162\145\163\145\x74\x2d\x61\156\156\x6f\164\141\x74\151\x6f\x6e\163\135")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\146\154\x61\x73\x68\145\x73\x2e\x63\157\x6e\146\151\147\56\156\157\x74\151\x63\145\x2e\x61\156\156\157\164\x61\164\151\x6f\156\x73\x5f\162\x65\x73\x65\x74", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\156\157\x74\151\143\x65")[0]); $annotationsReset = $em->getRepository(Annotation::class)->findByEntryIdAndUserId($entry->getId(), $user->getId()); $this->assertEmpty($annotationsReset, "\101\x6e\156\x6f\164\141\x74\x69\157\x6e\x73\40\167\145\x72\x65\40\x72\145\163\145\164"); $crawler = $client->request("\107\x45\124", "\x2f\143\x6f\156\x66\x69\147\x23\163\145\x74\63"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\146\x6f\x72\155\x5b\156\141\x6d\145\x3d\x72\145\x73\145\x74\55\x74\x61\x67\163\135")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x66\154\141\x73\150\x65\163\56\143\x6f\156\146\x69\x67\56\156\157\x74\151\143\145\x2e\x74\141\x67\x73\137\x72\145\163\x65\x74", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\x6e\157\x74\x69\143\x65")[0]); $tagReset = $em->getRepository(Tag::class)->countAllTags($user->getId()); $this->assertSame(0, $tagReset, "\124\x61\x67\163\x20\167\145\x72\x65\40\x72\145\163\x65\x74"); $crawler = $client->request("\107\x45\124", "\57\143\x6f\x6e\146\x69\147\43\163\x65\x74\x33"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x66\x6f\x72\155\x5b\156\x61\x6d\x65\x3d\x72\x65\163\145\164\55\x65\x6e\164\162\x69\145\163\x5d")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\146\154\x61\x73\150\x65\x73\x2e\x63\x6f\156\146\x69\147\56\156\157\x74\x69\143\145\56\145\x6e\x74\x72\x69\x65\163\137\x72\145\163\x65\164", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\156\157\x74\151\x63\145")[0]); $entryReset = $em->getRepository(Entry::class)->countAllEntriesByUser($user->getId()); $this->assertSame(0, $entryReset, "\x45\156\x74\162\x69\145\x73\x20\167\x65\162\x65\40\x72\145\x73\145\164"); } public function testResetArchivedEntries() { $this->logInAs("\145\x6d\160\164\x79"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); \assert($user instanceof User); $tag = new Tag(); $tag->setLabel("\x73\x75\x70\x65\x72"); $em->persist($tag); $entry = new Entry($user); $entry->setUrl("\150\164\164\x70\x73\x3a\57\x2f\167\x77\x77\56\x6c\x65\x6d\157\156\144\145\x2e\x66\x72\x2f\145\165\162\157\160\x65\57\141\162\x74\x69\x63\x6c\x65\57\62\60\61\66\57\61\x30\57\60\61\x2f\x70\x6f\x75\x72\x2d\154\x65\x2d\160\163\157\x65\x2d\x63\x68\141\x71\x75\x65\55\x65\x6c\145\x63\164\151\x6f\x6e\x2d\163\55\x65\x73\164\x2d\x74\x72\141\156\x73\x66\x6f\162\155\145\x65\55\x65\x6e\x2d\x75\156\x65\55\141\x67\x6f\156\x69\145\137\65\60\x30\66\x34\67\x36\137\63\x32\61\x34\56\150\164\x6d\154"); $entry->setContent("\x59\x6f\165\x68\x6f\x75"); $entry->setTitle("\x59\x6f\x75\150\157\x75"); $entry->addTag($tag); $em->persist($entry); $annotation = new Annotation($user); $annotation->setText("\x61\x6e\x6e\x6f\x74\141\164\x65\x64"); $annotation->setQuote("\141\156\x6e\x6f\x74\141\164\145\x64"); $annotation->setRanges(array()); $annotation->setEntry($entry); $em->persist($annotation); $tagArchived = new Tag(); $tagArchived->setLabel("\163\165\160\145\x72"); $em->persist($tagArchived); $entryArchived = new Entry($user); $entryArchived->setUrl("\x68\164\x74\x70\163\72\x2f\x2f\167\x77\x77\x2e\154\x65\155\157\x6e\x64\x65\56\x66\x72\57\145\x75\x72\157\160\x65\x2f\x61\162\164\151\143\x6c\145\x2f\62\x30\61\66\57\x31\x30\x2f\60\x31\x2f\x70\157\165\x72\x2d\x6c\x65\x2d\160\x73\x6f\x65\x2d\x63\150\x61\161\x75\x65\55\145\154\x65\143\x74\151\157\x6e\x2d\163\55\145\x73\x74\55\x74\x72\x61\x6e\x73\x66\157\162\x6d\145\145\x2d\x65\x6e\55\165\x6e\x65\x2d\x61\x67\x6f\x6e\x69\x65\137\65\x30\60\66\x34\67\x36\137\63\62\x31\64\56\x68\x74\155\154"); $entryArchived->setContent("\131\x6f\x75\x68\x6f\x75"); $entryArchived->setTitle("\x59\x6f\x75\150\x6f\x75"); $entryArchived->addTag($tagArchived); $entryArchived->updateArchived(true); $em->persist($entryArchived); $annotationArchived = new Annotation($user); $annotationArchived->setText("\141\x6e\156\x6f\x74\x61\164\145\x64"); $annotationArchived->setQuote("\x61\x6e\x6e\x6f\x74\x61\x74\145\144"); $annotationArchived->setRanges(array()); $annotationArchived->setEntry($entryArchived); $em->persist($annotationArchived); $em->flush(); $crawler = $client->request("\x47\x45\124", "\x2f\143\x6f\156\146\151\x67\x23\163\145\164\63"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\146\x6f\162\x6d\x5b\156\x61\x6d\145\x3d\162\145\163\x65\x74\55\141\162\143\150\151\x76\145\x64\135")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\146\154\x61\163\x68\145\163\56\143\157\156\x66\151\x67\56\x6e\157\x74\x69\143\145\56\141\162\143\150\x69\x76\x65\144\137\x72\x65\163\x65\x74", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\x6e\157\x74\x69\143\145")[0]); $entryReset = $em->getRepository(Entry::class)->countAllEntriesByUser($user->getId()); $this->assertSame(1, $entryReset, "\105\156\164\162\x69\x65\x73\x20\x77\x65\162\x65\x20\x72\x65\x73\x65\x74"); $tagReset = $em->getRepository(Tag::class)->countAllTags($user->getId()); $this->assertSame(1, $tagReset, "\x54\141\147\x73\x20\167\145\x72\145\40\x72\145\163\x65\164"); $annotationsReset = $em->getRepository(Annotation::class)->findByEntryIdAndUserId($annotationArchived->getId(), $user->getId()); $this->assertEmpty($annotationsReset, "\x41\156\x6e\157\164\141\x74\x69\157\x6e\x73\40\x77\x65\162\x65\40\162\x65\x73\x65\164"); } public function testResetEntriesCascade() { $this->logInAs("\x65\155\160\164\171"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $user = static::$kernel->getContainer()->get(TokenStorageInterface::class)->getToken()->getUser(); \assert($user instanceof User); $tag = new Tag(); $tag->setLabel("\163\x75\x70\145\162"); $em->persist($tag); $entry = new Entry($user); $entry->setUrl("\x68\164\164\x70\x73\x3a\x2f\x2f\167\167\167\56\154\x65\x6d\157\x6e\x64\145\56\146\x72\57\145\x75\162\x6f\160\x65\x2f\x61\162\x74\151\143\x6c\x65\x2f\62\60\61\x36\x2f\x31\x30\57\60\x31\x2f\x70\157\x75\162\55\154\x65\x2d\160\163\x6f\145\55\x63\150\141\161\x75\x65\55\x65\154\x65\143\x74\x69\x6f\156\x2d\x73\x2d\x65\163\164\55\164\162\x61\156\x73\x66\x6f\x72\x6d\x65\145\x2d\145\156\x2d\165\x6e\x65\x2d\x61\147\157\x6e\x69\145\137\x35\x30\60\x36\64\x37\x36\137\63\62\x31\64\x2e\x68\164\155\154"); $entry->setContent("\x59\x6f\x75\x68\x6f\x75"); $entry->setTitle("\x59\157\x75\x68\x6f\x75"); $entry->addTag($tag); $em->persist($entry); $annotation = new Annotation($user); $annotation->setText("\141\156\156\157\164\x61\164\x65\144"); $annotation->setQuote("\141\156\156\x6f\164\141\164\145\x64"); $annotation->setRanges(array()); $annotation->setEntry($entry); $em->persist($annotation); $em->flush(); $crawler = $client->request("\x47\x45\124", "\57\143\x6f\156\146\x69\x67\43\163\145\x74\x33"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x66\x6f\x72\155\133\x6e\141\155\145\75\x72\145\x73\x65\x74\55\145\156\164\162\x69\145\163\x5d")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\146\x6c\x61\163\x68\x65\x73\56\x63\x6f\156\146\151\147\56\156\x6f\164\151\x63\x65\x2e\x65\x6e\x74\x72\151\145\x73\137\162\145\163\145\164", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\x6e\x6f\x74\151\143\145")[0]); $entryReset = $em->getRepository(Entry::class)->countAllEntriesByUser($user->getId()); $this->assertSame(0, $entryReset, "\105\x6e\x74\x72\151\x65\x73\x20\167\145\x72\x65\40\162\x65\x73\145\164"); $tagReset = $em->getRepository(Tag::class)->countAllTags($user->getId()); $this->assertSame(0, $tagReset, "\x54\x61\147\x73\x20\x77\x65\x72\145\40\x72\145\x73\145\164"); $annotationsReset = $em->getRepository(Annotation::class)->findByEntryIdAndUserId($entry->getId(), $user->getId()); $this->assertEmpty($annotationsReset, "\x41\x6e\x6e\x6f\164\141\x74\151\157\x6e\163\x20\167\x65\x72\145\x20\x72\x65\163\x65\164"); } public function testSwitchViewMode() { $this->logInAs("\x61\144\x6d\x69\x6e"); $client = $this->getTestClient(); $client->request("\107\105\x54", "\x2f\x75\156\x72\145\141\144\x2f\154\151\x73\x74"); $this->assertStringContainsString("\162\x6f\167\40\144\141\164\x61", $client->getResponse()->getContent()); $client->request("\x47\x45\x54", "\x2f\143\157\156\146\x69\x67\57\x76\151\x65\167\55\x6d\x6f\144\x65"); $crawler = $client->followRedirect(); $client->request("\x47\x45\x54", "\57\x75\x6e\x72\x65\141\x64\x2f\x6c\151\163\164"); $this->assertStringContainsString("\x63\157\x6c\154\x65\x63\164\151\x6f\156", $client->getResponse()->getContent()); $client->request("\107\x45\124", "\57\143\157\156\146\x69\x67\x2f\166\151\x65\x77\55\155\157\144\145"); } public function testChangeLocaleWithoutReferer() { $client = $this->getTestClient(); $client->request("\107\x45\124", "\57\154\x6f\x63\x61\154\x65\x2f\x64\145"); $client->followRedirect(); $this->assertSame("\x64\145", $client->getRequest()->getLocale()); $this->assertSame("\144\x65", $client->getContainer()->get(SessionInterface::class)->get("\x5f\154\157\x63\141\154\x65")); } public function testChangeLocaleWithReferer() { $client = $this->getTestClient(); $client->request("\107\105\124", "\x2f\154\157\x67\151\x6e"); $client->request("\x47\105\124", "\57\154\x6f\x63\141\x6c\145\57\144\145"); $client->followRedirect(); $this->assertSame("\x64\145", $client->getRequest()->getLocale()); $this->assertSame("\x64\145", $client->getContainer()->get(SessionInterface::class)->get("\x5f\x6c\x6f\143\x61\x6c\145")); } public function testChangeLocaleToBadLocale() { $client = $this->getTestClient(); $client->request("\107\x45\124", "\x2f\154\x6f\x67\x69\x6e"); $client->request("\x47\105\x54", "\x2f\154\157\x63\141\154\145\x2f\171\165\x79\165\x79\165\171\165"); $client->followRedirect(); $this->assertNotSame("\x79\165\x79\x75\171\x75\171\x75", $client->getRequest()->getLocale()); $this->assertNotSame("\x79\165\x79\x75\171\x75\x79\165", $client->getContainer()->get(SessionInterface::class)->get("\x5f\x6c\157\x63\141\x6c\145")); } public function testUserEnable2faEmail() { $this->logInAs("\141\x64\155\x69\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\x54", "\x2f\x63\157\156\x66\x69\147"); $form = $crawler->filter("\x66\x6f\162\155\x5b\156\x61\x6d\145\x3d\x63\x6f\x6e\x66\151\x67\x5f\157\164\x70\x5f\145\155\x61\151\x6c\135")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x66\x6c\x61\163\x68\x65\x73\x2e\143\x6f\x6e\x66\151\x67\x2e\x6e\x6f\164\151\x63\145\x2e\157\164\x70\137\145\156\141\142\x6c\145\x64", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\156\x6f\x74\x69\143\x65")[0]); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("\141\144\155\x69\x6e"); $this->assertTrue($user->isEmailTwoFactor()); $user->setEmailTwoFactor(false); $em->persist($user); $em->flush(); } public function testUserDisable2faEmail() { $this->logInAs("\x61\x64\155\151\156"); $client = $this->getTestClient(); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("\141\x64\x6d\151\156"); $user->setEmailTwoFactor(true); $em->persist($user); $em->flush(); $crawler = $client->request("\107\x45\124", "\57\143\157\x6e\x66\x69\x67"); $form = $crawler->filter("\x66\x6f\162\x6d\133\x6e\141\155\x65\x3d\x64\151\163\141\x62\x6c\145\x5f\x6f\164\x70\137\x65\155\x61\151\x6c\135")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\146\154\141\x73\150\145\163\x2e\143\157\156\x66\151\x67\56\156\157\x74\151\143\145\56\x6f\x74\x70\x5f\144\x69\x73\141\x62\154\145\144", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\156\157\164\151\143\145")[0]); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("\141\144\x6d\151\x6e"); $this->assertFalse($user->isEmailTwoFactor()); } public function testUserEnable2faGoogle() { $this->logInAs("\141\x64\x6d\151\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\124", "\57\x63\157\x6e\146\151\x67"); $form = $crawler->filter("\x66\x6f\x72\x6d\x5b\156\x61\155\x65\75\143\x6f\156\x66\151\x67\x5f\157\x74\160\x5f\141\160\x70\135")->form(); $client->submit($form); $this->assertSame(200, $client->getResponse()->getStatusCode()); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("\x61\144\x6d\x69\x6e"); $this->assertTrue($user->isGoogleTwoFactor()); $this->assertGreaterThan(0, $user->getBackupCodes()); $user->setGoogleAuthenticatorSecret(false); $user->setBackupCodes(null); $em->persist($user); $em->flush(); } public function testUserDisable2faGoogle() { $this->logInAs("\141\144\155\x69\x6e"); $client = $this->getTestClient(); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("\x61\x64\x6d\x69\x6e"); $user->setGoogleAuthenticatorSecret("\107\157\157\147\154\145\x32\106\x41"); $em->persist($user); $em->flush(); $crawler = $client->request("\107\x45\124", "\57\143\157\156\146\151\x67"); $form = $crawler->filter("\146\157\x72\155\x5b\156\x61\x6d\x65\x3d\x64\151\163\141\x62\154\145\137\157\x74\160\137\141\160\160\135")->form(); $client->submit($form); $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertStringContainsString("\x66\x6c\x61\x73\150\145\163\x2e\143\x6f\156\146\151\147\x2e\x6e\x6f\164\x69\x63\x65\x2e\x6f\x74\160\137\144\151\x73\x61\142\154\145\x64", $client->getContainer()->get(SessionInterface::class)->getFlashBag()->get("\x6e\157\164\x69\x63\145")[0]); $em = $this->getEntityManager(); $user = $em->getRepository(User::class)->findOneByUsername("\x61\x64\155\x69\156"); $this->assertEmpty($user->getGoogleAuthenticatorSecret()); $this->assertEmpty($user->getBackupCodes()); } public function testExportTaggingRule() { $this->logInAs("\141\144\x6d\151\156"); $client = $this->getTestClient(); ob_start(); $crawler = $client->request("\107\x45\x54", "\x2f\164\x61\x67\x67\151\156\147\55\162\x75\x6c\x65\x2f\x65\x78\x70\157\x72\x74"); ob_end_clean(); $this->assertSame(200, $client->getResponse()->getStatusCode()); $headers = $client->getResponse()->headers; $this->assertSame("\141\x70\x70\154\x69\143\x61\164\151\x6f\x6e\x2f\152\163\x6f\156", $headers->get("\x63\x6f\x6e\x74\x65\x6e\x74\x2d\164\x79\x70\x65")); $this->assertSame("\141\x74\x74\x61\x63\x68\155\145\x6e\x74\x3b\40\146\x69\154\x65\x6e\141\x6d\145\x3d\x22\x74\x61\x67\x67\x69\156\147\137\x72\165\154\145\163\x5f\141\144\x6d\x69\156\x2e\152\163\x6f\156\42", $headers->get("\143\157\x6e\164\x65\156\x74\55\x64\x69\x73\x70\x6f\163\151\x74\151\157\156")); $this->assertSame("\x55\124\x46\x2d\x38", $headers->get("\x63\157\x6e\x74\145\156\164\55\164\162\x61\156\x73\146\x65\162\x2d\x65\x6e\143\157\144\x69\x6e\147")); $content = json_decode($client->getResponse()->getContent(), true); $this->assertCount(4, $content); $this->assertSame("\143\x6f\156\x74\145\x6e\164\x20\155\x61\164\143\x68\x65\x73\x20\x22\163\x70\x75\162\x73\x22", $content[0]["\162\x75\154\x65"]); $this->assertSame("\163\x70\x6f\x72\164", $content[0]["\164\141\147\163"][0]); } public function testImportTagginfRuleBadFile() { $this->logInAs("\x61\144\155\151\x6e"); $client = $this->getTestClient(); $crawler = $client->request("\x47\105\x54", "\x2f\143\x6f\x6e\x66\x69\147"); $form = $crawler->filter("\146\x6f\x72\155\133\156\x61\x6d\145\x3d\165\x70\x6c\157\x61\x64\x5f\164\141\147\x67\151\x6e\147\137\x72\x75\x6c\145\x5f\146\151\154\145\x5d\x20\x3e\40\142\165\164\x74\157\156\x5b\x74\x79\x70\x65\x3d\x73\165\x62\x6d\151\x74\135")->form(); $data = array("\x75\x70\154\157\141\x64\137\x74\141\147\x67\151\156\147\x5f\x72\x75\x6c\x65\137\x66\x69\x6c\x65\133\146\x69\x6c\145\x5d" => ''); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); } public function testImportTagginfRuleFile() { $this->logInAs("\x61\144\155\151\156"); $client = $this->getTestClient(); $crawler = $client->request("\107\105\124", "\57\143\157\x6e\146\151\x67"); $form = $crawler->filter("\x66\157\x72\155\133\156\x61\155\x65\75\165\160\x6c\x6f\x61\x64\137\164\x61\x67\x67\x69\x6e\x67\137\x72\165\x6c\x65\x5f\146\x69\x6c\x65\x5d\x20\x3e\40\x62\x75\164\x74\x6f\156\133\164\x79\160\145\75\x73\x75\x62\155\151\x74\x5d")->form(); $file = new UploadedFile(__DIR__ . "\x2f\56\56\x2f\146\x69\x78\x74\165\162\x65\x73\57\164\x61\x67\x67\x69\x6e\x67\x5f\162\x75\154\x65\163\x5f\x61\144\x6d\x69\x6e\x2e\152\x73\x6f\156", "\164\141\147\x67\151\156\147\137\x72\x75\154\x65\x73\137\141\144\155\151\156\x2e\152\x73\x6f\x6e"); $data = array("\x75\160\154\x6f\x61\x64\137\x74\x61\x67\x67\151\x6e\x67\137\x72\165\x6c\x65\x5f\146\151\x6c\145\x5b\x66\151\154\145\135" => $file); $client->submit($form, $data); $this->assertSame(302, $client->getResponse()->getStatusCode()); $user = static::getContainer()->get("\146\x6f\163\137\165\x73\x65\162\x2e\165\163\145\x72\137\155\141\156\141\147\145\162")->findUserBy(array("\165\x73\145\x72\x6e\x61\x6d\145" => "\x61\144\155\151\156")); \assert($user instanceof User); $taggingRules = $user->getConfig()->getTaggingRules()->toArray(); $this->assertCount(5, $taggingRules); $this->assertSame("\x74\151\164\154\145\x20\155\x61\x74\143\150\145\163\x20\42\x66\x6f\x6f\x74\x62\141\x6c\154\x22", $taggingRules[4]->getRule()); } public function testSwitchDisplayThumbnails() { $this->logInAs("\x61\x64\x6d\x69\156"); $client = $this->getTestClient(); $crawler = $client->request("\x47\105\x54", "\57\143\x6f\x6e\146\151\x67"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\x75\164\164\157\x6e\133\151\144\x3d\x63\x6f\x6e\x66\x69\147\x5f\163\141\166\x65\135")->form(); $data = array("\x63\157\x6e\x66\151\x67\x5b\144\151\163\160\x6c\x61\171\137\x74\x68\165\x6d\142\156\x61\151\154\163\135" => true); $client->submit($form, $data); $client->followRedirect(); $client->request("\107\105\x54", "\57\x75\156\162\x65\x61\x64\x2f\154\x69\163\x74"); $this->assertStringContainsString("\x63\x6c\141\x73\x73\x3d\x22\160\x72\x65\x76\151\x65\167\42", $client->getResponse()->getContent()); $crawler = $client->request("\107\x45\124", "\57\x63\x6f\156\x66\x69\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\142\x75\x74\164\157\156\x5b\151\144\x3d\143\157\156\x66\x69\x67\137\163\x61\166\x65\135")->form(); $data = array("\x63\x6f\156\x66\151\147\x5b\144\151\x73\x70\154\x61\171\x5f\x74\150\165\x6d\x62\156\141\151\154\163\135" => false); $client->submit($form, $data); $client->followRedirect(); $client->request("\107\x45\x54", "\57\x75\x6e\x72\x65\141\144\x2f\154\151\163\164"); $this->assertStringNotContainsString("\x63\x6c\x61\163\x73\75\42\160\x72\x65\166\151\x65\x77\x22", $client->getResponse()->getContent()); $client->request("\107\105\124", "\x2f\x63\157\156\146\151\147\57\x76\151\145\167\x2d\155\157\144\x65"); } public function testGeneratedCSS() { $this->logInAs("\x61\144\x6d\151\x6e"); $client = $this->getTestClient(); $em = $client->getContainer()->get(EntityManagerInterface::class); $entry = $em->getRepository(Entry::class)->findByUrlAndUserId("\150\x74\164\160\x3a\x2f\x2f\x30\x2e\x30\56\60\x2e\60\x2f\145\156\164\x72\171\61", $this->getLoggedInUserId()); $client->request("\107\x45\x54", "\x2f\166\151\x65\x77\57" . $entry->getId()); $this->assertStringNotContainsString("\146\x6f\x6e\x74\55\x66\x61\x6d\x69\x6c\x79\x3a\x20\x22\117\x70\x65\x6e\x44\x79\163\154\145\x78\x69\x63\122\145\x67\x75\x6c\141\x72\42", $client->getResponse()->getContent()); $this->assertStringNotContainsString("\155\141\170\55\167\151\144\164\150\x3a\40\66\x30\145\155", $client->getResponse()->getContent()); $this->assertStringNotContainsString("\x6c\151\x6e\145\55\150\x65\x69\147\x68\x74\x3a\x20\x32\x65\x6d", $client->getResponse()->getContent()); $this->assertStringNotContainsString("\x66\157\156\164\55\163\151\172\x65\x3a\x20\62\x65\155", $client->getResponse()->getContent()); $crawler = $client->request("\x47\105\124", "\x2f\143\157\x6e\146\151\147"); $this->assertSame(200, $client->getResponse()->getStatusCode()); $form = $crawler->filter("\x62\x75\x74\164\157\x6e\133\x69\144\x3d\x63\157\156\146\x69\147\x5f\163\141\166\x65\135")->form(); $data = array("\x63\x6f\156\146\151\x67\x5b\x66\157\x6e\164\135" => "\x4f\160\145\x6e\104\171\x73\154\145\170\151\x63\122\x65\147\165\x6c\x61\162", "\143\x6f\x6e\x66\151\147\133\x66\x6f\156\164\163\151\172\x65\x5d" => 2.0, "\x63\157\156\x66\x69\147\133\154\x69\x6e\145\x48\x65\x69\147\x68\164\x5d" => 2.0, "\143\x6f\x6e\146\x69\147\133\155\141\x78\127\x69\x64\x74\150\135" => 60); $client->submit($form, $data); $client->followRedirect(); $client->request("\x47\105\124", "\57\166\151\x65\167\57" . $entry->getId()); $this->assertStringContainsString("\146\x6f\156\x74\x2d\146\x61\x6d\x69\154\x79\x3a\x20\x22\117\160\x65\156\x44\171\x73\x6c\x65\170\151\x63\x52\x65\147\x75\154\x61\162\x22", $client->getResponse()->getContent()); $this->assertStringContainsString("\x6d\141\x78\55\x77\151\x64\x74\x68\x3a\x20\66\x30\x65\x6d", $client->getResponse()->getContent()); $this->assertStringContainsString("\x6c\x69\156\145\x2d\x68\145\x69\147\x68\164\x3a\40\62\145\x6d", $client->getResponse()->getContent()); $this->assertStringContainsString("\x66\x6f\x6e\164\55\x73\151\x7a\145\72\40\x32\145\x6d", $client->getResponse()->getContent()); } }
Function Calls
None |
Stats
MD5 | f844da57d96c30bd3998c1bd9a000549 |
Eval Count | 0 |
Decode Time | 158 ms |