Skip to content

Commit

Permalink
Adding test
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Polo committed Mar 4, 2016
1 parent c26e02b commit 66ee7e4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/Http/JwtMiddlewareSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ public function it_validates_the_token_and_passes_onto_the_next_middleware(JwtTo
$this->handle($request, $next)->shouldReturn('hello world');
}

public function it_validates_the_token_with_custom_header_key_and_passes_onto_the_next_middleware(JwtToken $token, Request $request)
{
$customHeader = 'X-Test-AuthHeader';
putenv("JWT_HEADER=$customHeader");

$request->header($customHeader)->willReturn('Bearer foo_token');

$token->setToken('foo_token')->willReturn($token);
$token->validateOrFail()->shouldBeCalled()->willReturn(true);

$next = function() { return 'hello world'; };
$this->handle($request, $next)->shouldReturn('hello world');

putenv('JWT_HEADER=');
}

public function it_throws_an_exception_if_the_token_is_invalid(JwtToken $token, Request $request)
{
$request->header('Authorization')->willReturn(null);
Expand Down

0 comments on commit 66ee7e4

Please sign in to comment.