{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/9570","labels_url":"https://api.github.com/repos/laravel/framework/issues/9570/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/9570/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/9570/events","html_url":"https://github.com/laravel/framework/issues/9570","id":93989389,"number":9570,"title":"Laravel TestCase not sending Authorization headers","user":{"login":"gvhuyssteen","id":1265536,"avatar_url":"https://avatars.githubusercontent.com/u/1265536?v=3","gravatar_id":"","url":"https://api.github.com/users/gvhuyssteen","html_url":"https://github.com/gvhuyssteen","followers_url":"https://api.github.com/users/gvhuyssteen/followers","following_url":"https://api.github.com/users/gvhuyssteen/following{/other_user}","gists_url":"https://api.github.com/users/gvhuyssteen/gists{/gist_id}","starred_url":"https://api.github.com/users/gvhuyssteen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvhuyssteen/subscriptions","organizations_url":"https://api.github.com/users/gvhuyssteen/orgs","repos_url":"https://api.github.com/users/gvhuyssteen/repos","events_url":"https://api.github.com/users/gvhuyssteen/events{/privacy}","received_events_url":"https://api.github.com/users/gvhuyssteen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-09T08:27:22Z","updated_at":"2015-07-09T08:30:20Z","closed_at":"2015-07-09T08:29:52Z","body":"Duplicate of issue on StackOverflow.\r\n\r\nhttp://stackoverflow.com/questions/31309098/laravel-testcase-not-sending-authorization-headers-jwt-token\r\n\r\n**Summary**\r\n\r\nWe are writing unit tests to test the creation and invalidation of JWT tokens and receiving a \"The token could not be parsed from the request\" error back from a JWTException every time we try to JWTAuth::invalidate the token.\r\n\r\n**Description**\r\n\r\nInside our controller, to create a user token, we are passing through the user email address and then returning the JWT token.\r\n\r\nAfterwards, we are destroying the token by invalidating it using invalidateToken method and passing through the token by sending an Authorization header.\r\n\r\n```\r\npublic function invalidateToken()\r\n{\r\n    try {\r\n        JWTAuth::invalidate(JWTAuth::getToken());\r\n        return Response::json(['status' => 'success'], 200);\r\n    } catch (JWTException $e) {\r\n        return Response::json(['status' => 'error', 'message' => $e->getMessage()], 401);\r\n    }\r\n}\r\n```\r\nThis works perfectly by using Postman as well as PHPStorms Restful client.\r\n\r\nWhen we try to write a test for this method, we are faced with an error response and a \"The token could not be parsed from the request\" error message.\r\n\r\nOur test is as follow:\r\n\r\n```\r\npublic function testInvalidateToken()\r\n{\r\n    $createUserToken = $this->call('POST', '/token/create', ['email' => 'test@test.com']);\r\n    $user = $this->parseJson($createUserToken);\r\n\r\n    $response = $this->call('POST', '/token/invalidate',\r\n        [/* params */], [/* cookies */], [/* files */], ['HTTP_Authorization' => 'Bearer '.$user->token]);\r\n\r\n    // var_dump($user->token);\r\n    // die();\r\n\r\n    $data = $this->parseJson($response);\r\n    $this->assertEquals($data->status, 'success');\r\n    $this->assertEquals($data->status, '200');\r\n}\r\n```\r\nWe are using Laravel 5.1 (which has the cookies as a parameter before the server parameter)\r\n\r\nPHP version 5.6.10\r\n\r\nPHPUnit 3.7.28"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/119873436","html_url":"https://github.com/laravel/framework/issues/9570#issuecomment-119873436","issue_url":"https://api.github.com/repos/laravel/framework/issues/9570","id":119873436,"user":{"login":"GrahamCampbell","id":2829600,"avatar_url":"https://avatars.githubusercontent.com/u/2829600?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamCampbell","html_url":"https://github.com/GrahamCampbell","followers_url":"https://api.github.com/users/GrahamCampbell/followers","following_url":"https://api.github.com/users/GrahamCampbell/following{/other_user}","gists_url":"https://api.github.com/users/GrahamCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamCampbell/subscriptions","organizations_url":"https://api.github.com/users/GrahamCampbell/orgs","repos_url":"https://api.github.com/users/GrahamCampbell/repos","events_url":"https://api.github.com/users/GrahamCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamCampbell/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T08:30:20Z","updated_at":"2015-07-09T08:30:20Z","body":"Only phpunit 4.7+ is supported. Also, please ask on the forums."}}