2016-06-17 2 views
0

Tymon JWT pkg을 사용합니다. 문제는 항상 응답으로 응답 : 토큰이 만료되었습니다. $token 내가 테스트를하지만 항상 만료 ... 누구나 문제가 뭔지 알아 토케을 생성유닛 테스트 반환 만료 된 JWT 토큰 [Laravel 5.2]

public function test_store_games() 
    { 

      $token = Auth::tokenById(1); 

     $response = $this->post(Config::get('settings.api') . 'games', [ 
      'name' => 'test123', 
      'category' => 'test'],['HTTP_Authorization' => 'Bearer ' . $token]); 

     $this->assertRequestOk(); 
    } 

바르 : 여기

테스트입니까?

답변

1

컨트롤러에 컨트롤러를 추가하면 변경됩니까?

function __construct() 
    { 
     // for testing only, otherwise JWTAuth::parseToken() fails 
     if (env('APP_ENV') == 'testing' 
       && array_key_exists("HTTP_AUTHORIZATION", request()->server())) { 
      JWTAuth::setRequest(\Route::getCurrentRequest()); 
     } 
    } 
0

당신은 jwt.php 설정 파일에 'TTL'=> 60을 유효 기간을 설정할 수 있습니다. 기본적으로 1 시간은 시간을 늘리기 위해 변경됩니다.