diff --git a/app/config/services.yml b/app/config/services.yml
index 0d9d33741..de0ebf9f3 100644
--- a/app/config/services.yml
+++ b/app/config/services.yml
@@ -301,7 +301,7 @@ services:
Wallabag\Import\ReadabilityImport:
calls:
- - [ setEnabled, [ '@=service(''craue_config'').get(''readibility_enabled'')' ] ]
+ - [ setEnabled, [ '@=service(''craue_config'').get(''readability_enabled'')' ] ]
tags:
- { name: wallabag.import, alias: readability }
diff --git a/app/config/wallabag.yml b/app/config/wallabag.yml
index 28ec013c1..1ff0d7b0d 100644
--- a/app/config/wallabag.yml
+++ b/app/config/wallabag.yml
@@ -143,7 +143,7 @@ parameters:
value: 1
section: import
-
- name: readibility_enabled
+ name: readability_enabled
value: 1
section: import
-
@@ -178,10 +178,6 @@ parameters:
name: pocket_html_enabled
value: 1
section: import
- -
- name: pocket_csv_enabled
- value: 1
- section: import
-
name: matomo_enabled
value: 0
diff --git a/migrations/Version20250526113708.php b/migrations/Version20250526113708.php
index 51e264b74..0e6f1ffe5 100644
--- a/migrations/Version20250526113708.php
+++ b/migrations/Version20250526113708.php
@@ -79,7 +79,7 @@ final class Version20250526113708 extends WallabagMigration
'section' => 'import',
],
[
- 'name' => 'pocket_csv_enabled',
+ 'name' => 'elcurator_enabled',
'value' => '1',
'section' => 'import',
],
diff --git a/src/Controller/Import/BrowserController.php b/src/Controller/Import/BrowserController.php
index a7bc6f142..290c14f77 100644
--- a/src/Controller/Import/BrowserController.php
+++ b/src/Controller/Import/BrowserController.php
@@ -20,15 +20,15 @@ abstract class BrowserController extends AbstractController
#[IsGranted('IMPORT_ENTRIES')]
public function indexAction(Request $request, TranslatorInterface $translator)
{
- $wallabag = $this->getImportService();
- if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
- throw $this->createAccessDeniedException('You can not access this importer.');
+ $import = $this->getImportService();
+ if (!$import->isEnabled()) {
+ throw $this->createNotFoundException('Import is disabled');
}
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
- $wallabag->setUser($this->getUser());
+ $import->setUser($this->getUser());
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
@@ -36,7 +36,7 @@ abstract class BrowserController extends AbstractController
$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)) {
- $res = $wallabag
+ $res = $import
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@@ -44,7 +44,7 @@ abstract class BrowserController extends AbstractController
$message = 'flashes.import.notice.failed';
if (true === $res) {
- $summary = $wallabag->getSummary();
+ $summary = $import->getSummary();
$message = $translator->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
@@ -68,7 +68,7 @@ abstract class BrowserController extends AbstractController
return $this->render($this->getImportTemplate(), [
'form' => $form->createView(),
- 'import' => $wallabag,
+ 'import' => $import,
]);
}
diff --git a/src/Controller/Import/DeliciousController.php b/src/Controller/Import/DeliciousController.php
index 2ead52358..9f2c4628f 100644
--- a/src/Controller/Import/DeliciousController.php
+++ b/src/Controller/Import/DeliciousController.php
@@ -23,9 +23,12 @@ class DeliciousController extends AbstractController
#[Route(path: '/import/delicious', name: 'import_delicious', methods: ['GET', 'POST'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'delicious')]
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->handleRequest($request);
diff --git a/src/Controller/Import/HtmlController.php b/src/Controller/Import/HtmlController.php
index 5ff32d39c..5c507e28d 100644
--- a/src/Controller/Import/HtmlController.php
+++ b/src/Controller/Import/HtmlController.php
@@ -20,15 +20,15 @@ abstract class HtmlController extends AbstractController
#[IsGranted('IMPORT_ENTRIES')]
public function indexAction(Request $request, TranslatorInterface $translator)
{
- $wallabag = $this->getImportService();
- if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
- throw $this->createAccessDeniedException('You can not access this importer.');
+ $import = $this->getImportService();
+ if (!$import->isEnabled()) {
+ throw $this->createNotFoundException('Import is disabled');
}
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
- $wallabag->setUser($this->getUser());
+ $import->setUser($this->getUser());
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
@@ -36,7 +36,7 @@ abstract class HtmlController extends AbstractController
$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)) {
- $res = $wallabag
+ $res = $import
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@@ -44,7 +44,7 @@ abstract class HtmlController extends AbstractController
$message = 'flashes.import.notice.failed';
if (true === $res) {
- $summary = $wallabag->getSummary();
+ $summary = $import->getSummary();
$message = $translator->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
@@ -68,7 +68,7 @@ abstract class HtmlController extends AbstractController
return $this->render($this->getImportTemplate(), [
'form' => $form->createView(),
- 'import' => $wallabag,
+ 'import' => $import,
]);
}
diff --git a/src/Controller/Import/InstapaperController.php b/src/Controller/Import/InstapaperController.php
index d04e62280..d8e607b2f 100644
--- a/src/Controller/Import/InstapaperController.php
+++ b/src/Controller/Import/InstapaperController.php
@@ -23,9 +23,12 @@ class InstapaperController extends AbstractController
#[Route(path: '/import/instapaper', name: 'import_instapaper', methods: ['GET', 'POST'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'instapaper')]
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->handleRequest($request);
diff --git a/src/Controller/Import/OmnivoreController.php b/src/Controller/Import/OmnivoreController.php
index 388a40b1e..a5d978160 100644
--- a/src/Controller/Import/OmnivoreController.php
+++ b/src/Controller/Import/OmnivoreController.php
@@ -23,9 +23,12 @@ class OmnivoreController extends AbstractController
#[Route(path: '/import/omnivore', name: 'import_omnivore', methods: ['GET', 'POST'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'omnivore')]
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->handleRequest($request);
diff --git a/src/Controller/Import/PinboardController.php b/src/Controller/Import/PinboardController.php
index 2554fcefd..0b6618303 100644
--- a/src/Controller/Import/PinboardController.php
+++ b/src/Controller/Import/PinboardController.php
@@ -23,9 +23,12 @@ class PinboardController extends AbstractController
#[Route(path: '/import/pinboard', name: 'import_pinboard', methods: ['GET', 'POST'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'pinboard')]
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->handleRequest($request);
diff --git a/src/Controller/Import/PocketController.php b/src/Controller/Import/PocketController.php
index c5c392d3a..54f1ad23f 100644
--- a/src/Controller/Import/PocketController.php
+++ b/src/Controller/Import/PocketController.php
@@ -27,9 +27,12 @@ class PocketController extends AbstractController
#[Route(path: '/import/pocket', name: 'import_pocket', methods: ['GET'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'pocketImport')]
public function indexAction(PocketImport $pocketImport)
{
+ if (!$pocketImport->isEnabled()) {
+ throw $this->createNotFoundException('Import is disabled');
+ }
+
$pocket = $this->getPocketImportService($pocketImport);
$form = $this->createFormBuilder($pocket)
@@ -48,9 +51,12 @@ class PocketController extends AbstractController
#[Route(path: '/import/pocket/auth', name: 'import_pocket_auth', methods: ['POST'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'pocketImport')]
public function authAction(Request $request, PocketImport $pocketImport)
{
+ if (!$pocketImport->isEnabled()) {
+ throw $this->createNotFoundException('Import is disabled');
+ }
+
$requestToken = $this->getPocketImportService($pocketImport)
->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'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'pocketImport')]
public function callbackAction(PocketImport $pocketImport, TranslatorInterface $translator)
{
+ if (!$pocketImport->isEnabled()) {
+ throw $this->createNotFoundException('Import is disabled');
+ }
+
$message = 'flashes.import.notice.failed';
$pocket = $this->getPocketImportService($pocketImport);
diff --git a/src/Controller/Import/ReadabilityController.php b/src/Controller/Import/ReadabilityController.php
index 2eb10c73c..68e4c4e79 100644
--- a/src/Controller/Import/ReadabilityController.php
+++ b/src/Controller/Import/ReadabilityController.php
@@ -23,9 +23,12 @@ class ReadabilityController extends AbstractController
#[Route(path: '/import/readability', name: 'import_readability', methods: ['GET', 'POST'])]
#[IsGranted('IMPORT_ENTRIES')]
- #[IsGranted('USE_IMPORTER', subject: 'readability')]
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->handleRequest($request);
diff --git a/src/Controller/Import/WallabagController.php b/src/Controller/Import/WallabagController.php
index e8ae8e713..94ce07660 100644
--- a/src/Controller/Import/WallabagController.php
+++ b/src/Controller/Import/WallabagController.php
@@ -22,15 +22,15 @@ abstract class WallabagController extends AbstractController
*/
public function indexAction(Request $request, TranslatorInterface $translator)
{
- $wallabag = $this->getImportService();
- if (!$this->isGranted('USE_IMPORTER', $wallabag)) {
- throw $this->createAccessDeniedException('You can not access this importer.');
+ $import = $this->getImportService();
+ if (!$import->isEnabled()) {
+ throw $this->createNotFoundException('Import is disabled');
}
$form = $this->createForm(UploadImportType::class);
$form->handleRequest($request);
- $wallabag->setUser($this->getUser());
+ $import->setUser($this->getUser());
if ($form->isSubmitted() && $form->isValid()) {
$file = $form->get('file')->getData();
@@ -38,7 +38,7 @@ abstract class WallabagController extends AbstractController
$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)) {
- $res = $wallabag
+ $res = $import
->setFilepath($this->getParameter('wallabag.resource_dir') . '/' . $name)
->setMarkAsRead($markAsRead)
->import();
@@ -46,7 +46,7 @@ abstract class WallabagController extends AbstractController
$message = 'flashes.import.notice.failed';
if (true === $res) {
- $summary = $wallabag->getSummary();
+ $summary = $import->getSummary();
$message = $translator->trans('flashes.import.notice.summary', [
'%imported%' => $summary['imported'],
'%skipped%' => $summary['skipped'],
@@ -71,7 +71,7 @@ abstract class WallabagController extends AbstractController
return $this->render($this->getImportTemplate(), [
'form' => $form->createView(),
- 'import' => $wallabag,
+ 'import' => $import,
]);
}
diff --git a/src/Import/ImportChain.php b/src/Import/ImportChain.php
index a96638c01..c1ae6dc3f 100644
--- a/src/Import/ImportChain.php
+++ b/src/Import/ImportChain.php
@@ -18,10 +18,8 @@ class ImportChain
*/
public function addImport(ImportInterface $import, $alias)
{
- // if (true === $import->isEnabled()) {
$this->imports[$alias] = $import;
- // }
return $this;
}
diff --git a/src/Security/Voter/ImportVoter.php b/src/Security/Voter/ImportVoter.php
deleted file mode 100644
index a70e565a1..000000000
--- a/src/Security/Voter/ImportVoter.php
+++ /dev/null
@@ -1,42 +0,0 @@
-getUser();
-
- if (!$user instanceof User) {
- return false;
- }
-
- return match ($attribute) {
- self::USE_IMPORTER => true === $subject->isEnabled(),
- default => false,
- };
- }
-}
diff --git a/templates/Import/index.html.twig b/templates/Import/index.html.twig
index 236a7f887..50dd5320e 100644
--- a/templates/Import/index.html.twig
+++ b/templates/Import/index.html.twig
@@ -16,17 +16,17 @@
{{ 'import.page_description'|trans }}
- {% for import in imports %}
+ {% for import in imports | filter(i => i.isEnabled()) %}
-
- {{ import.name }}
-
-
+
+ {{ import.name }}
+
+
-
+
{% endfor %}
diff --git a/tests/Controller/Import/ChromeControllerTest.php b/tests/Controller/Import/ChromeControllerTest.php
index 3d9377072..88efeadf9 100644
--- a/tests/Controller/Import/ChromeControllerTest.php
+++ b/tests/Controller/Import/ChromeControllerTest.php
@@ -91,7 +91,7 @@ class ChromeControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
- public function testImportWallabagWithChromeFile()
+ public function testImportChromeWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -132,7 +132,7 @@ class ChromeControllerTest extends WallabagTestCase
$this->assertSame('07', $createdAt->format('m'));
}
- public function testImportWallabagWithEmptyFile()
+ public function testImportChromeWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -155,4 +155,17 @@ class ChromeControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/DeliciousControllerTest.php b/tests/Controller/Import/DeliciousControllerTest.php
index 010381ce1..bde3f177d 100644
--- a/tests/Controller/Import/DeliciousControllerTest.php
+++ b/tests/Controller/Import/DeliciousControllerTest.php
@@ -200,4 +200,17 @@ class DeliciousControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/ElcuratorControllerTest.php b/tests/Controller/Import/ElcuratorControllerTest.php
index 6e4c4c126..9fb044219 100644
--- a/tests/Controller/Import/ElcuratorControllerTest.php
+++ b/tests/Controller/Import/ElcuratorControllerTest.php
@@ -133,4 +133,17 @@ class ElcuratorControllerTest extends WallabagTestCase
$this->assertContains('tag1', $tags, 'It includes the "tag1" 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);
+ }
}
diff --git a/tests/Controller/Import/FirefoxControllerTest.php b/tests/Controller/Import/FirefoxControllerTest.php
index c285018d7..defeb1e29 100644
--- a/tests/Controller/Import/FirefoxControllerTest.php
+++ b/tests/Controller/Import/FirefoxControllerTest.php
@@ -91,7 +91,7 @@ class FirefoxControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
- public function testImportWallabagWithFirefoxFile()
+ public function testImportFirefoxWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -129,7 +129,7 @@ class FirefoxControllerTest extends WallabagTestCase
$this->assertCount(3, $content->getTags());
}
- public function testImportWallabagWithEmptyFile()
+ public function testImportFirefoxWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -152,4 +152,17 @@ class FirefoxControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/InstapaperControllerTest.php b/tests/Controller/Import/InstapaperControllerTest.php
index d05c06f05..25245af98 100644
--- a/tests/Controller/Import/InstapaperControllerTest.php
+++ b/tests/Controller/Import/InstapaperControllerTest.php
@@ -213,4 +213,17 @@ class InstapaperControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/OmnivoreControllerTest.php b/tests/Controller/Import/OmnivoreControllerTest.php
index 1832bc01e..a06db1915 100644
--- a/tests/Controller/Import/OmnivoreControllerTest.php
+++ b/tests/Controller/Import/OmnivoreControllerTest.php
@@ -200,4 +200,17 @@ class OmnivoreControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/PinboardControllerTest.php b/tests/Controller/Import/PinboardControllerTest.php
index 9d4e5ec53..342bf8eb5 100644
--- a/tests/Controller/Import/PinboardControllerTest.php
+++ b/tests/Controller/Import/PinboardControllerTest.php
@@ -207,4 +207,17 @@ class PinboardControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/PocketControllerTest.php b/tests/Controller/Import/PocketControllerTest.php
index 4216a7cc1..018e39341 100644
--- a/tests/Controller/Import/PocketControllerTest.php
+++ b/tests/Controller/Import/PocketControllerTest.php
@@ -75,6 +75,11 @@ class PocketControllerTest extends WallabagTestCase
->method('getRequestToken')
->willReturn('token');
+ $pocketImport
+ ->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(true);
+
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('POST', '/import/pocket/auth');
@@ -97,6 +102,11 @@ class PocketControllerTest extends WallabagTestCase
->method('authorize')
->willReturn(false);
+ $pocketImport
+ ->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(true);
+
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$client->request('GET', '/import/pocket/callback');
@@ -131,6 +141,11 @@ class PocketControllerTest extends WallabagTestCase
->method('import')
->willReturn(true);
+ $pocketImport
+ ->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(true);
+
static::$kernel->getContainer()->set(PocketImport::class, $pocketImport);
$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->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);
+ }
}
diff --git a/tests/Controller/Import/PocketHtmlControllerTest.php b/tests/Controller/Import/PocketHtmlControllerTest.php
index ed5e86d96..3346144a2 100644
--- a/tests/Controller/Import/PocketHtmlControllerTest.php
+++ b/tests/Controller/Import/PocketHtmlControllerTest.php
@@ -91,7 +91,7 @@ class PocketHtmlControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
- public function testImportWallabagWithPocketHtmlFile()
+ public function testImportPocketHtmlWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -129,7 +129,7 @@ class PocketHtmlControllerTest extends WallabagTestCase
$this->assertCount(3, $content->getTags());
}
- public function testImportWallabagWithEmptyFile()
+ public function testImportPocketHtmlWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -152,4 +152,17 @@ class PocketHtmlControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/ReadabilityControllerTest.php b/tests/Controller/Import/ReadabilityControllerTest.php
index 5930cbbbd..3b000ef0e 100644
--- a/tests/Controller/Import/ReadabilityControllerTest.php
+++ b/tests/Controller/Import/ReadabilityControllerTest.php
@@ -205,4 +205,17 @@ class ReadabilityControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/ShaarliControllerTest.php b/tests/Controller/Import/ShaarliControllerTest.php
index 2be30f9f8..e54417c4b 100644
--- a/tests/Controller/Import/ShaarliControllerTest.php
+++ b/tests/Controller/Import/ShaarliControllerTest.php
@@ -91,7 +91,7 @@ class ShaarliControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
- public function testImportWallabagWithShaarliFile()
+ public function testImportShaarliWithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -129,7 +129,7 @@ class ShaarliControllerTest extends WallabagTestCase
$this->assertCount(2, $content->getTags());
}
- public function testImportWallabagWithEmptyFile()
+ public function testImportShaarliWithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -152,4 +152,17 @@ class ShaarliControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/WallabagV1ControllerTest.php b/tests/Controller/Import/WallabagV1ControllerTest.php
index a6e394b28..237f4538a 100644
--- a/tests/Controller/Import/WallabagV1ControllerTest.php
+++ b/tests/Controller/Import/WallabagV1ControllerTest.php
@@ -11,7 +11,7 @@ use Wallabag\Entity\Entry;
class WallabagV1ControllerTest extends WallabagTestCase
{
- public function testImportWallabag()
+ public function testImportWallabagV1()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -23,7 +23,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
- public function testImportWallabagWithRabbitEnabled()
+ public function testImportWallabagV1WithRabbitEnabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -39,7 +39,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
}
- public function testImportWallabagBadFile()
+ public function testImportWallabagV1BadFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -56,7 +56,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
- public function testImportWallabagWithRedisEnabled()
+ public function testImportWallabagV1WithRedisEnabled()
{
$this->checkRedis();
$this->logInAs('admin');
@@ -92,7 +92,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
- public function testImportWallabagWithFile()
+ public function testImportWallabagV1WithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -136,7 +136,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
}
- public function testImportWallabagWithFileAndMarkAllAsRead()
+ public function testImportWallabagV1WithFileAndMarkAllAsRead()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -183,7 +183,7 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertStringContainsString('flashes.import.notice.summary', $body[0]);
}
- public function testImportWallabagWithEmptyFile()
+ public function testImportWallabagV1WithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -206,4 +206,17 @@ class WallabagV1ControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Controller/Import/WallabagV2ControllerTest.php b/tests/Controller/Import/WallabagV2ControllerTest.php
index d3f032601..ca5d2b3d8 100644
--- a/tests/Controller/Import/WallabagV2ControllerTest.php
+++ b/tests/Controller/Import/WallabagV2ControllerTest.php
@@ -11,7 +11,7 @@ use Wallabag\Entity\Entry;
class WallabagV2ControllerTest extends WallabagTestCase
{
- public function testImportWallabag()
+ public function testImportWallabagV2()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -23,7 +23,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertSame(1, $crawler->filter('input[type=file]')->count());
}
- public function testImportWallabagWithRabbitEnabled()
+ public function testImportWallabagV2WithRabbitEnabled()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -39,7 +39,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_rabbitmq', 0);
}
- public function testImportWallabagBadFile()
+ public function testImportWallabagV2BadFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -56,7 +56,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertSame(200, $client->getResponse()->getStatusCode());
}
- public function testImportWallabagWithRedisEnabled()
+ public function testImportWallabagV2WithRedisEnabled()
{
$this->checkRedis();
$this->logInAs('admin');
@@ -92,7 +92,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$client->getContainer()->get(Config::class)->set('import_with_redis', 0);
}
- public function testImportWallabagWithFile()
+ public function testImportWallabagV2WithFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -158,7 +158,7 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertTrue($content->isStarred(), 'Entry is starred');
}
- public function testImportWallabagWithEmptyFile()
+ public function testImportWallabagV2WithEmptyFile()
{
$this->logInAs('admin');
$client = $this->getTestClient();
@@ -181,4 +181,17 @@ class WallabagV2ControllerTest extends WallabagTestCase
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
$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);
+ }
}
diff --git a/tests/Security/Voter/ImportVoterTest.php b/tests/Security/Voter/ImportVoterTest.php
deleted file mode 100644
index 1885cca17..000000000
--- a/tests/Security/Voter/ImportVoterTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
-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]));
- }
-}