diff --git a/apps/node_man/handlers/meta.py b/apps/node_man/handlers/meta.py index 5a96ceea1..e335fc7fa 100644 --- a/apps/node_man/handlers/meta.py +++ b/apps/node_man/handlers/meta.py @@ -21,6 +21,7 @@ from apps.node_man.handlers.cmdb import CmdbHandler from apps.node_man.handlers.install_channel import InstallChannelHandler from apps.node_man.models import GsePackages +from apps.node_man.permissions.package_manage import PackageManagePermission from apps.node_man.serializers.package_manage import FilterConditionPackageSerializer from apps.utils import APIModel @@ -473,6 +474,9 @@ def fetch_os_type_children(os_types: Tuple = constants.OsType): @staticmethod def fetch_agent_pkg_manager_children(): + if not PackageManagePermission().has_permission(None, None): + return {"message": "该用户不是管理员"} + version_set, tag_name_description_map, creator_set, is_ready_set = set(), dict(), set(), set() gse_packages = FilterConditionPackageSerializer(GsePackages.objects.all(), many=True).data for gse_package in gse_packages: diff --git a/apps/node_man/tests/test_views/test_package_manage_views.py b/apps/node_man/tests/test_views/test_package_manage_views.py index e1a0fc5ca..f865a957a 100644 --- a/apps/node_man/tests/test_views/test_package_manage_views.py +++ b/apps/node_man/tests/test_views/test_package_manage_views.py @@ -13,7 +13,7 @@ ) from apps.core.tag.models import Tag from apps.node_man.handlers.meta import MetaHandler -from apps.node_man.models import GsePackages, GsePackageDesc +from apps.node_man.models import GsePackageDesc, GsePackages from apps.node_man.tests.utils import create_gse_package @@ -31,7 +31,7 @@ def clear_agent_data(cls): def test_list(self): # 和之前的builder.make加起来100 - create_gse_package(99) + create_gse_package(99, start_id=1000) result = self.client.get(path="/api/agent/package/") self.assertEqual(result["result"], True)