Skip to content

Commit

Permalink
Add test for cookie and regexp (see #171) (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuupola committed Sep 30, 2019
1 parent 7875188 commit 0b08866
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/JwtAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,31 @@ public function testShouldReturn200WithTokenFromCookie()
$this->assertEquals("Success", $response->getBody());
}

public function testShouldReturn200WithTokenFromBearerCookie()
{
$request = (new ServerRequestFactory)
->createServerRequest("GET", "https://example.com/api")
->withCookieParams(["nekot" => "Bearer " . self::$acmeToken]);

$default = function (ServerRequestInterface $request) {
$response = (new ResponseFactory)->createResponse();
$response->getBody()->write("Success");
return $response;
};

$collection = new MiddlewareCollection([
new JwtAuthentication([
"secret" => "supersecretkeyyoushouldnotcommittogithub",
"cookie" => "nekot",
])
]);

$response = $collection->dispatch($request, $default);

$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals("Success", $response->getBody());
}


public function testShouldReturn200WithSecretArray()
{
Expand Down

0 comments on commit 0b08866

Please sign in to comment.