-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #2704: ensure route registered via $routes->cli() not accessible via web browser even autoroute is true #2707
Conversation
|
… accessible via web browser even autoroute is true
@MGatner I've added feature test case for demoing 404 page thrown when open cli routes from http |
it seems need some autoload tweak for testing "App" namespace for feature test demo, I will re-check again. |
The test tweak implemented. |
@@MGatner travis build green 🎉 |
{ | ||
if (is_string($route)) | ||
{ | ||
if (strpos($route, $controller . '::' . $methodName) === 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using strpos
is on purpose to handle parameter, eg: controller::method/$1:
$routes->cli('hello/(:any)', 'Commands\Hello::index/$1');
I've added feature test case for demoing 404 page thrown when open parameterized cli routes from http |
…meterized and non parameterized
… controller name only
I've added condition check for default method index when routing defined in cli as controller name only, which fallback to method index, eg: $routes->cli('hello', 'Hello'); |
I've added condition for multi case, eg: capitalized controller or method in URI with compare with strtolower of the controller and method. |
travis build green 🎉 |
*/ | ||
public function testOpenCliRoutesFromHttpGot404($from, $to, $httpGet) | ||
{ | ||
$this->expectException(PageNotFoundException::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I add the following test case,
the test passes because there is no App\Controllers\Hello
class.
'parameterized method cli' => [
'hello/(:segment)',
'Hello::$1',
'Hello/index',
],
*/ | ||
public function testOpenCliRoutesFromHttpGot404($from, $to, $httpGet) | ||
{ | ||
$this->expectException(PageNotFoundException::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests pass because there is no App\Controllers\Hello
class.
Fix #2704: ensure route registered via $routes->cli() not accessible via web browser even autoroute is true.
Checklist: