### Question:
AuthService implements IAuthService { @Override public boolean hasPermission(Result authResult) { return authResult.isSuccess() && (boolean) authResult.getData(); }  @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 boolean invalidJwtAccessToken(String authentication); @Override Jwt getJwt(String authentication);  }### Answer:
@Test public void testHasPermission_假如用户authentication正确且有对请求url有权限_当用户请求该url_那么返回成功有权限() { when(authProvider.auth(BEARER + VALID_TOKEN, "/users", "POST")).thenReturn(Result.success(true)); Assert.assertTrue(authService.hasPermission(BEARER + VALID_TOKEN, "/users", "POST")); }
@Test public void testHasPermission_假如用户authentication正确且有对请求url只有POST权限_当用户请求该url的GET_那么返回成功无权限() { when(authProvider.auth(BEARER + VALID_TOKEN, "/users", "GET")).thenReturn(Result.success(false)); Assert.assertFalse(authService.hasPermission(BEARER + VALID_TOKEN, "/users", "GET")); }
@Test public void testHasPermission_假如_当传入无效token_那么返回无权限() { Assert.assertFalse(authService.hasPermission("invalid token", "/users", "POST")); }