From 3ff328c9618038715d59c80ad3dbcaa5fc912e00 Mon Sep 17 00:00:00 2001 From: rickchengx <38122586+rickchengx@users.noreply.github.com> Date: Wed, 2 Nov 2022 11:20:00 +0800 Subject: [PATCH] [Improvement-12623][Permission]Remove the unused projectIds in operationPermissionCheck() (#12624) --- .../ResourcePermissionCheckService.java | 2 +- .../ResourcePermissionCheckServiceImpl.java | 2 +- .../api/service/impl/BaseServiceImpl.java | 4 +-- .../ResourcePermissionCheckServiceTest.java | 4 +-- .../api/service/AccessTokenServiceTest.java | 4 +-- .../api/service/AlertGroupServiceTest.java | 12 ++++----- .../AlertPluginInstanceServiceTest.java | 6 ++--- .../api/service/DataSourceServiceTest.java | 4 +-- .../service/DqExecuteResultServiceTest.java | 2 +- .../api/service/DqRuleServiceTest.java | 2 +- .../api/service/EnvironmentServiceTest.java | 6 ++--- .../api/service/MonitorServiceTest.java | 2 +- .../api/service/ProjectServiceTest.java | 26 ++++++++----------- .../api/service/QueueServiceTest.java | 4 +-- .../api/service/TaskGroupServiceTest.java | 12 ++++----- .../api/service/TenantServiceTest.java | 6 ++--- .../api/service/UdfFuncServiceTest.java | 20 +++++++------- .../api/service/UsersServiceTest.java | 4 +-- .../api/service/WorkerGroupServiceTest.java | 16 ++++++------ 19 files changed, 67 insertions(+), 71 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckService.java index 9f5fde0501..20df36fa03 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckService.java @@ -50,7 +50,7 @@ public interface ResourcePermissionCheckService { * @param logger * @return */ - boolean operationPermissionCheck(Object authorizationType, Object[] projectIds, Integer userId, + boolean operationPermissionCheck(Object authorizationType, Integer userId, String permissionKey, Logger logger); /** diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java index bf3d48e4cf..3f4cb01f40 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java @@ -122,7 +122,7 @@ public class ResourcePermissionCheckServiceImpl } @Override - public boolean operationPermissionCheck(Object authorizationType, Object[] projectIds, Integer userId, + public boolean operationPermissionCheck(Object authorizationType, Integer userId, String permissionKey, Logger logger) { User user = processService.getUserById(userId); if (user == null) { diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java index d04d87a9b4..8c8a54fe1a 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java @@ -177,8 +177,8 @@ public class BaseServiceImpl implements BaseService { */ @Override public boolean canOperatorPermissions(User user, Object[] ids, AuthorizationType type, String permissionKey) { - boolean operationPermissionCheck = resourcePermissionCheckService.operationPermissionCheck(type, - type.equals(AuthorizationType.PROJECTS) ? ids : null, user.getId(), permissionKey, logger); + boolean operationPermissionCheck = + resourcePermissionCheckService.operationPermissionCheck(type, user.getId(), permissionKey, logger); boolean resourcePermissionCheck = resourcePermissionCheckService.resourcePermissionCheck(type, ids, user.getUserType().equals(UserType.ADMIN_USER) ? 0 : user.getId(), logger); return operationPermissionCheck && resourcePermissionCheck; diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java index 4ce733a37d..2bef0d5e65 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceTest.java @@ -79,10 +79,10 @@ public class ResourcePermissionCheckServiceTest { User user = new User(); user.setId(1); resourcePermissionCheckServices.setApplicationContext(context); - Assertions.assertFalse(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, null, + Assertions.assertFalse(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, user.getId(), null, logger)); String sourceUrl = "/tmp/"; - Assertions.assertFalse(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, null, + Assertions.assertFalse(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, user.getId(), sourceUrl, logger)); } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java index 60c4ad43f3..28eb2bea08 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java @@ -143,7 +143,7 @@ public class AccessTokenServiceTest { User userLogin = new User(); userLogin.setId(1); userLogin.setUserType(UserType.ADMIN_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, 1, ACCESS_TOKEN_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 0, baseServiceLogger)).thenReturn(true); @@ -171,7 +171,7 @@ public class AccessTokenServiceTest { User user = new User(); user.setId(1); user.setUserType(UserType.ADMIN_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, 1, ACCESS_TOKEN_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java index e35678cc7d..76a456c35f 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java @@ -130,7 +130,7 @@ public class AlertGroupServiceTest { user.setUserType(UserType.ADMIN_USER); user.setId(0); // success - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, user.getId(), ALERT_GROUP_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_GROUP, null, user.getId(), baseServiceLogger)).thenReturn(true); @@ -148,7 +148,7 @@ public class AlertGroupServiceTest { User user = new User(); user.setUserType(UserType.ADMIN_USER); user.setId(0); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, user.getId(), ALERT_GROUP_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_GROUP, null, user.getId(), baseServiceLogger)).thenReturn(true); @@ -170,7 +170,7 @@ public class AlertGroupServiceTest { user.setUserType(UserType.ADMIN_USER); // not exist user.setUserType(UserType.ADMIN_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, user.getId(), ALERT_GROUP_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_GROUP, new Object[]{1}, 0, baseServiceLogger)).thenReturn(true); @@ -192,7 +192,7 @@ public class AlertGroupServiceTest { User user = new User(); user.setId(0); user.setUserType(UserType.ADMIN_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, user.getId(), ALERT_GROUP_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_GROUP, new Object[]{2}, user.getId(), baseServiceLogger)).thenReturn(true); @@ -210,7 +210,7 @@ public class AlertGroupServiceTest { user.setId(0); // no operate user.setUserType(UserType.GENERAL_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, user.getId(), ALERT_GROUP_DELETE, baseServiceLogger)).thenReturn(true); Map result = alertGroupService.delAlertgroupById(user, 1); logger.info(result.toString()); @@ -219,7 +219,7 @@ public class AlertGroupServiceTest { // not exist user.setUserType(UserType.ADMIN_USER); user.setId(0); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_GROUP, user.getId(), ALERT_GROUP_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_GROUP, new Object[]{2}, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java index 85522d3b56..3f767c6ce4 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java @@ -173,7 +173,7 @@ public class AlertPluginInstanceServiceTest { public void testCreate() { Mockito.when(alertPluginInstanceMapper.existInstanceName("test")).thenReturn(true); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_PLUGIN_INSTANCE, - null, 1, ALART_INSTANCE_CREATE, baseServiceLogger)).thenReturn(true); + 1, ALART_INSTANCE_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_PLUGIN_INSTANCE, null, 0, baseServiceLogger)).thenReturn(true); Map result = alertPluginInstanceService.create(user, 1, "test", uiParams); @@ -189,7 +189,7 @@ public class AlertPluginInstanceServiceTest { List ids = Arrays.asList("11,2,3", null, "98,1"); Mockito.when(alertGroupMapper.queryInstanceIdsList()).thenReturn(ids); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_PLUGIN_INSTANCE, - null, 1, ALERT_PLUGIN_DELETE, baseServiceLogger)).thenReturn(true); + 1, ALERT_PLUGIN_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_PLUGIN_INSTANCE, null, 0, baseServiceLogger)).thenReturn(true); Map result = alertPluginInstanceService.delete(user, 1); @@ -205,7 +205,7 @@ public class AlertPluginInstanceServiceTest { public void testUpdate() { Mockito.when(alertPluginInstanceMapper.updateById(Mockito.any())).thenReturn(0); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ALERT_PLUGIN_INSTANCE, - null, 1, ALERT_PLUGIN_UPDATE, baseServiceLogger)).thenReturn(true); + 1, ALERT_PLUGIN_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ALERT_PLUGIN_INSTANCE, null, 0, baseServiceLogger)).thenReturn(true); Map result = alertPluginInstanceService.update(user, 1, "testUpdate", uiParams); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java index 0230d6c058..216d3650b6 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataSourceServiceTest.java @@ -239,7 +239,7 @@ public class DataSourceServiceTest { loginUser.setUserType(UserType.ADMIN_USER); loginUser.setId(1); dataSource.setId(22); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), DATASOURCE_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, new Object[]{dataSource.getId()}, 0, baseServiceLogger)).thenReturn(true); @@ -254,7 +254,7 @@ public class DataSourceServiceTest { loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); int userId = 3; - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATASOURCE, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATASOURCE, null, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java index 86d2b6bbeb..6bfff0f6a1 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqExecuteResultServiceTest.java @@ -83,7 +83,7 @@ public class DqExecuteResultServiceTest { User loginUser = new User(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATA_QUALITY, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATA_QUALITY, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATA_QUALITY, null, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java index 06f2cdd3a8..703c5d3a6a 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java @@ -138,7 +138,7 @@ public class DqRuleServiceTest { User loginUser = new User(); loginUser.setId(1); loginUser.setUserType(UserType.ADMIN_USER); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATA_QUALITY, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.DATA_QUALITY, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.DATA_QUALITY, null, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/EnvironmentServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/EnvironmentServiceTest.java index 99775f1e90..822a251d7f 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/EnvironmentServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/EnvironmentServiceTest.java @@ -98,7 +98,7 @@ public class EnvironmentServiceTest { @Test public void testCreateEnvironment() { User loginUser = getGeneralUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ENVIRONMENT, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ENVIRONMENT, loginUser.getId(), ENVIRONMENT_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ENVIRONMENT, null, 0, baseServiceLogger)).thenReturn(true); @@ -142,7 +142,7 @@ public class EnvironmentServiceTest { @Test public void testUpdateEnvironmentByCode() { User loginUser = getGeneralUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ENVIRONMENT, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ENVIRONMENT, loginUser.getId(), ENVIRONMENT_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ENVIRONMENT, null, 0, baseServiceLogger)).thenReturn(true); @@ -238,7 +238,7 @@ public class EnvironmentServiceTest { @Test public void testDeleteEnvironmentByCode() { User loginUser = getGeneralUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ENVIRONMENT, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ENVIRONMENT, loginUser.getId(), ENVIRONMENT_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ENVIRONMENT, null, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/MonitorServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/MonitorServiceTest.java index f9cb08a6a6..50fe445752 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/MonitorServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/MonitorServiceTest.java @@ -132,7 +132,7 @@ public class MonitorServiceTest { } private void mockPermissionCheck(String permissionKey, boolean result) { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.MONITOR, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.MONITOR, 1, permissionKey, serviceLogger)).thenReturn(result); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.MONITOR, null, 0, serviceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java index f2b3d4d16b..9fefc7dcc9 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProjectServiceTest.java @@ -105,7 +105,7 @@ public class ProjectServiceTest { User loginUser = getLoginUser(); loginUser.setId(1); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, 1, PROJECT_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, null, 1, baseServiceLogger)).thenReturn(true); @@ -149,7 +149,6 @@ public class ProjectServiceTest { project.setUserId(1); loginUser.setUserType(UserType.ADMIN_USER); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{project.getId()}, project.getUserId(), PROJECT, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{project.getId()}, @@ -168,7 +167,6 @@ public class ProjectServiceTest { project1.setUserId(2); loginUser.setUserType(UserType.GENERAL_USER); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{project.getId()}, loginUser.getId(), PROJECT, baseServiceLogger)).thenReturn(true); result2 = projectService.checkProjectAndAuth(loginUser, project1, projectCode, PROJECT); Assertions.assertEquals(Status.USER_NO_OPERATION_PROJECT_PERM, result2.get(Constants.STATUS)); @@ -191,7 +189,6 @@ public class ProjectServiceTest { tempUser.setId(Integer.MAX_VALUE); tempUser.setUserType(UserType.GENERAL_USER); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{project.getId()}, tempUser.getId(), null, baseServiceLogger)).thenReturn(true); boolean checkResult = projectService.hasProjectAndPerm(tempUser, project, result, null); logger.info(result.toString()); @@ -202,7 +199,6 @@ public class ProjectServiceTest { project.setUserId(1); loginUser.setUserType(UserType.ADMIN_USER); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{project.getId()}, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{project.getId()}, @@ -251,7 +247,6 @@ public class ProjectServiceTest { tempUser.setId(Integer.MAX_VALUE); tempUser.setUserType(UserType.GENERAL_USER); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{project.getId()}, tempUser.getId(), null, baseServiceLogger)).thenReturn(true); boolean checkResult = projectService.hasProjectAndWritePerm(tempUser, project, result); logger.info(result.toString()); @@ -262,7 +257,6 @@ public class ProjectServiceTest { project.setUserId(1); loginUser.setUserType(UserType.ADMIN_USER); Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{project.getId()}, loginUser.getId(), null, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{project.getId()}, @@ -276,9 +270,10 @@ public class ProjectServiceTest { public void testDeleteProject() { User loginUser = getLoginUser(); Mockito.when(projectMapper.queryByCode(1L)).thenReturn(getProject()); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{1}, loginUser.getId(), - PROJECT_DELETE, baseServiceLogger)).thenReturn(true); + Mockito.when( + resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, loginUser.getId(), + PROJECT_DELETE, baseServiceLogger)) + .thenReturn(true); // PROJECT_NOT_FOUND Result result = projectService.deleteProject(loginUser, 11L); logger.info(result.toString()); @@ -319,9 +314,10 @@ public class ProjectServiceTest { loginUser.setId(1); Project project = getProject(); project.setCode(2L); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, - new Object[]{1}, loginUser.getId(), - PROJECT_UPDATE, baseServiceLogger)).thenReturn(true); + Mockito.when( + resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, loginUser.getId(), + PROJECT_UPDATE, baseServiceLogger)) + .thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, loginUser.getId(), baseServiceLogger)).thenReturn(true); @@ -391,7 +387,7 @@ public class ProjectServiceTest { // SUCCESS loginUser.setUserType(UserType.ADMIN_USER); Mockito.when( - resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, + resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, loginUser.getId(), PROJECT, baseServiceLogger)) .thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, @@ -405,7 +401,7 @@ public class ProjectServiceTest { loginUser.setId(1); loginUser.setUserType(UserType.GENERAL_USER); Mockito.when( - resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, + resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.PROJECTS, loginUser.getId(), PROJECT, baseServiceLogger)) .thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.PROJECTS, new Object[]{1}, diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/QueueServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/QueueServiceTest.java index 6eaad37be4..0379797626 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/QueueServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/QueueServiceTest.java @@ -128,7 +128,7 @@ public class QueueServiceTest { @Test public void testCreateQueue() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.QUEUE, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.QUEUE, getLoginUser().getId(), YARN_QUEUE_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.QUEUE, null, 0, baseServiceLogger)).thenReturn(true); @@ -155,7 +155,7 @@ public class QueueServiceTest { Mockito.when(queueMapper.selectById(1)).thenReturn(getQUEUE()); Mockito.when(queueMapper.existQueue(EXISTS, null)).thenReturn(true); Mockito.when(queueMapper.existQueue(null, EXISTS)).thenReturn(true); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.QUEUE, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.QUEUE, getLoginUser().getId(), YARN_QUEUE_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.QUEUE, new Object[]{0}, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskGroupServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskGroupServiceTest.java index e3074bc128..7d475a621e 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskGroupServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TaskGroupServiceTest.java @@ -117,7 +117,7 @@ public class TaskGroupServiceTest { @Test public void forceStartTask() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, loginUser.getId(), ApiFuncIdentificationConstant.TASK_GROUP_QUEUE_START, serviceLogger)) .thenReturn(false); Map objectMap = taskGroupService.forceStartTask(loginUser, 1); @@ -127,7 +127,7 @@ public class TaskGroupServiceTest { @Test public void modifyPriority() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, loginUser.getId(), ApiFuncIdentificationConstant.TASK_GROUP_QUEUE_PRIORITY, serviceLogger)) .thenReturn(false); Map objectMap = taskGroupService.modifyPriority(loginUser, 1, 1); @@ -138,7 +138,7 @@ public class TaskGroupServiceTest { public void testCreate() { User loginUser = getLoginUser(); TaskGroup taskGroup = getTaskGroup(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, loginUser.getId(), ApiFuncIdentificationConstant.TASK_GROUP_CREATE, serviceLogger)).thenReturn(true); Mockito.when(taskGroupMapper.insert(taskGroup)).thenReturn(1); Mockito.when(taskGroupMapper.queryByName(loginUser.getId(), taskGroupName)).thenReturn(null); @@ -162,7 +162,7 @@ public class TaskGroupServiceTest { IPage page = new Page<>(1, 10); page.setRecords(getList()); User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, loginUser.getId(), ApiFuncIdentificationConstant.TASK_GROUP_VIEW, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.TASK_GROUP, null, 0, serviceLogger)).thenReturn(true); @@ -183,7 +183,7 @@ public class TaskGroupServiceTest { taskGroup.setStatus(Flag.YES.getCode()); // Task group status error - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, loginUser.getId(), ApiFuncIdentificationConstant.TASK_GROUP_EDIT, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.TASK_GROUP, null, 0, serviceLogger)).thenReturn(true); @@ -204,7 +204,7 @@ public class TaskGroupServiceTest { Mockito.when(taskGroupMapper.selectById(1)).thenReturn(taskGroup); // close failed - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TASK_GROUP, loginUser.getId(), ApiFuncIdentificationConstant.TASK_GROUP_CLOSE, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.TASK_GROUP, null, 0, serviceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java index 32f24a69f9..99570372e5 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java @@ -110,7 +110,7 @@ public class TenantServiceTest { User loginUser = getLoginUser(); Mockito.when(tenantMapper.existTenant(tenantCode)).thenReturn(true); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TENANT, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TENANT, loginUser.getId(), TENANT_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.TENANT, null, 0, baseServiceLogger)).thenReturn(true); @@ -182,7 +182,7 @@ public class TenantServiceTest { @Test public void testUpdateTenant() throws Exception { Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TENANT, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TENANT, getLoginUser().getId(), TENANT_UPDATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.TENANT, null, 0, baseServiceLogger)).thenReturn(true); @@ -204,7 +204,7 @@ public class TenantServiceTest { @Test public void testDeleteTenantById() throws Exception { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TENANT, null, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.TENANT, getLoginUser().getId(), TENANT_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.TENANT, null, 0, baseServiceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java index 9f12cc23c2..d707b02410 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UdfFuncServiceTest.java @@ -104,7 +104,7 @@ public class UdfFuncServiceTest { @Test public void testCreateUdfFunction() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_CREATE, serviceLogger)).thenReturn(true); Mockito.when( resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, null, 0, serviceLogger)) @@ -141,7 +141,7 @@ public class UdfFuncServiceTest { @Test public void testQueryUdfFuncDetail() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{2}, 0, serviceLogger)).thenReturn(true); @@ -151,7 +151,7 @@ public class UdfFuncServiceTest { logger.info(result.toString()); Assertions.assertTrue(Status.RESOURCE_NOT_EXIST.getCode() == result.getCode()); // success - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{1}, 0, serviceLogger)).thenReturn(true); @@ -167,7 +167,7 @@ public class UdfFuncServiceTest { Mockito.when(udfFuncMapper.selectUdfById(1)).thenReturn(getUdfFunc()); // UDF_FUNCTION_NOT_EXIST - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_UPDATE, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{12}, 0, serviceLogger)).thenReturn(true); @@ -187,7 +187,7 @@ public class UdfFuncServiceTest { Assertions.assertTrue(Status.HDFS_NOT_STARTUP.getCode() == result.getCode()); // RESOURCE_NOT_EXIST - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_UPDATE, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{11}, 0, serviceLogger)).thenReturn(true); @@ -200,7 +200,7 @@ public class UdfFuncServiceTest { Assertions.assertTrue(Status.RESOURCE_NOT_EXIST.getCode() == result.getCode()); // success - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_UPDATE, serviceLogger)).thenReturn(true); try { Mockito.when(storageOperate.exists("")).thenReturn(true); @@ -219,7 +219,7 @@ public class UdfFuncServiceTest { @Test public void testQueryUdfFuncListPaging() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true); Mockito.when( resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, null, 0, serviceLogger)) @@ -240,7 +240,7 @@ public class UdfFuncServiceTest { @Test public void testQueryUdfFuncList() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true); Mockito.when( resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, null, 1, serviceLogger)) @@ -263,7 +263,7 @@ public class UdfFuncServiceTest { @Test public void testDelete() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_DELETE, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, new Object[]{122}, 0, serviceLogger)).thenReturn(true); @@ -278,7 +278,7 @@ public class UdfFuncServiceTest { @Test public void testVerifyUdfFuncByName() { - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.UDF, 1, ApiFuncIdentificationConstant.UDF_FUNCTION_VIEW, serviceLogger)).thenReturn(true); Mockito.when( resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.UDF, null, 0, serviceLogger)) diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java index 8a9c6506be..4694d0858e 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java @@ -256,7 +256,7 @@ public class UsersServiceTest { user.setUserType(UserType.ADMIN_USER); user.setId(1); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, 1, USER_MANAGER, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 0, serviceLogger)).thenReturn(false); @@ -265,7 +265,7 @@ public class UsersServiceTest { Assertions.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); // success - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.ACCESS_TOKEN, 1, USER_MANAGER, serviceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.ACCESS_TOKEN, null, 0, serviceLogger)).thenReturn(true); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java index 6013a0226b..70135d468b 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkerGroupServiceTest.java @@ -103,7 +103,7 @@ public class WorkerGroupServiceTest { @Test public void giveNoPermission_whenSaveWorkerGroup_expectNoOperation() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_CREATE, baseServiceLogger)).thenReturn(false); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(false); @@ -116,7 +116,7 @@ public class WorkerGroupServiceTest { @Test public void giveNullName_whenSaveWorkerGroup_expectNAME_NULL() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true); @@ -129,7 +129,7 @@ public class WorkerGroupServiceTest { @Test public void giveSameUserName_whenSaveWorkerGroup_expectNAME_EXIST() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true); @@ -147,7 +147,7 @@ public class WorkerGroupServiceTest { @Test public void giveInvalidAddress_whenSaveWorkerGroup_expectADDRESS_INVALID() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true); @@ -169,7 +169,7 @@ public class WorkerGroupServiceTest { @Test public void giveValidWorkerGroup_whenSaveWorkerGroup_expectSuccess() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_CREATE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true); @@ -219,7 +219,7 @@ public class WorkerGroupServiceTest { @Test public void giveNotExistsWorkerGroup_whenDeleteWorkerGroupById_expectNotExists() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true); @@ -233,7 +233,7 @@ public class WorkerGroupServiceTest { @Test public void giveRunningProcess_whenDeleteWorkerGroupById_expectFailed() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true); @@ -255,7 +255,7 @@ public class WorkerGroupServiceTest { @Test public void giveValidParams_whenDeleteWorkerGroupById_expectSuccess() { User loginUser = getLoginUser(); - Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, + Mockito.when(resourcePermissionCheckService.operationPermissionCheck(AuthorizationType.WORKER_GROUP, 1, WORKER_GROUP_DELETE, baseServiceLogger)).thenReturn(true); Mockito.when(resourcePermissionCheckService.resourcePermissionCheck(AuthorizationType.WORKER_GROUP, null, 1, baseServiceLogger)).thenReturn(true);