Skip to content
Browse files
testing section for jwt auth
  • Loading branch information
rmannibucau committed Aug 28, 2018
1 parent b76696b commit ef8ded2c7801d193ef7e79494bcab8941ff4173d
Showing 1 changed file with 37 additions and 0 deletions.
@@ -34,3 +34,40 @@ It provides a way to validate and interact with a JWT metadata.

=== Test a service layer (without servlet layer)

In 1.0.0 you have to mock a request and use the Geronimo JWT Auth extension
to mock the JWT context. In 1.0.1 this is simplified thanks to  `TokenAccessor`
abstraction which requires only to provide the "current" token.
In this same version a token can be instantiated thanks to `JwtParser` (previously you had to
implement `JsonWebToken` yourself).

Here is a test - assuming you have CDI injections, which is the case with Arquillian, Meecrowave etc...:

public class DemoTest {
private GeronimoJwtAuthExtension extension;
private JwtParser parser;
void testJwtService() throws ServletException, IOException {
() -> parser.createToken(
.add("iss", "")
() -> {
// do test here

TIP: if you use that a lot you will likely want to wrap it in a JUnit or TestNG extension.

0 comments on commit ef8ded2

Please sign in to comment.