From: Jérémy Benoist Date: Tue, 20 Jun 2017 14:40:48 +0000 (+0200) Subject: Merge pull request #2683 from wallabag/credentials-in-db X-Git-Tag: 2.3.0~31^2~52 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=80784b782becfaa297e6d9cbb0584e27739cffc8;hp=-c;p=github%2Fwallabag%2Fwallabag.git Merge pull request #2683 from wallabag/credentials-in-db Store credentials in DB --- 80784b782becfaa297e6d9cbb0584e27739cffc8 diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 02dd04f2,3a3fb91d..a91a0ce4 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@@ -32,6 -32,7 +32,7 @@@ menu # save_link: 'Save a link' back_to_unread: 'Tilbage til de ulæste artikler' # users_management: 'Users management' + # site_credentials: 'Site credentials' top: add_new_entry: 'Tilføj ny artikel' search: 'Søg' @@@ -186,8 -187,6 +187,8 @@@ entry unread_label: 'Ulæst' preview_picture_label: 'Har et vist billede' preview_picture_help: 'ForhÃ¥ndsvis billede' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Sprog' # http_status_label: 'HTTP status' reading_time: @@@ -520,6 -519,26 +521,26 @@@ user search: # placeholder: Filter by username or email + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new credential + # form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + error: # page_title: An error occurred @@@ -572,3 -591,8 +593,8 @@@ flashes # added: 'User "%username%" added' # updated: 'User "%username%" updated' # deleted: 'User "%username%" deleted' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index f6ccdae0,85f0e1a3..e77cdca3 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Link speichern' back_to_unread: 'Zurück zu ungelesenen Artikeln' users_management: 'Benutzerverwaltung' + # site_credentials: 'Site credentials' top: add_new_entry: 'Neuen Artikel hinzufügen' search: 'Suche' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Ungelesene' preview_picture_label: 'Vorschaubild vorhanden' preview_picture_help: 'Vorschaubild' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Sprache' http_status_label: 'HTTP-Status' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: placeholder: Filtere nach Benutzer oder E-Mail-Adresse + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + list: + actions: Aktionen + edit_action: Bearbeiten + yes: Ja + no: Nein + # create_new_one: Create a new credential + form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + save: Speichern + delete: Löschen + delete_confirm: Bist du sicher? + back_to_list: Zurück zur Liste + error: page_title: Ein Fehler ist aufgetreten @@@ -573,3 -592,8 +594,8 @@@ flashes added: 'Benutzer "%username%" hinzugefügt' updated: 'Benutzer "%username%" aktualisiert' deleted: 'Benutzer "%username%" gelöscht' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 902c3046,284fa2fb..50edab3a --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Save a link' back_to_unread: 'Back to unread articles' users_management: 'Users management' + site_credentials: 'Site credentials' top: add_new_entry: 'Add a new entry' search: 'Search' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Unread' preview_picture_label: 'Has a preview picture' preview_picture_help: 'Preview picture' + is_public_label: 'Has a public link' + is_public_help: 'Public link' language_label: 'Language' http_status_label: 'HTTP status' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: placeholder: Filter by username or email + site_credential: + page_title: Site credentials management + new_site_credential: Create a credential + edit_site_credential: Edit an existing credential + description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + list: + actions: Actions + edit_action: Edit + yes: Yes + no: No + create_new_one: Create a new credential + form: + username_label: 'Username' + host_label: 'Host' + password_label: 'Password' + save: Save + delete: Delete + delete_confirm: Are you sure? + back_to_list: Back to list + error: page_title: An error occurred @@@ -573,3 -592,8 +594,8 @@@ flashes added: 'User "%username%" added' updated: 'User "%username%" updated' deleted: 'User "%username%" deleted' + site_credential: + notice: + added: 'Site credential for "%host%" added' + updated: 'Site credential for "%host%" updated' + deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index afd6a7b1,33bb879c..6fbf00eb --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Guardar un enlace' back_to_unread: 'Volver a los artículos sin leer' users_management: 'Configuración de usuarios' + # site_credentials: 'Site credentials' top: add_new_entry: 'Añadir un nuevo artículo' search: 'Buscar' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Sin leer' preview_picture_label: 'Tiene imagen de previsualización' preview_picture_help: 'Imagen de previsualización' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Idioma' http_status_label: 'Código de estado HTTP' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: # placeholder: Filter by username or email + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new credential + # form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + error: page_title: Ha ocurrido un error @@@ -573,3 -592,8 +594,8 @@@ flashes added: 'Añadido el usuario "%username%"' updated: 'Actualizado el usuario "%username%"' deleted: 'Eliminado el usuario "%username%"' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 545514b3,90eb119c..ad7d6cd9 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'ذخیرهٔ یک پیوند' back_to_unread: 'بازگشت به خوانده‌نشده‌ها' # users_management: 'Users management' + # site_credentials: 'Site credentials' top: add_new_entry: 'افزودن مقالهٔ تازه' search: 'جستجو' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'خوانده‌نشده' preview_picture_label: 'دارای عکس پیش‌نمایش' preview_picture_help: 'پیش‌نمایش عکس' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'زبان' # http_status_label: 'HTTP status' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: # placeholder: Filter by username or email + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new credential + # form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + error: # page_title: An error occurred @@@ -573,3 -592,8 +594,8 @@@ flashes # added: 'User "%username%" added' # updated: 'User "%username%" updated' # deleted: 'User "%username%" deleted' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index e9e79c67,cd239b5c..c4b029c3 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: "Sauvegarder un nouvel article" back_to_unread: "Retour aux articles non lus" users_management: "Gestion des utilisateurs" + site_credentials: 'Accès aux sites' top: add_new_entry: "Sauvegarder un nouvel article" search: "Rechercher" @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: "Non lus" preview_picture_label: "A une photo" preview_picture_help: "Photo" + is_public_label: 'A un lien public' + is_public_help: 'Lien public' language_label: "Langue" http_status_label: "Statut HTTP" reading_time: @@@ -516,11 -515,31 +517,31 @@@ user twofactor_label: "Double authentification" save: "Sauvegarder" delete: "Supprimer" - delete_confirm: "Voulez-vous vraiment ?" + delete_confirm: "Êtes-vous sûr ?" back_to_list: "Revenir à la liste" search: placeholder: "Filtrer par nom d’utilisateur ou email" + site_credential: + page_title: Gestion des accès aux sites + new_site_credential: Créer un accès à un site + edit_site_credential: Éditer l'accès d'un site + description: "Ici vous pouvez gérer les accès aux différents sites. Ces accès permettent de récupérer des contenus sur des sites qui requièrent une authentification ou un paywall" + list: + actions: Actions + edit_action: Éditer + yes: Oui + no: Non + create_new_one: Créer un nouvel accès à un site + form: + username_label: 'Identifiant' + host_label: 'Domaine' + password_label: 'Mot de passe' + save: "Sauvegarder" + delete: "Supprimer" + delete_confirm: "Êtes-vous sûr ?" + back_to_list: "Revenir à la liste" + error: page_title: "Une erreur est survenue" @@@ -570,6 -589,11 +591,11 @@@ flashes client_deleted: "Client %name% supprimé" user: notice: - added: "Utilisateur \"%username%\" ajouté" - updated: "Utilisateur \"%username%\" mis à jour" - deleted: "Utilisateur \"%username%\" supprimé" + added: 'Utilisateur "%username%" ajouté' + updated: 'Utilisateur "%username%" mis à jour' + deleted: 'Utilisateur "%username%" supprimé' + site_credential: + notice: + added: 'Accès au site "%host%" ajouté' + updated: 'Accès au site "%host%" mis à jour' + deleted: 'Accès au site "%host%" supprimé' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 0597d3e3,5cb2a68f..4bd04aad --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Salva collegamento' back_to_unread: 'Torna ai contenuti non letti' # users_management: 'Users management' + # site_credentials: 'Site credentials' top: add_new_entry: 'Aggiungi un nuovo contenuto' search: 'Cerca' @@@ -187,8 -188,6 +188,8 @@@ entry # unread_label: 'Unread' preview_picture_label: "Ha un'immagine di anteprima" preview_picture_help: 'Immagine di anteprima' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Lingua' # http_status_label: 'HTTP status' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: # placeholder: Filter by username or email + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new credential + # form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + error: # page_title: An error occurred @@@ -573,3 -592,8 +594,8 @@@ flashes # added: 'User "%username%" added' # updated: 'User "%username%" updated' # deleted: 'User "%username%" deleted' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index c172a0f6,bc11b2a4..a6dd4dcd --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Enregistrar un novèl article' back_to_unread: 'Tornar als articles pas legits' users_management: 'Gestion dels utilizaires' + # site_credentials: 'Site credentials' top: add_new_entry: 'Enregistrar un novèl article' search: 'Cercar' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Pas legits' preview_picture_label: 'A un imatge' preview_picture_help: 'Imatge' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Lenga' http_status_label: 'Estatut HTTP' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: placeholder: "Filtrar per nom d'utilizaire o corrièl" + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + list: + actions: 'Accions' + edit_action: 'Modificar' + yes: 'Òc' + no: 'Non' + # create_new_one: Create a new credential + form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + save: 'Enregistrar' + delete: 'Suprimir' + delete_confirm: 'Sètz segur ?' + back_to_list: 'Tornar a la lista' + error: page_title: Una error s'es produsida @@@ -573,3 -592,8 +594,8 @@@ flashes added: 'Utilizaire "%username%" ajustat' updated: 'Utilizaire "%username%" mes a jorn' deleted: 'Utilizaire "%username%" suprimit' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 82d16767,033d6ac5..7312abd7 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Zapisz link' back_to_unread: 'Powrót do nieprzeczytanych artykułów' users_management: 'Zarządzanie użytkownikami' + # site_credentials: 'Site credentials' top: add_new_entry: 'Dodaj nowy wpis' search: 'Szukaj' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Nieprzeczytane' preview_picture_label: 'Posiada podgląd obrazu' preview_picture_help: 'Podgląd obrazu' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Język' http_status_label: 'Status HTTP' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: placeholder: Filtruj po nazwie użytkownika lub adresie e-mail + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + list: + actions: Akcje + edit_action: Edytuj + yes: Tak + no: Nie + # create_new_one: Create a new credential + form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + save: Zapisz + delete: Usuń + delete_confirm: Jesteś pewien? + back_to_list: Powrót do listy + error: page_title: Wystąpił błąd @@@ -573,3 -592,8 +594,8 @@@ flashes added: 'Użytkownik "%username%" dodany' updated: 'Użytkownik "%username%" zaktualizowany' deleted: 'Użytkownik "%username%" usunięty' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index b75567d6,c70c2496..18090352 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@@ -32,6 -32,7 +32,7 @@@ menu save_link: 'Salvar um link' back_to_unread: 'Voltar para os artigos não lidos' users_management: 'Gestão de Usuários' + # site_credentials: 'Site credentials' top: add_new_entry: 'Adicionar uma nova entrada' search: 'Pesquisa' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Não Lido' preview_picture_label: 'Possui uma imagem de preview' preview_picture_help: 'Imagem de preview' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Idioma' # http_status_label: 'HTTP status' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: # placeholder: Filter by username or email + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + list: + actions: 'Ações' + edit_action: 'Editar' + yes: 'Sim' + no: 'Não' + # create_new_one: Create a new credential + form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + save: 'Salvar' + delete: 'Apagar' + delete_confirm: 'Tem certeza?' + back_to_list: 'Voltar para a lista' + error: # page_title: An error occurred @@@ -573,3 -592,8 +594,8 @@@ flashes added: 'Usuário "%username%" adicionado' updated: 'Usuário "%username%" atualizado' deleted: 'Usuário "%username%" removido' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 95df573d,a5dc44f0..f8866fdc --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@@ -32,6 -32,7 +32,7 @@@ menu # save_link: 'Save a link' back_to_unread: 'Înapoi la articolele necitite' # users_management: 'Users management' + # site_credentials: 'Site credentials' top: add_new_entry: 'Introdu un nou articol' search: 'Căutare' @@@ -187,8 -188,6 +188,8 @@@ entry unread_label: 'Necitite' preview_picture_label: 'Are o imagine de previzualizare' preview_picture_help: 'Previzualizare imagine' + # is_public_label: 'Has a public link' + # is_public_help: 'Public link' language_label: 'Limbă' # http_status_label: 'HTTP status' reading_time: @@@ -521,6 -520,26 +522,26 @@@ user search: # placeholder: Filter by username or email + site_credential: + # page_title: Site credentials management + # new_site_credential: Create a credential + # edit_site_credential: Edit an existing credential + # description: "Here you can manage all credentials for sites which required them (create, edit and delete), like a paywall, an authentication, etc." + # list: + # actions: Actions + # edit_action: Edit + # yes: Yes + # no: No + # create_new_one: Create a new credential + # form: + # username_label: 'Username' + # host_label: 'Host' + # password_label: 'Password' + # save: Save + # delete: Delete + # delete_confirm: Are you sure? + # back_to_list: Back to list + error: # page_title: An error occurred @@@ -573,3 -592,8 +594,8 @@@ flashes # added: 'User "%username%" added' # updated: 'User "%username%" updated' # deleted: 'User "%username%" deleted' + site_credential: + notice: + # added: 'Site credential for "%host%" added' + # updated: 'Site credential for "%host%" updated' + # deleted: 'Site credential for "%host%" deleted' diff --combined tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 853f37f2,f17dc97b..7cf28bfe --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@@ -5,6 -5,7 +5,7 @@@ namespace Tests\Wallabag\CoreBundle\Con use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\Entry; + use Wallabag\CoreBundle\Entity\SiteCredential; class EntryControllerTest extends WallabagCoreTestCase { @@@ -860,20 -861,6 +861,20 @@@ $this->assertCount(1, $crawler->filter('div[class=entry]')); } + public function testFilterOnIsPublic() + { + $this->logInAs('admin'); + $this->useTheme('baggy'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/unread/list'); + $form = $crawler->filter('button[id=submit-filter]')->form(); + $form['entry_filter[isPublic]']->tick(); + + $crawler = $client->submit($form); + $this->assertCount(0, $crawler->filter('div[class=entry]')); + } + public function testPreviewPictureFilter() { $this->logInAs('admin'); @@@ -1335,4 -1322,56 +1336,56 @@@ $this->assertEquals($url, $content->getUrl()); $this->assertEquals($expectedLanguage, $content->getLanguage()); } + + /** + * This test will require an internet connection. + */ + public function testRestrictedArticle() + { + $url = 'http://www.monde-diplomatique.fr/2017/05/BONNET/57475'; + $this->logInAs('admin'); + $client = $this->getClient(); + $em = $client->getContainer()->get('doctrine.orm.entity_manager'); + + // enable restricted access + $client->getContainer()->get('craue_config')->set('restricted_access', 1); + + // create a new site_credential + $user = $client->getContainer()->get('security.token_storage')->getToken()->getUser(); + $credential = new SiteCredential($user); + $credential->setHost('monde-diplomatique.fr'); + $credential->setUsername($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('foo')); + $credential->setPassword($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); + + $em->persist($credential); + $em->flush(); + + $crawler = $client->request('GET', '/new'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('form[name=entry]')->form(); + + $data = [ + 'entry[url]' => $url, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + $this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]); + + $content = $em + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId($url, $this->getLoggedInUserId()); + + $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); + $this->assertSame('Crimes et réformes aux Philippines', $content->getTitle()); + + $client->getContainer()->get('craue_config')->set('restricted_access', 0); + } }