Skip to content

Commit

Permalink
Update uses of HttpExceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Nov 25, 2017
1 parent a53a14b commit 7a5e333
Show file tree
Hide file tree
Showing 30 changed files with 85 additions and 85 deletions.
4 changes: 2 additions & 2 deletions src/Auth/BasicAuthenticate.php
Expand Up @@ -14,9 +14,9 @@
*/
namespace Cake\Auth;

use Cake\Http\Exception\UnauthorizedException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\Network\Exception\UnauthorizedException;

/**
* Basic Authentication adapter for AuthComponent.
Expand Down Expand Up @@ -89,7 +89,7 @@ public function getUser(ServerRequest $request)
* @param \Cake\Http\ServerRequest $request A request object.
* @param \Cake\Http\Response $response A response object.
* @return void
* @throws \Cake\Network\Exception\UnauthorizedException
* @throws \Cake\Http\Exception\UnauthorizedException
*/
public function unauthenticated(ServerRequest $request, Response $response)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/AuthComponent.php
Expand Up @@ -21,9 +21,9 @@
use Cake\Core\Exception\Exception;
use Cake\Event\Event;
use Cake\Event\EventDispatcherTrait;
use Cake\Http\Exception\ForbiddenException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\Network\Exception\ForbiddenException;
use Cake\Routing\Router;
use Cake\Utility\Hash;

Expand Down Expand Up @@ -456,7 +456,7 @@ protected function _isLoginAction(Controller $controller)
*
* @param \Cake\Controller\Controller $controller A reference to the controller object
* @return \Cake\Http\Response
* @throws \Cake\Network\Exception\ForbiddenException
* @throws \Cake\Http\Exception\ForbiddenException
*/
protected function _unauthorized(Controller $controller)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/CsrfComponent.php
Expand Up @@ -16,10 +16,10 @@

use Cake\Controller\Component;
use Cake\Event\Event;
use Cake\Http\Exception\InvalidCsrfTokenException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\I18n\Time;
use Cake\Network\Exception\InvalidCsrfTokenException;
use Cake\Utility\Security;

/**
Expand Down Expand Up @@ -149,7 +149,7 @@ protected function _setCookie(ServerRequest $request, Response $response)
* Validate the request data against the cookie token.
*
* @param \Cake\Http\ServerRequest $request The request to validate against.
* @throws \Cake\Network\Exception\InvalidCsrfTokenException when the CSRF token is invalid or missing.
* @throws \Cake\Http\Exception\InvalidCsrfTokenException when the CSRF token is invalid or missing.
* @return void
*/
protected function _validateToken(ServerRequest $request)
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/FlashComponent.php
Expand Up @@ -16,7 +16,7 @@

use Cake\Controller\Component;
use Cake\Controller\ComponentRegistry;
use Cake\Network\Exception\InternalErrorException;
use Cake\Http\Exception\InternalErrorException;
use Cake\Utility\Inflector;
use Exception;

Expand Down Expand Up @@ -150,7 +150,7 @@ public function set($message, array $options = [])
* @param string $name Element name to use.
* @param array $args Parameters to pass when calling `FlashComponent::set()`.
* @return void
* @throws \Cake\Network\Exception\InternalErrorException If missing the flash message.
* @throws \Cake\Http\Exception\InternalErrorException If missing the flash message.
*/
public function __call($name, $args)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Component/PaginatorComponent.php
Expand Up @@ -18,7 +18,7 @@
use Cake\Controller\ComponentRegistry;
use Cake\Datasource\Exception\PageOutOfBoundsException;
use Cake\Datasource\Paginator;
use Cake\Network\Exception\NotFoundException;
use Cake\Http\Exception\NotFoundException;
use InvalidArgumentException;

