### Question:
AuthService implements IAuthService { @Override public boolean invalidJwtAccessToken(String authentication) { boolean invalid = Boolean.TRUE; try { getJwt(authentication); invalid = Boolean.FALSE; } catch (SignatureException | ExpiredJwtException | MalformedJwtException ex) { log.error("user token error :{}", ex.getMessage()); } return invalid; }  @Override Result authenticate(String authentication, String url, String method); @Override boolean ignoreAuthentication(String url); @Override boolean hasPermission(Result authResult); @Override boolean hasPermission(String authentication, String url, String method); @Override Jws<Claims> getJwt(String jwtToken); @Override boolean invalidJwtAccessToken(String authentication);  }### Answer:
@Test public void testInvalidJwtAccessToken_假如有人获取用户token_当输入token去掉了signature_那么返回true表示token无效() { String authentication = BEARER + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX25hbWUiOiJ6aG91dGFvbyIsInNjb3BlIjpbInJlYWQiXSwib3JnYW5pemF0aW9uIjoiemhvdXRhb28iLCJleHAiOjE1Mjc0NTM5NDQsImF1dGhvcml0aWVzIjpbIkFETUlOIiwiSVQiXSwianRpIjoiZTZiNzM5ZmUtYWEzZC00Y2RmLWIxZjUtNzZkMmVlMjU0ODU1IiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnQifQ"; Assert.assertTrue(authService.invalidJwtAccessToken(authentication)); }
@Test public void testInvalidJwtAccessToken_假如授权服务通过给定密钥生成了token_当输入该token组成的authentication_那么返回false表示token有效() { Assert.assertFalse(authService.invalidJwtAccessToken(BEARER + VALID_TOKEN)); }
@Test public void testInvalidJwtAccessToken_假如_当输入随机字串_那么返回true表示token无效() { String authentication = BEARER + "im random string"; Assert.assertTrue(authService.invalidJwtAccessToken(authentication)); }
@Test public void testInvalidJwtAccessToken_假如有人获取用户token_当输入篡改过playload中信息_那么返回true表示token无效() { String authentication = BEARER + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.111eyJGc2VyX25hbWUiOiJ6aG91dGFvbyIsInNjb3BlIjpbInJlYWQiXSwib3JnYW5pemF0aW9uIjoiemhvdXRhb28iLCJleHAiOjE1Mjc0NTM5NDQsImF1dGhvcml0aWVzIjpbIkFETUlOIiwiSVQiXSwianRpIjoiZTZiNzM5ZmUtYWEzZC00Y2RmLWIxZjUtNzZkMmVlMjU0ODU1IiwiY2xpZW50X2lkIjoidGVzdF9jbGllbnQifQ.l6PQrs98zT40H6Ad4NHE7NSXyeWnMn-ZhURw3zO-EfE"; Assert.assertTrue(authService.invalidJwtAccessToken(authentication)); }