fix jwt bug

This commit is contained in:
Looly
2021-06-18 15:59:20 +08:00
parent 7ead906910
commit 86d711cc03
10 changed files with 167 additions and 37 deletions

View File

@@ -1,5 +1,6 @@
package cn.hutool.jwt;
import cn.hutool.core.util.StrUtil;
import cn.hutool.jwt.signers.JWTSignerUtil;
import org.junit.Assert;
import org.junit.Test;
@@ -73,4 +74,14 @@ public class JWTTest {
jwt.sign();
}
@Test
public void verifyTest(){
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9." +
"eyJ1c2VyX25hbWUiOiJhZG1pbiIsInNjb3BlIjpbImFsbCJdLCJleHAiOjE2MjQwMDQ4MjIsInVzZXJJZCI6MSwiYXV0aG9yaXRpZXMiOlsiUk9MRV_op5LoibLkuozlj7ciLCJzeXNfbWVudV8xIiwiUk9MRV_op5LoibLkuIDlj7ciLCJzeXNfbWVudV8yIl0sImp0aSI6ImQ0YzVlYjgwLTA5ZTctNGU0ZC1hZTg3LTVkNGI5M2FhNmFiNiIsImNsaWVudF9pZCI6ImhhbmR5LXNob3AifQ." +
"aixF1eKlAKS_k3ynFnStE7-IRGiD5YaqznvK2xEjBew";
final boolean verify = JWT.of(token).setKey(StrUtil.utf8Bytes("123456")).verify();
Assert.assertTrue(verify);
}
}