Laravel TestCase not sending Authorization headers (JWT Token)

前端 未结 4 1105
故里飘歌
故里飘歌 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:23

    I tried the following code in Controller constructor:

    if (env('APP_ENV') == 'testing' 
            && array_key_exists("HTTP_AUTHORIZATION", request()->server())) {
        JWTAuth::setRequest(\Route::getCurrentRequest());
    } 
    

提交回复
热议问题