mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-05 19:31:02 +00:00
Remove voter & add tests
This commit is contained in:
parent
7e7674a4a6
commit
5629330cb6
29 changed files with 269 additions and 154 deletions
|
@ -301,7 +301,7 @@ services:
|
||||||
|
|
||||||
Wallabag\Import\ReadabilityImport:
|
Wallabag\Import\ReadabilityImport:
|
||||||
calls:
|
calls:
|
||||||
- [ setEnabled, [ '@=service(''craue_config'').get(''readibility_enabled'')' ] ]
|
- [ setEnabled, [ '@=service(''craue_config'').get(''readability_enabled'')' ] ]
|
||||||
tags:
|
tags:
|
||||||
- { name: wallabag.import, alias: readability }
|
- { name: wallabag.import, alias: readability }
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ parameters:
|
||||||
value: 1
|
value: 1
|
||||||
section: import
|
section: import
|
||||||
-
|
-
|
||||||
name: readibility_enabled
|
name: readability_enabled
|
||||||
value: 1
|
value: 1
|
||||||
section: import
|
section: import
|
||||||
-
|
-
|
||||||
|
@ -178,10 +178,6 @@ parameters:
|
||||||
name: pocket_html_enabled
|
name: pocket_html_enabled
|
||||||
value: 1
|
value: 1
|
||||||
section: import
|
section: import
|
||||||
-
|
|
||||||
name: pocket_csv_enabled
|
|
||||||
value: 1
|
|
||||||
section: import
|
|
||||||
-
|
-
|
||||||
name: matomo_enabled
|
name: matomo_enabled
|
||||||
value: 0
|
value: 0
|
||||||
|
|
|
@ -79,7 +79,7 @@ final class Version20250526113708 extends WallabagMigration
|
||||||
'section' => 'import',
|
'section' => 'import',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => 'pocket_csv_enabled',
|
'name' => 'elcurator_enabled',
|
||||||
'value' => '1',
|
'value' => '1',
|
||||||
'section' => 'import',
|
'section' => 'import',
|
||||||
],
|
],
|
||||||
|
|
|
@ -20,15 +20,15 @@ abstract class BrowserController extends AbstractController
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
public function indexAction(Request $request, TranslatorInterface $translator)
|
public function indexAction(Request $request, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$wallabag = $this->getImportService();
|
$import = $this->getImportService();
|
||||||
if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
|
if (!$import->isEnabled()) {
|
||||||
throw $this->createAccessDeniedException('You can not access this importer.');
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
$wallabag->setUser($this->getUser());
|
$import->setUser($this->getUser());
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$file = $form->get('file')->getData();
|
$file = $form->get('file')->getData();
|
||||||
|
@ -36,7 +36,7 @@ abstract class BrowserController extends AbstractController
|
||||||
$name = $this->getUser()->getId() . '.json';
|
$name = $this->getUser()->getId() . '.json';
|
||||||
|
|
||||||
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
||||||
$res = $wallabag
|
$res = $import
|
||||||
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
||||||
->setMarkAsRead($markAsRead)
|
->setMarkAsRead($markAsRead)
|
||||||
->import();
|
->import();
|
||||||
|
@ -44,7 +44,7 @@ abstract class BrowserController extends AbstractController
|
||||||
$message = 'flashes.import.notice.failed';
|
$message = 'flashes.import.notice.failed';
|
||||||
|
|
||||||
if (true === $res) {
|
if (true === $res) {
|
||||||
$summary = $wallabag->getSummary();
|
$summary = $import->getSummary();
|
||||||
$message = $translator->trans('flashes.import.notice.summary', [
|
$message = $translator->trans('flashes.import.notice.summary', [
|
||||||
'%imported%' => $summary['imported'],
|
'%imported%' => $summary['imported'],
|
||||||
'%skipped%' => $summary['skipped'],
|
'%skipped%' => $summary['skipped'],
|
||||||
|
@ -68,7 +68,7 @@ abstract class BrowserController extends AbstractController
|
||||||
|
|
||||||
return $this->render($this->getImportTemplate(), [
|
return $this->render($this->getImportTemplate(), [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'import' => $wallabag,
|
'import' => $import,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ class DeliciousController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/delicious', name: 'import_delicious', methods: ['GET', 'POST'])]
|
#[Route(path: '/import/delicious', name: 'import_delicious', methods: ['GET', 'POST'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'delicious')]
|
|
||||||
public function indexAction(Request $request, DeliciousImport $delicious, Config $craueConfig, TranslatorInterface $translator)
|
public function indexAction(Request $request, DeliciousImport $delicious, Config $craueConfig, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
if (!$delicious->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,15 @@ abstract class HtmlController extends AbstractController
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
public function indexAction(Request $request, TranslatorInterface $translator)
|
public function indexAction(Request $request, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$wallabag = $this->getImportService();
|
$import = $this->getImportService();
|
||||||
if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
|
if (!$import->isEnabled()) {
|
||||||
throw $this->createAccessDeniedException('You can not access this importer.');
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
$wallabag->setUser($this->getUser());
|
$import->setUser($this->getUser());
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$file = $form->get('file')->getData();
|
$file = $form->get('file')->getData();
|
||||||
|
@ -36,7 +36,7 @@ abstract class HtmlController extends AbstractController
|
||||||
$name = $this->getUser()->getId() . '.html';
|
$name = $this->getUser()->getId() . '.html';
|
||||||
|
|
||||||
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
||||||
$res = $wallabag
|
$res = $import
|
||||||
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
||||||
->setMarkAsRead($markAsRead)
|
->setMarkAsRead($markAsRead)
|
||||||
->import();
|
->import();
|
||||||
|
@ -44,7 +44,7 @@ abstract class HtmlController extends AbstractController
|
||||||
$message = 'flashes.import.notice.failed';
|
$message = 'flashes.import.notice.failed';
|
||||||
|
|
||||||
if (true === $res) {
|
if (true === $res) {
|
||||||
$summary = $wallabag->getSummary();
|
$summary = $import->getSummary();
|
||||||
$message = $translator->trans('flashes.import.notice.summary', [
|
$message = $translator->trans('flashes.import.notice.summary', [
|
||||||
'%imported%' => $summary['imported'],
|
'%imported%' => $summary['imported'],
|
||||||
'%skipped%' => $summary['skipped'],
|
'%skipped%' => $summary['skipped'],
|
||||||
|
@ -68,7 +68,7 @@ abstract class HtmlController extends AbstractController
|
||||||
|
|
||||||
return $this->render($this->getImportTemplate(), [
|
return $this->render($this->getImportTemplate(), [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'import' => $wallabag,
|
'import' => $import,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ class InstapaperController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/instapaper', name: 'import_instapaper', methods: ['GET', 'POST'])]
|
#[Route(path: '/import/instapaper', name: 'import_instapaper', methods: ['GET', 'POST'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'instapaper')]
|
|
||||||
public function indexAction(Request $request, InstapaperImport $instapaper, Config $craueConfig, TranslatorInterface $translator)
|
public function indexAction(Request $request, InstapaperImport $instapaper, Config $craueConfig, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
if (!$instapaper->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ class OmnivoreController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/omnivore', name: 'import_omnivore', methods: ['GET', 'POST'])]
|
#[Route(path: '/import/omnivore', name: 'import_omnivore', methods: ['GET', 'POST'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'omnivore')]
|
|
||||||
public function indexAction(Request $request, OmnivoreImport $omnivore, Config $craueConfig, TranslatorInterface $translator)
|
public function indexAction(Request $request, OmnivoreImport $omnivore, Config $craueConfig, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
if (!$omnivore->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ class PinboardController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/pinboard', name: 'import_pinboard', methods: ['GET', 'POST'])]
|
#[Route(path: '/import/pinboard', name: 'import_pinboard', methods: ['GET', 'POST'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'pinboard')]
|
|
||||||
public function indexAction(Request $request, PinboardImport $pinboard, Config $craueConfig, TranslatorInterface $translator)
|
public function indexAction(Request $request, PinboardImport $pinboard, Config $craueConfig, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
if (!$pinboard->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
|
|
@ -27,9 +27,12 @@ class PocketController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/pocket', name: 'import_pocket', methods: ['GET'])]
|
#[Route(path: '/import/pocket', name: 'import_pocket', methods: ['GET'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'pocketImport')]
|
|
||||||
public function indexAction(PocketImport $pocketImport)
|
public function indexAction(PocketImport $pocketImport)
|
||||||
{
|
{
|
||||||
|
if (!$pocketImport->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$pocket = $this->getPocketImportService($pocketImport);
|
$pocket = $this->getPocketImportService($pocketImport);
|
||||||
|
|
||||||
$form = $this->createFormBuilder($pocket)
|
$form = $this->createFormBuilder($pocket)
|
||||||
|
@ -48,9 +51,12 @@ class PocketController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/pocket/auth', name: 'import_pocket_auth', methods: ['POST'])]
|
#[Route(path: '/import/pocket/auth', name: 'import_pocket_auth', methods: ['POST'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'pocketImport')]
|
|
||||||
public function authAction(Request $request, PocketImport $pocketImport)
|
public function authAction(Request $request, PocketImport $pocketImport)
|
||||||
{
|
{
|
||||||
|
if (!$pocketImport->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$requestToken = $this->getPocketImportService($pocketImport)
|
$requestToken = $this->getPocketImportService($pocketImport)
|
||||||
->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL));
|
->getRequestToken($this->generateUrl('import', [], UrlGeneratorInterface::ABSOLUTE_URL));
|
||||||
|
|
||||||
|
@ -78,9 +84,12 @@ class PocketController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/pocket/callback', name: 'import_pocket_callback', methods: ['GET'])]
|
#[Route(path: '/import/pocket/callback', name: 'import_pocket_callback', methods: ['GET'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'pocketImport')]
|
|
||||||
public function callbackAction(PocketImport $pocketImport, TranslatorInterface $translator)
|
public function callbackAction(PocketImport $pocketImport, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
if (!$pocketImport->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$message = 'flashes.import.notice.failed';
|
$message = 'flashes.import.notice.failed';
|
||||||
$pocket = $this->getPocketImportService($pocketImport);
|
$pocket = $this->getPocketImportService($pocketImport);
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,12 @@ class ReadabilityController extends AbstractController
|
||||||
|
|
||||||
#[Route(path: '/import/readability', name: 'import_readability', methods: ['GET', 'POST'])]
|
#[Route(path: '/import/readability', name: 'import_readability', methods: ['GET', 'POST'])]
|
||||||
#[IsGranted('IMPORT_ENTRIES')]
|
#[IsGranted('IMPORT_ENTRIES')]
|
||||||
#[IsGranted('USE_IMPORTER', subject: 'readability')]
|
|
||||||
public function indexAction(Request $request, ReadabilityImport $readability, Config $craueConfig, TranslatorInterface $translator)
|
public function indexAction(Request $request, ReadabilityImport $readability, Config $craueConfig, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
|
if (!$readability->isEnabled()) {
|
||||||
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,15 @@ abstract class WallabagController extends AbstractController
|
||||||
*/
|
*/
|
||||||
public function indexAction(Request $request, TranslatorInterface $translator)
|
public function indexAction(Request $request, TranslatorInterface $translator)
|
||||||
{
|
{
|
||||||
$wallabag = $this->getImportService();
|
$import = $this->getImportService();
|
||||||
if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
|
if (!$import->isEnabled()) {
|
||||||
throw $this->createAccessDeniedException('You can not access this importer.');
|
throw $this->createNotFoundException('Import is disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm(UploadImportType::class);
|
$form = $this->createForm(UploadImportType::class);
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
|
|
||||||
$wallabag->setUser($this->getUser());
|
$import->setUser($this->getUser());
|
||||||
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
$file = $form->get('file')->getData();
|
$file = $form->get('file')->getData();
|
||||||
|
@ -38,7 +38,7 @@ abstract class WallabagController extends AbstractController
|
||||||
$name = $this->getUser()->getId() . '.json';
|
$name = $this->getUser()->getId() . '.json';
|
||||||
|
|
||||||
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
if (null !== $file && \in_array($file->getClientMimeType(), $this->getParameter('wallabag.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag.resource_dir'), $name)) {
|
||||||
$res = $wallabag
|
$res = $import
|
||||||
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
|
||||||
->setMarkAsRead($markAsRead)
|
->setMarkAsRead($markAsRead)
|
||||||
->import();
|
->import();
|
||||||
|
@ -46,7 +46,7 @@ abstract class WallabagController extends AbstractController
|
||||||
$message = 'flashes.import.notice.failed';
|
$message = 'flashes.import.notice.failed';
|
||||||
|
|
||||||
if (true === $res) {
|
if (true === $res) {
|
||||||
$summary = $wallabag->getSummary();
|
$summary = $import->getSummary();
|
||||||
$message = $translator->trans('flashes.import.notice.summary', [
|
$message = $translator->trans('flashes.import.notice.summary', [
|
||||||
'%imported%' => $summary['imported'],
|
'%imported%' => $summary['imported'],
|
||||||
'%skipped%' => $summary['skipped'],
|
'%skipped%' => $summary['skipped'],
|
||||||
|
@ -71,7 +71,7 @@ abstract class WallabagController extends AbstractController
|
||||||
|
|
||||||
return $this->render($this->getImportTemplate(), [
|
return $this->render($this->getImportTemplate(), [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'import' => $wallabag,
|
'import' => $import,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,8 @@ class ImportChain
|
||||||
*/
|
*/
|
||||||
public function addImport(ImportInterface $import, $alias)
|
public function addImport(ImportInterface $import, $alias)
|
||||||
{
|
{
|
||||||
// if (true === $import->isEnabled()) {
|
|
||||||
$this->imports[$alias] = $import;
|
$this->imports[$alias] = $import;
|
||||||
|
|
||||||
// }
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Wallabag\Security\Voter;
|
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
||||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|
||||||
use Wallabag\Entity\User;
|
|
||||||
use Wallabag\Import\AbstractImport;
|
|
||||||
|
|
||||||
class ImportVoter extends Voter
|
|
||||||
{
|
|
||||||
public const USE_IMPORTER = 'USE_IMPORTER';
|
|
||||||
|
|
||||||
protected function supports(string $attribute, $subject): bool
|
|
||||||
{
|
|
||||||
if (!$subject instanceof AbstractImport) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!\in_array($attribute, [self::USE_IMPORTER], true)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
|
|
||||||
{
|
|
||||||
\assert($subject instanceof AbstractImport);
|
|
||||||
|
|
||||||
$user = $token->getUser();
|
|
||||||
|
|
||||||
if (!$user instanceof User) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return match ($attribute) {
|
|
||||||
self::USE_IMPORTER => true === $subject->isEnabled(),
|
|
||||||
default => false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,17 +16,17 @@
|
||||||
|
|
||||||
{{ 'import.page_description'|trans }}
|
{{ 'import.page_description'|trans }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% for import in imports %}
|
{% for import in imports | filter(i => i.isEnabled()) %}
|
||||||
<div class="col s6 m3">
|
<div class="col s6 m3">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<span class="card-title">{{ import.name }}</span>
|
<span class="card-title">{{ import.name }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-action">
|
<div class="card-action">
|
||||||
<a href="{{ path(import.url) }}">{{ 'import.action.import_contents'|trans }}</a>
|
<a href="{{ path(import.url) }}">{{ 'import.action.import_contents'|trans }}</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ChromeControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithChromeFile()
|
public function testImportChromeWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -132,7 +132,7 @@ class ChromeControllerTest extends WallabagTestCase
|
||||||
$this->assertSame('07', $createdAt->format('m'));
|
$this->assertSame('07', $createdAt->format('m'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportChromeWithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -155,4 +155,17 @@ class ChromeControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportChromeDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('chrome_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/chrome');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('chrome_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,4 +200,17 @@ class DeliciousControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportDeliciousDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('delicious_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/delicious');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('delicious_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,4 +133,17 @@ class ElcuratorControllerTest extends WallabagTestCase
|
||||||
$this->assertContains('tag1', $tags, 'It includes the "tag1" tag');
|
$this->assertContains('tag1', $tags, 'It includes the "tag1" tag');
|
||||||
$this->assertContains('tag2', $tags, 'It includes the "tag2" tag');
|
$this->assertContains('tag2', $tags, 'It includes the "tag2" tag');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportElcuratorDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('elcurator_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/elcurator');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('elcurator_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class FirefoxControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFirefoxFile()
|
public function testImportFirefoxWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -129,7 +129,7 @@ class FirefoxControllerTest extends WallabagTestCase
|
||||||
$this->assertCount(3, $content->getTags());
|
$this->assertCount(3, $content->getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportFirefoxWithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -152,4 +152,17 @@ class FirefoxControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportFirefoxDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('firefox_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/firefox');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('firefox_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,4 +213,17 @@ class InstapaperControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportInstapaperDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('instapaper_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/instapaper');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('instapaper_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,4 +200,17 @@ class OmnivoreControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportOmnivoreDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('omnivore_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/omnivore');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('omnivore_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,4 +207,17 @@ class PinboardControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportPinboardDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('pinboard_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/pinboard');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('pinboard_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,11 @@ class PocketControllerTest extends WallabagTestCase
|
||||||
->method('getRequestToken')
|
->method('getRequestToken')
|
||||||
->willReturn('token');
|
->willReturn('token');
|
||||||
|
|
||||||
|
$pocketImport
|
||||||
|
->expects($this->once())
|
||||||
|
->method('isEnabled')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
|
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
|
||||||
|
|
||||||
$client->request('POST', '/import/pocket/auth');
|
$client->request('POST', '/import/pocket/auth');
|
||||||
|
@ -97,6 +102,11 @@ class PocketControllerTest extends WallabagTestCase
|
||||||
->method('authorize')
|
->method('authorize')
|
||||||
->willReturn(false);
|
->willReturn(false);
|
||||||
|
|
||||||
|
$pocketImport
|
||||||
|
->expects($this->once())
|
||||||
|
->method('isEnabled')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
|
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
|
||||||
|
|
||||||
$client->request('GET', '/import/pocket/callback');
|
$client->request('GET', '/import/pocket/callback');
|
||||||
|
@ -131,6 +141,11 @@ class PocketControllerTest extends WallabagTestCase
|
||||||
->method('import')
|
->method('import')
|
||||||
->willReturn(true);
|
->willReturn(true);
|
||||||
|
|
||||||
|
$pocketImport
|
||||||
|
->expects($this->once())
|
||||||
|
->method('isEnabled')
|
||||||
|
->willReturn(true);
|
||||||
|
|
||||||
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
|
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
|
||||||
|
|
||||||
$client->request('GET', '/import/pocket/callback');
|
$client->request('GET', '/import/pocket/callback');
|
||||||
|
@ -139,4 +154,17 @@ class PocketControllerTest extends WallabagTestCase
|
||||||
$this->assertStringContainsString('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
|
$this->assertStringContainsString('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
|
||||||
$this->assertSame('flashes.import.notice.summary', $client->getContainer()->get(SessionInterface::class)->getFlashBag()->peek('notice')[0]);
|
$this->assertSame('flashes.import.notice.summary', $client->getContainer()->get(SessionInterface::class)->getFlashBag()->peek('notice')[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportPocketDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('pocket_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/pocket');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('pocket_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class PocketHtmlControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithPocketHtmlFile()
|
public function testImportPocketHtmlWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -129,7 +129,7 @@ class PocketHtmlControllerTest extends WallabagTestCase
|
||||||
$this->assertCount(3, $content->getTags());
|
$this->assertCount(3, $content->getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportPocketHtmlWithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -152,4 +152,17 @@ class PocketHtmlControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportPocketHtmlDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('pocket_html_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/pocket_html');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('pocket_html_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,4 +205,17 @@ class ReadabilityControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportReadabilityDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('readability_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/readability');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('readability_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ShaarliControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithShaarliFile()
|
public function testImportShaarliWithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -129,7 +129,7 @@ class ShaarliControllerTest extends WallabagTestCase
|
||||||
$this->assertCount(2, $content->getTags());
|
$this->assertCount(2, $content->getTags());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportShaarliWithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -152,4 +152,17 @@ class ShaarliControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportShaarliDisabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('shaarli_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/shaarli');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('shaarli_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Wallabag\Entity\Entry;
|
||||||
|
|
||||||
class WallabagV1ControllerTest extends WallabagTestCase
|
class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
{
|
{
|
||||||
public function testImportWallabag()
|
public function testImportWallabagV1()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -23,7 +23,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
|
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithRabbitEnabled()
|
public function testImportWallabagV1WithRabbitEnabled()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -39,7 +39,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagBadFile()
|
public function testImportWallabagV1BadFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -56,7 +56,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithRedisEnabled()
|
public function testImportWallabagV1WithRedisEnabled()
|
||||||
{
|
{
|
||||||
$this->checkRedis();
|
$this->checkRedis();
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
@ -92,7 +92,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFile()
|
public function testImportWallabagV1WithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -136,7 +136,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
|
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFileAndMarkAllAsRead()
|
public function testImportWallabagV1WithFileAndMarkAllAsRead()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -183,7 +183,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportWallabagV1WithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -206,4 +206,17 @@ class WallabagV1ControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportWallabagV1Disabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('wallabag_v1_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/wallabag_v1');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('wallabag_v1_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ use Wallabag\Entity\Entry;
|
||||||
|
|
||||||
class WallabagV2ControllerTest extends WallabagTestCase
|
class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
{
|
{
|
||||||
public function testImportWallabag()
|
public function testImportWallabagV2()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -23,7 +23,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
|
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithRabbitEnabled()
|
public function testImportWallabagV2WithRabbitEnabled()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -39,7 +39,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagBadFile()
|
public function testImportWallabagV2BadFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -56,7 +56,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
$this->assertSame(200, $client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithRedisEnabled()
|
public function testImportWallabagV2WithRedisEnabled()
|
||||||
{
|
{
|
||||||
$this->checkRedis();
|
$this->checkRedis();
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
|
@ -92,7 +92,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithFile()
|
public function testImportWallabagV2WithFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -158,7 +158,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
$this->assertTrue($content->isStarred(), 'Entry is starred');
|
$this->assertTrue($content->isStarred(), 'Entry is starred');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testImportWallabagWithEmptyFile()
|
public function testImportWallabagV2WithEmptyFile()
|
||||||
{
|
{
|
||||||
$this->logInAs('admin');
|
$this->logInAs('admin');
|
||||||
$client = $this->getTestClient();
|
$client = $this->getTestClient();
|
||||||
|
@ -181,4 +181,17 @@ class WallabagV2ControllerTest extends WallabagTestCase
|
||||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||||
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
$this->assertStringContainsString('flashes.import.notice.failed', $body[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testImportWallabagV2Disabled()
|
||||||
|
{
|
||||||
|
$this->logInAs('admin');
|
||||||
|
$client = $this->getTestClient();
|
||||||
|
$client->getContainer()->get(Config::class)->set('wallabag_v2_enabled', 0);
|
||||||
|
|
||||||
|
$client->request('GET', '/import/wallabag_v2');
|
||||||
|
|
||||||
|
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||||
|
|
||||||
|
$client->getContainer()->get(Config::class)->set('wallabag_v2_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Security\Voter;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
||||||
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
|
|
||||||
use Wallabag\Entity\SiteCredential;
|
|
||||||
use Wallabag\Entity\User;
|
|
||||||
use Wallabag\Security\Voter\ImportVoter;
|
|
||||||
|
|
||||||
class ImportVoterTest extends TestCase
|
|
||||||
{
|
|
||||||
private $token;
|
|
||||||
private $user;
|
|
||||||
private $importVoter;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
$this->token = $this->createMock(TokenInterface::class);
|
|
||||||
$this->user = new User();
|
|
||||||
|
|
||||||
$this->importVoter = new ImportVoter();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVoteReturnsAbstainForInvalidSubject(): void
|
|
||||||
{
|
|
||||||
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->importVoter->vote($this->token, new \stdClass(), [ImportVoter::USE_IMPORTER]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVoteReturnsAbstainForInvalidAttribute(): void
|
|
||||||
{
|
|
||||||
$this->assertSame(VoterInterface::ACCESS_ABSTAIN, $this->importVoter->vote($this->token, new SiteCredential(new User()), ['INVALID']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVoteReturnsDeniedForNonSiteCredentialUserEdit(): void
|
|
||||||
{
|
|
||||||
$this->assertSame(VoterInterface::ACCESS_DENIED, $this->importVoter->vote($this->token, new SiteCredential(new User()), [ImportVoter::USE_IMPORTER]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testVoteReturnsGrantedForSiteCredentialUserEdit(): void
|
|
||||||
{
|
|
||||||
$this->assertSame(VoterInterface::ACCESS_GRANTED, $this->importVoter->vote($this->token, new SiteCredential($this->user), [ImportVoter::USE_IMPORTER]));
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue