Skip to content
Permalink
Browse files

Adding test for host url redirect.

  • Loading branch information...
dereuromark committed Sep 8, 2016
1 parent cfadb8f commit ffa464d06e94b118604a64349a36d51fe9ec753e
Showing with 21 additions and 3 deletions.
  1. +21 −3 tests/TestCase/Controller/Component/AuthComponentTest.php
@@ -23,8 +23,8 @@
use Cake\Network\Request;
use Cake\Network\Response;
use Cake\ORM\TableRegistry;
use Cake\Routing\Route\InflectedRoute;
use Cake\Routing\Router;
use Cake\Routing\Route\InflectedRoute;
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
use TestApp\Controller\AuthTestController;
@@ -1326,10 +1326,10 @@ public function testRedirectSet()
public function testRedirectQueryStringRead()
{
$this->Auth->config('loginAction', ['controller' => 'users', 'action' => 'login']);
$this->Auth->request->query = ['redirect' => '/users/home'];
$this->Auth->request->query = ['redirect' => '/users/custom'];
$result = $this->Auth->redirectUrl();
$this->assertEquals('/users/home', $result);
$this->assertEquals('/users/custom', $result);
}
/**
@@ -1368,6 +1368,24 @@ public function testRedirectQueryStringReadEqualToLoginAction()
$this->assertEquals('/users/home', $result);
}
/**
* Tests that redirect does not return loginAction if that contains a host,
* instead loginRedirect should be used.
*
* @return void
*/
public function testRedirectQueryStringInvalid()
{
$this->Auth->config([
'loginAction' => ['controller' => 'users', 'action' => 'login'],
'loginRedirect' => ['controller' => 'users', 'action' => 'home']
]);
$this->Auth->request->query = ['redirect' => 'http://some.domain.example/users/login'];
$result = $this->Auth->redirectUrl();
$this->assertEquals('/users/home', $result);
}
/**
* test that the returned URL doesn't contain the base URL.
*

0 comments on commit ffa464d

Please sign in to comment.
You can’t perform that action at this time.