tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.3k stars 1.54k forks source link

Problem with Laravel HTTP tests writing #1895

Open VladPavliuk opened 5 years ago

VladPavliuk commented 5 years ago

Subject of the issue

Hi! I tried to add a few test methods each of which tests - is user's auth status. After successfully received jwt token I've faced with the next problem - I get false each time when JWTAuth::getToken() is called in the tested method though, Authorization header with Bearer {token} value is present in the request to the tested api endpoint.

Your environment

Q A
Bug? yes
New Feature? no
Framework Laravel
Framework version 5.7.*
Package version ^0.5.12
PHP version 7.5.1

Steps to reproduce

  1. Create an empty test method in Laravel with the following content:

image

  1. Try to call JWTAuth::getToken() in the tested method (in this case it's 'store' method in 'ProductsController'). image

  2. Launch the test method: ./vendor/bin/phpunit --filter myTest

Expected behaviour

I would like to see the token which I've put into request 'Authorization' header in my tested method (in this case it's 'store' method in 'ProductsController') if JWTAuth::getToken() is called there.

Actual behaviour

I get false when JWTAuth::getToken() is called in my tested method.

stale[bot] commented 3 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.