|
@@ -41,6 +41,9 @@ public class AuthorizeTests {
|
|
|
@Mock
|
|
|
private MethodInterceptorContext handleRole;
|
|
|
|
|
|
+ @Mock
|
|
|
+ private MethodInterceptorContext handleEmpty;
|
|
|
+
|
|
|
@Mock
|
|
|
private Authentication authentication;
|
|
|
|
|
@@ -78,6 +81,10 @@ public class AuthorizeTests {
|
|
|
when(handleRole.getParameter("paramEntity")).thenReturn(Optional.of(entity));
|
|
|
|
|
|
|
|
|
+ //mock MethodInterceptorContext
|
|
|
+ when(handleEmpty.getMethod()).thenReturn(TestClass.class.getMethod("handleEmpty"));
|
|
|
+ when(handleEmpty.getTarget()).thenReturn(testClass);
|
|
|
+
|
|
|
//过滤字段
|
|
|
AbstractDataAccessConfig fieldFilter = new SimpleFieldFilterDataAccessConfig("password", "salt");
|
|
|
fieldFilter.setAction(Permission.ACTION_QUERY);
|
|
@@ -120,6 +127,20 @@ public class AuthorizeTests {
|
|
|
authorizingContext.setDefinition(definition);
|
|
|
authorizingContext.setParamContext(queryById);
|
|
|
|
|
|
+ handler.handRBAC(authorizingContext);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testIssue164() {
|
|
|
+ DefaultAuthorizingHandler handler = new DefaultAuthorizingHandler();
|
|
|
+
|
|
|
+ AuthorizeDefinition definition = parser.parse(handleRole.getTarget().getClass(), handleRole.getMethod());
|
|
|
+
|
|
|
+ AuthorizingContext authorizingContext = new AuthorizingContext();
|
|
|
+ authorizingContext.setAuthentication(authentication);
|
|
|
+ authorizingContext.setDefinition(definition);
|
|
|
+ authorizingContext.setParamContext(handleRole);
|
|
|
+
|
|
|
try {
|
|
|
handler.handRBAC(authorizingContext);
|
|
|
Assert.fail("role access handle fail");
|
|
@@ -127,21 +148,20 @@ public class AuthorizeTests {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
@Test
|
|
|
- public void testIssue164() {
|
|
|
+ public void testIssue164Empty() {
|
|
|
DefaultAuthorizingHandler handler = new DefaultAuthorizingHandler();
|
|
|
|
|
|
- AuthorizeDefinition definition = parser.parse(handleRole.getTarget().getClass(), handleRole.getMethod());
|
|
|
+ AuthorizeDefinition definition = parser.parse(handleEmpty.getTarget().getClass(), handleEmpty.getMethod());
|
|
|
|
|
|
AuthorizingContext authorizingContext = new AuthorizingContext();
|
|
|
authorizingContext.setAuthentication(authentication);
|
|
|
authorizingContext.setDefinition(definition);
|
|
|
authorizingContext.setParamContext(handleRole);
|
|
|
-
|
|
|
handler.handRBAC(authorizingContext);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 测试数据权限控制s
|
|
|
*/
|
|
@@ -218,11 +238,16 @@ public class AuthorizeTests {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @Authorize(role = "admin")
|
|
|
+ @Authorize(role = "admin",merge = false)
|
|
|
public void handleRoleDeny(QueryParamEntity paramEntity) {
|
|
|
System.out.println(JSON.toJSON(paramEntity));
|
|
|
}
|
|
|
|
|
|
+ @Authorize(merge = false)
|
|
|
+ public void handleEmpty() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public interface TestClassSuper {
|