|
|
@@ -8,7 +8,7 @@ import com.citu.framework.security.core.LoginUser;
|
|
|
import com.citu.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
import com.citu.framework.test.core.ut.BaseMockitoUnitTest;
|
|
|
import com.citu.module.system.api.permission.PermissionApi;
|
|
|
-import com.citu.module.system.api.permission.dto.DeptDataPermissionRespDTO;
|
|
|
+import com.citu.module.system.api.permission.dto.DataPermissionRespDTO;
|
|
|
import net.sf.jsqlparser.expression.Alias;
|
|
|
import net.sf.jsqlparser.expression.Expression;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
@@ -98,14 +98,14 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
.setUserType(UserTypeEnum.ADMIN.getValue()));
|
|
|
securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser);
|
|
|
// mock 方法(DeptDataPermissionRespDTO)
|
|
|
- DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO().setAll(true);
|
|
|
+ DataPermissionRespDTO deptDataPermission = new DataPermissionRespDTO().setAll(true);
|
|
|
when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission));
|
|
|
|
|
|
// 调用
|
|
|
Expression expression = rule.getExpression(tableName, tableAlias);
|
|
|
// 断言
|
|
|
assertNull(expression);
|
|
|
- assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class));
|
|
|
+ assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DataPermissionRespDTO.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -121,14 +121,14 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
.setUserType(UserTypeEnum.ADMIN.getValue()));
|
|
|
securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser);
|
|
|
// mock 方法(DeptDataPermissionRespDTO)
|
|
|
- DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO();
|
|
|
+ DataPermissionRespDTO deptDataPermission = new DataPermissionRespDTO();
|
|
|
when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission));
|
|
|
|
|
|
// 调用
|
|
|
Expression expression = rule.getExpression(tableName, tableAlias);
|
|
|
// 断言
|
|
|
assertEquals("null = null", expression.toString());
|
|
|
- assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class));
|
|
|
+ assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DataPermissionRespDTO.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -144,15 +144,15 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
.setUserType(UserTypeEnum.ADMIN.getValue()));
|
|
|
securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser);
|
|
|
// mock 方法(DeptDataPermissionRespDTO)
|
|
|
- DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO()
|
|
|
- .setDeptIds(SetUtils.asSet(10L, 20L)).setSelf(true);
|
|
|
+ DataPermissionRespDTO deptDataPermission = new DataPermissionRespDTO()
|
|
|
+ .setDataIds(SetUtils.asSet(10L, 20L)).setSelf(true);
|
|
|
when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission));
|
|
|
|
|
|
// 调用
|
|
|
Expression expression = rule.getExpression(tableName, tableAlias);
|
|
|
// 断言
|
|
|
assertSame(EXPRESSION_NULL, expression);
|
|
|
- assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class));
|
|
|
+ assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DataPermissionRespDTO.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -168,7 +168,7 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
.setUserType(UserTypeEnum.ADMIN.getValue()));
|
|
|
securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser);
|
|
|
// mock 方法(DeptDataPermissionRespDTO)
|
|
|
- DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO()
|
|
|
+ DataPermissionRespDTO deptDataPermission = new DataPermissionRespDTO()
|
|
|
.setSelf(true);
|
|
|
when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission));
|
|
|
// 添加 user 字段配置
|
|
|
@@ -178,7 +178,7 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
Expression expression = rule.getExpression(tableName, tableAlias);
|
|
|
// 断言
|
|
|
assertEquals("u.id = 1", expression.toString());
|
|
|
- assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class));
|
|
|
+ assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DataPermissionRespDTO.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -194,8 +194,8 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
.setUserType(UserTypeEnum.ADMIN.getValue()));
|
|
|
securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser);
|
|
|
// mock 方法(DeptDataPermissionRespDTO)
|
|
|
- DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO()
|
|
|
- .setDeptIds(CollUtil.newLinkedHashSet(10L, 20L));
|
|
|
+ DataPermissionRespDTO deptDataPermission = new DataPermissionRespDTO()
|
|
|
+ .setDataIds(CollUtil.newLinkedHashSet(10L, 20L));
|
|
|
when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission));
|
|
|
// 添加 dept 字段配置
|
|
|
rule.addDeptColumn("t_user", "dept_id");
|
|
|
@@ -204,7 +204,7 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
Expression expression = rule.getExpression(tableName, tableAlias);
|
|
|
// 断言
|
|
|
assertEquals("u.dept_id IN (10, 20)", expression.toString());
|
|
|
- assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class));
|
|
|
+ assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DataPermissionRespDTO.class));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -220,8 +220,8 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
.setUserType(UserTypeEnum.ADMIN.getValue()));
|
|
|
securityFrameworkUtilsMock.when(SecurityFrameworkUtils::getLoginUser).thenReturn(loginUser);
|
|
|
// mock 方法(DeptDataPermissionRespDTO)
|
|
|
- DeptDataPermissionRespDTO deptDataPermission = new DeptDataPermissionRespDTO()
|
|
|
- .setDeptIds(CollUtil.newLinkedHashSet(10L, 20L)).setSelf(true);
|
|
|
+ DataPermissionRespDTO deptDataPermission = new DataPermissionRespDTO()
|
|
|
+ .setDataIds(CollUtil.newLinkedHashSet(10L, 20L)).setSelf(true);
|
|
|
when(permissionApi.getDeptDataPermission(same(1L))).thenReturn(success(deptDataPermission));
|
|
|
// 添加 user 字段配置
|
|
|
rule.addUserColumn("t_user", "id");
|
|
|
@@ -232,7 +232,7 @@ class DeptDataPermissionRuleTest extends BaseMockitoUnitTest {
|
|
|
Expression expression = rule.getExpression(tableName, tableAlias);
|
|
|
// 断言
|
|
|
assertEquals("(u.dept_id IN (10, 20) OR u.id = 1)", expression.toString());
|
|
|
- assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DeptDataPermissionRespDTO.class));
|
|
|
+ assertSame(deptDataPermission, loginUser.getContext(DeptDataPermissionRule.CONTEXT_KEY, DataPermissionRespDTO.class));
|
|
|
}
|
|
|
}
|
|
|
|