Search in sources :

Example 1 with JWTExpiredException

use of com.auth0.jwt.JWTExpiredException in project survey by markoniemi.

the class JwtTokenTest method verifyTokenWithExpiredToken.

@Test
public void verifyTokenWithExpiredToken() {
    try {
        User user = new User("username", "password", "email", Role.ROLE_USER);
        Map<String, Object> payload = new HashMap<String, Object>();
        payload.put("username", user.getUsername());
        JwtToken token = new JwtToken(payload, 1);
        Thread.sleep(1000);
        token.verifyToken();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof JWTExpiredException);
    }
}
Also used : User(org.survey.model.user.User) HashMap(java.util.HashMap) JWTExpiredException(com.auth0.jwt.JWTExpiredException) JWTExpiredException(com.auth0.jwt.JWTExpiredException) JWTVerifyException(com.auth0.jwt.JWTVerifyException) Test(org.junit.Test)

Aggregations

JWTExpiredException (com.auth0.jwt.JWTExpiredException)1 JWTVerifyException (com.auth0.jwt.JWTVerifyException)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 User (org.survey.model.user.User)1