Laravel TestCase not sending Authorization headers (JWT Token)

前端 未结 4 1081
故里飘歌
故里飘歌 2021-01-18 02:46

Summary

We are writing unit tests to test the creation and invalidation of JWT tokens and receiving a \"The token could not be parsed from the reque

4条回答
  •  不知归路
    2021-01-18 03:33

    We faced a similar issue when writing tests on Laravel 4.2, exceptionally we added this lines when running the application on the testing environment:

     // This will only work when unit testing
            if ((\App::environment() == 'testing') && array_key_exists("HTTP_Authorization",  LRequest::server())) {
                $headers['Authorization'] = LRequest::server()["HTTP_Authorization"];
            }
    

提交回复
热议问题