Unable to find the controller for path /login_check. The route is wrongly configured.
trq opened this issue · 2 comments
trq commented
Using the flex
branch I am getting the error mentioned above. I know it's probably a misconfiguration rather than an issue with lexik-jwt
, but I'm trying to work from this example and can't find a solution to this problem.
I have a fork here which adds a commit to get some tests up and running proving the above issue.
See trq@3e9d2e6
POST /register
works as expected, but I am unable to get a token using /login_check
.
Any ideas what the issue might be?
Thanks
trq commented
Just some example output:
bin/phpunit
#!/usr/bin/env php
PHPUnit 6.5.8 by Sebastian Bergmann and contributors.
Testing Project Test Suite
2018-05-23T22:44:57+00:00 [error] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "Unable to find the controller for path "/login_check". The route is wrongly configured." at /Volumes/Code/lexik-jwt-authentication-sandbox/vendor/symfony/http-kernel/HttpKernel.php line 133
E 1 / 1 (100%)NULL
Time: 2.08 seconds, Memory: 26.00MB
There was 1 error:
1) App\Tests\TokenTest::canAccessAEndpointRequiringAuthentication
TypeError: trim() expects parameter 1 to be string, null given
/Volumes/Code/lexik-jwt-authentication-sandbox/tests/TokenClientTrait.php:57
/Volumes/Code/lexik-jwt-authentication-sandbox/tests/TokenTest.php:29
ERRORS!
Tests: 1, Assertions: 1, Errors: 1.
You can see the error within the var_export
here
chalasr commented
Hey,
json_login
expects a JSON request (it is skipped otherwise) while your test sends form data.
here is a patch that should make it work:
diff --git a/tests/TokenClientTrait.php b/tests/TokenClientTrait.php
index 228cff0..3ea7bf8 100644
--- a/tests/TokenClientTrait.php
+++ b/tests/TokenClientTrait.php
@@ -42,10 +42,13 @@ trait TokenClientTrait
$client->request(
'POST',
'/login_check',
- [
- '_username' => $username,
- '_password' => 'password',
- ]
+ [],
+ [],
+ ['CONTENT_TYPE' => 'application/json'],
+<<<JSON
+ {"username": "$username", "password": "password"}
+JSON
+
);
$data = json_decode($client->getResponse()->getContent(), true);