mirror of
https://github.com/wallabag/wallabag.git
synced 2025-03-13 22:52:39 +00:00
Merge 6fa3e9581c
into a4a6eb580b
This commit is contained in:
commit
1c42826179
7 changed files with 45 additions and 16 deletions
29
src/Event/Subscriber/AccessDeniedToNotFoundSubscriber.php
Normal file
29
src/Event/Subscriber/AccessDeniedToNotFoundSubscriber.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\Event\Subscriber;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
class AccessDeniedToNotFoundSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
KernelEvents::EXCEPTION => 'onKernelException',
|
||||
];
|
||||
}
|
||||
|
||||
public function onKernelException(ExceptionEvent $event): void
|
||||
{
|
||||
$exception = $event->getThrowable();
|
||||
|
||||
if ($exception instanceof AccessDeniedHttpException) {
|
||||
$notFoundException = new NotFoundHttpException('', $exception);
|
||||
$event->setThrowable($notFoundException);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,7 +105,7 @@ class DeveloperControllerTest extends WallabagTestCase
|
|||
|
||||
$this->logInAs('bob');
|
||||
$client->request('POST', '/developer/client/delete/' . $adminApiClient->getId());
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
|
||||
// Try to remove the admin's client with the good user
|
||||
$this->logInAs('admin');
|
||||
|
|
|
@ -110,7 +110,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||
|
||||
$this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
|
||||
|
||||
$this->assertSame(403, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testGetEntries()
|
||||
|
@ -1260,14 +1260,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
|
|||
{
|
||||
$this->client->request('GET', '/api/entries/exists?url=');
|
||||
|
||||
$this->assertSame(403, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testGetEntriesExistsWithNoHashedUrl()
|
||||
{
|
||||
$this->client->request('GET', '/api/entries/exists?hashed_url=');
|
||||
|
||||
$this->assertSame(403, $this->client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $this->client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testReloadEntryErrorWhileFetching()
|
||||
|
|
|
@ -577,9 +577,9 @@ class ConfigControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->request('GET', '/tagging-rule/delete/' . $rule->getId());
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||
$this->assertStringContainsString('You can not access this rule', $body[0]);
|
||||
$this->assertStringContainsString('404: Not Found', $body[0]);
|
||||
}
|
||||
|
||||
public function testEditingTaggingRuleFromAnOtherUser()
|
||||
|
@ -593,9 +593,9 @@ class ConfigControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||
$this->assertStringContainsString('You can not access this rule', $body[0]);
|
||||
$this->assertStringContainsString('404: Not Found', $body[0]);
|
||||
}
|
||||
|
||||
public function testIgnoreOriginRuleCreation()
|
||||
|
@ -714,9 +714,9 @@ class ConfigControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->request('GET', '/ignore-origin-user-rule/edit/' . $rule->getId());
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||
$this->assertStringContainsString('You can not access this rule', $body[0]);
|
||||
$this->assertStringContainsString('404: Not Found', $body[0]);
|
||||
}
|
||||
|
||||
public function testEditingIgnoreOriginRuleFromAnOtherUser()
|
||||
|
@ -730,9 +730,9 @@ class ConfigControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->request('GET', '/ignore-origin-user-rule/edit/' . $rule->getId());
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
$this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
|
||||
$this->assertStringContainsString('You can not access this rule', $body[0]);
|
||||
$this->assertStringContainsString('404: Not Found', $body[0]);
|
||||
}
|
||||
|
||||
public function testDeleteUserButtonVisibility()
|
||||
|
@ -767,7 +767,7 @@ class ConfigControllerTest extends WallabagTestCase
|
|||
$this->assertStringNotContainsString('config.form_user.delete.button', $body[0]);
|
||||
|
||||
$client->request('POST', '/account/delete');
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
|
||||
$user = $em
|
||||
->getRepository(User::class)
|
||||
|
|
|
@ -781,7 +781,7 @@ class EntryControllerTest extends WallabagTestCase
|
|||
|
||||
$client->request('GET', '/view/' . $content->getId());
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testFilterOnReadingTime()
|
||||
|
|
|
@ -27,6 +27,6 @@ class SettingsControllerTest extends WallabagTestCase
|
|||
|
||||
$crawler = $client->request('GET', '/settings');
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ class SiteCredentialControllerTest extends WallabagTestCase
|
|||
|
||||
$client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
|
||||
|
||||
$this->assertSame(403, $client->getResponse()->getStatusCode());
|
||||
$this->assertSame(404, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function testDeleteSiteCredential()
|
||||
|
|
Loading…
Reference in a new issue