/**
Expand Down Expand Up @@ -187,7 +187,7 @@ public function implementedEvents()
* @param \Cake\Datasource\RepositoryInterface|\Cake\Datasource\QueryInterface $object The table or query to paginate.
* @param array $settings The settings/configuration used for pagination.
* @return \Cake\Datasource\ResultSetInterface Query results
* @throws \Cake\Network\Exception\NotFoundException
* @throws \Cake\Http\Exception\NotFoundException
*/
public function paginate($object, array $settings = [])
{
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/Component/SecurityComponent.php
Expand Up @@ -20,8 +20,8 @@
use Cake\Controller\Exception\SecurityException;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Http\Exception\BadRequestException;
use Cake\Http\ServerRequest;
use Cake\Network\Exception\BadRequestException;
use Cake\Utility\Hash;
use Cake\Utility\Security;

Expand Down Expand Up @@ -180,7 +180,7 @@ public function requireAuth($actions)
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
* @see \Cake\Controller\Component\SecurityComponent::$blackHoleCallback
* @link https://book.cakephp.org/3.0/en/controllers/components/security.html#handling-blackhole-callbacks
* @throws \Cake\Network\Exception\BadRequestException
* @throws \Cake\Http\Exception\BadRequestException
*/
public function blackHole(Controller $controller, $error = '', SecurityException $exception = null)
{
Expand All @@ -195,7 +195,7 @@ public function blackHole(Controller $controller, $error = '', SecurityException
* Check debug status and throw an Exception based on the existing one
*
* @param \Cake\Controller\Exception\SecurityException|null $exception Additional debug info describing the cause
* @throws \Cake\Network\Exception\BadRequestException
* @throws \Cake\Http\Exception\BadRequestException
* @return void
*/
protected function _throwException($exception = null)
Expand Down Expand Up @@ -588,7 +588,7 @@ public function generateToken(ServerRequest $request)
* @param string $method Method to execute
* @param array $params Parameters to send to method
* @return mixed Controller callback method's response
* @throws \Cake\Network\Exception\BadRequestException When a the blackholeCallback is not callable.
* @throws \Cake\Http\Exception\BadRequestException When a the blackholeCallback is not callable.
*/
protected function _callback(Controller $controller, $method, $params = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Exception/SecurityException.php
Expand Up @@ -12,7 +12,7 @@
*/
namespace Cake\Controller\Exception;

use Cake\Network\Exception\BadRequestException;
use Cake\Http\Exception\BadRequestException;

/**
* Security exception - used when SecurityComponent detects any issue with the current request
Expand Down
2 changes: 1 addition & 1 deletion src/Error/ExceptionRenderer.php
Expand Up @@ -20,9 +20,9 @@
use Cake\Core\Exception\Exception as CakeException;
use Cake\Core\Exception\MissingPluginException;
use Cake\Event\Event;
use Cake\Http\Exception\HttpException;
use Cake\Http\Response;
use Cake\Http\ServerRequestFactory;
use Cake\Network\Exception\HttpException;
use Cake\Routing\DispatcherFactory;
use Cake\Routing\Router;
use Cake\Utility\Inflector;
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Client/Adapter/Stream.php
Expand Up @@ -16,7 +16,7 @@
use Cake\Core\Exception\Exception;
use Cake\Http\Client\Request;
use Cake\Http\Client\Response;
use Cake\Network\Exception\HttpException;
use Cake\Http\Exception\HttpException;

/**
* Implements sending Cake\Http\Client\Request
Expand Down Expand Up @@ -239,7 +239,7 @@ protected function _buildSslContext(Request $request, $options)
*
* @param \Cake\Http\Client\Request $request The request object.
* @return array Array of populated Response objects
* @throws \Cake\Network\Exception\HttpException
* @throws \Cake\Http\Exception\HttpException
*/
protected function _send(Request $request)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/CsrfProtectionMiddleware.php
Expand Up @@ -14,10 +14,10 @@
*/
namespace Cake\Http\Middleware;

use Cake\Http\Exception\InvalidCsrfTokenException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\I18n\Time;
use Cake\Network\Exception\InvalidCsrfTokenException;
use Cake\Utility\Hash;
use Cake\Utility\Security;

Expand Down Expand Up @@ -177,7 +177,7 @@ protected function _addTokenCookie($token, ServerRequest $request, Response $res
*
* @param \Cake\Http\ServerRequest $request The request to validate against.
* @return void
* @throws \Cake\Network\Exception\InvalidCsrfTokenException When the CSRF token is invalid or missing.
* @throws \Cake\Http\Exception\InvalidCsrfTokenException When the CSRF token is invalid or missing.
*/
protected function _validateToken(ServerRequest $request)
{
Expand Down
8 changes: 4 additions & 4 deletions src/Http/Response.php
Expand Up @@ -19,9 +19,9 @@
use Cake\Http\Cookie\Cookie;
use Cake\Http\Cookie\CookieCollection;
use Cake\Http\Cookie\CookieInterface;
use Cake\Http\Exception\NotFoundException;
use Cake\Log\Log;
use Cake\Network\CorsBuilder;
use Cake\Network\Exception\NotFoundException;
use DateTime;
use DateTimeZone;
use InvalidArgumentException;
Expand Down Expand Up @@ -2388,7 +2388,7 @@ public function cors(ServerRequest $request, $allowedDomains = [], $allowedMetho
* to a file, `APP` will be prepended to the path.
* @param array $options Options See above.
* @return void
* @throws \Cake\Network\Exception\NotFoundException
* @throws \Cake\Http\Exception\NotFoundException
* @deprecated 3.4.0 Use withFile() instead.
*/
public function file($path, array $options = [])
Expand Down Expand Up @@ -2462,7 +2462,7 @@ public function file($path, array $options = [])
* to a file, `APP` will be prepended to the path.
* @param array $options Options See above.
* @return static
* @throws \Cake\Network\Exception\NotFoundException
* @throws \Cake\Http\Exception\NotFoundException
*/
public function withFile($path, array $options = [])
{
Expand Down Expand Up @@ -2533,7 +2533,7 @@ public function withStringBody($string)
* Validate a file path is a valid response body.
*
* @param string $path The path to the file.
* @throws \Cake\Network\Exception\NotFoundException
* @throws \Cake\Http\Exception\NotFoundException
* @return \Cake\Filesystem\File
*/
protected function validateFile($path)
Expand Down
4 changes: 2 additions & 2 deletions src/Http/ServerRequest.php
Expand Up @@ -18,7 +18,7 @@
use BadMethodCallException;
use Cake\Core\Configure;
use Cake\Http\Cookie\CookieCollection;
use Cake\Network\Exception\MethodNotAllowedException;
use Cake\Http\Exception\MethodNotAllowedException;
use Cake\Network\Session;
use Cake\Utility\Hash;
use InvalidArgumentException;
Expand Down Expand Up @@ -1895,7 +1895,7 @@ public function env($key, $value = null, $default = null)
*
* @param string|array $methods Allowed HTTP request methods.
* @return bool true
* @throws \Cake\Network\Exception\MethodNotAllowedException
* @throws \Cake\Http\Exception\MethodNotAllowedException
*/
public function allowMethod($methods)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Routing/Filter/AssetFilter.php
Expand Up @@ -62,7 +62,7 @@ public function __construct($config = [])
*
* @param \Cake\Event\Event $event Event containing the request and response object
* @return \Cake\Http\Response|null If the client is requesting a recognized asset, null otherwise
* @throws \Cake\Network\Exception\NotFoundException When asset not found
* @throws \Cake\Http\Exception\NotFoundException When asset not found
*/
public function beforeDispatch(Event $event)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Auth/BasicAuthenticateTest.php
Expand Up @@ -16,10 +16,10 @@

use Cake\Auth\BasicAuthenticate;
use Cake\Controller\ComponentRegistry;
use Cake\Http\Exception\UnauthorizedException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\I18n\Time;
use Cake\Network\Exception\UnauthorizedException;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;

Expand Down Expand Up @@ -218,7 +218,7 @@ public function testAuthenticateSuccess()
*/
public function testAuthenticateFailReChallenge()
{
$this->expectException(\Cake\Network\Exception\UnauthorizedException::class);
$this->expectException(\Cake\Http\Exception\UnauthorizedException::class);
$this->expectExceptionCode(401);
$this->auth->setConfig('scope.username', 'nate');
$request = new ServerRequest([
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Auth/DigestAuthenticateTest.php
Expand Up @@ -19,10 +19,10 @@
use Cake\Auth\DigestAuthenticate;
use Cake\Controller\ComponentRegistry;
use Cake\Core\Configure;
use Cake\Http\Exception\UnauthorizedException;
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\I18n\Time;
use Cake\Network\Exception\UnauthorizedException;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testAuthenticateNoData()
*/
public function testAuthenticateWrongUsername()
{
$this->expectException(\Cake\Network\Exception\UnauthorizedException::class);
$this->expectException(\Cake\Http\Exception\UnauthorizedException::class);
$this->expectExceptionCode(401);
$request = new ServerRequest('posts/index');
$request->addParams(['pass' => []]);
Expand Down Expand Up @@ -355,7 +355,7 @@ public function testAuthenticateSuccessSimulatedRequestMethod()
*/
public function testAuthenticateFailReChallenge()
{
$this->expectException(\Cake\Network\Exception\UnauthorizedException::class);
$this->expectException(\Cake\Http\Exception\UnauthorizedException::class);
$this->expectExceptionCode(401);
$this->auth->setConfig('scope.username', 'nate');
$request = new ServerRequest([
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Console/ConsoleErrorHandlerTest.php
Expand Up @@ -16,9 +16,9 @@

use Cake\Controller\Exception\MissingActionException;
use Cake\Core\Exception\Exception;
use Cake\Http\Exception\InternalErrorException;
use Cake\Http\Exception\NotFoundException;
use Cake\Log\Log;
use Cake\Network\Exception\InternalErrorException;
use Cake\Network\Exception\NotFoundException;
use Cake\TestSuite\TestCase;

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Controller/Component/AuthComponentTest.php
Expand Up @@ -994,7 +994,7 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError()
*/
public function testForbiddenException()
{
$this->expectException(\Cake\Network\Exception\ForbiddenException::class);
$this->expectException(\Cake\Http\Exception\ForbiddenException::class);
$url = '/party/on';
$this->Auth->request = $request = new ServerRequest($url);
$this->Auth->request->addParams(['controller' => 'Party', 'action' => 'on']);
Expand Down Expand Up @@ -1591,7 +1591,7 @@ public function testUser()
*/
public function testStatelessAuthNoRedirect()
{
$this->expectException(\Cake\Network\Exception\UnauthorizedException::class);
$this->expectException(\Cake\Http\Exception\UnauthorizedException::class);
$this->expectExceptionCode(401);
$event = new Event('Controller.startup', $this->Controller);
$_SESSION = [];
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Controller/Component/CsrfComponentTest.php
Expand Up @@ -172,7 +172,7 @@ public function testValidTokenInHeader($method)
*/
public function testInvalidTokenInHeader($method)
{
$this->expectException(\Cake\Network\Exception\InvalidCsrfTokenException::class);
$this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class);
$controller = $this->getMockBuilder('Cake\Controller\Controller')
->setMethods(['redirect'])
->getMock();
Expand Down Expand Up @@ -225,7 +225,7 @@ public function testValidTokenRequestData($method)
*/
public function testInvalidTokenRequestData($method)
{
$this->expectException(\Cake\Network\Exception\InvalidCsrfTokenException::class);
$this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class);
$controller = $this->getMockBuilder('Cake\Controller\Controller')
->setMethods(['redirect'])
->getMock();
Expand All @@ -249,7 +249,7 @@ public function testInvalidTokenRequestData($method)
*/
public function testInvalidTokenRequestDataMissing()
{
$this->expectException(\Cake\Network\Exception\InvalidCsrfTokenException::class);
$this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class);
$controller = $this->getMockBuilder('Cake\Controller\Controller')
->setMethods(['redirect'])
->getMock();
Expand All @@ -274,7 +274,7 @@ public function testInvalidTokenRequestDataMissing()
*/
public function testInvalidTokenMissingCookie($method)
{
$this->expectException(\Cake\Network\Exception\InvalidCsrfTokenException::class);
$this->expectException(\Cake\Http\Exception\InvalidCsrfTokenException::class);
$controller = $this->getMockBuilder('Cake\Controller\Controller')
->setMethods(['redirect'])
->getMock();
Expand Down
Expand Up @@ -22,7 +22,7 @@
use Cake\Datasource\Exception\PageOutOfBoundsException;
use Cake\Datasource\Paginator;
use Cake\Http\ServerRequest;
use Cake\Network\Exception\NotFoundException;
use Cake\Http\Exception\NotFoundException;
use Cake\ORM\Entity;
use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;
Expand Down Expand Up @@ -772,7 +772,7 @@ public function testOutOfRangePageNumberStillProvidesPageCount()
*/
public function testOutOfVeryBigPageNumberGetsClamped()
{
$this->expectException(\Cake\Network\Exception\NotFoundException::class);
$this->expectException(\Cake\Http\Exception\NotFoundException::class);
$this->loadFixtures('Posts');
$this->request->query = [
'page' => '3000000000000000000000000',
Expand Down

0 comments on commit 7a5e333

Please sign in to comment.