mirror of
https://github.com/langgenius/dify.git
synced 2026-07-21 18:58:35 +08:00
fix: debug plugin permission setting not work (#38197)
This commit is contained in:
parent
03d59dba47
commit
4303103304
@ -128,7 +128,7 @@ describe('useReferenceSetting Hook', () => {
|
||||
expect(result.current.canDebugger).toBe(true)
|
||||
})
|
||||
|
||||
it('should ignore legacy admin permission for managers without plugin keys', () => {
|
||||
it('should allow debug for managers with legacy admin permission when RBAC is disabled', () => {
|
||||
vi.mocked(useAppContext).mockReturnValue({
|
||||
isCurrentWorkspaceManager: true,
|
||||
isCurrentWorkspaceOwner: false,
|
||||
@ -146,10 +146,10 @@ describe('useReferenceSetting Hook', () => {
|
||||
const { result } = renderHook(() => useReferenceSetting(PluginCategoryEnum.tool))
|
||||
|
||||
expect(result.current.canManagement).toBe(false)
|
||||
expect(result.current.canDebugger).toBe(false)
|
||||
expect(result.current.canDebugger).toBe(true)
|
||||
})
|
||||
|
||||
it('should ignore legacy admin permission for owners without plugin keys', () => {
|
||||
it('should allow debug for owners with legacy admin permission when RBAC is disabled', () => {
|
||||
vi.mocked(useAppContext).mockReturnValue({
|
||||
isCurrentWorkspaceManager: false,
|
||||
isCurrentWorkspaceOwner: true,
|
||||
@ -167,7 +167,30 @@ describe('useReferenceSetting Hook', () => {
|
||||
const { result } = renderHook(() => useReferenceSetting(PluginCategoryEnum.tool))
|
||||
|
||||
expect(result.current.canManagement).toBe(false)
|
||||
expect(result.current.canDebugger).toBe(false)
|
||||
expect(result.current.canDebugger).toBe(true)
|
||||
})
|
||||
|
||||
it('should allow debug for normal users when legacy debug permission is everyone and RBAC is disabled', () => {
|
||||
vi.mocked(useAppContext).mockReturnValue({
|
||||
isCurrentWorkspaceManager: false,
|
||||
isCurrentWorkspaceOwner: false,
|
||||
langGeniusVersionInfo: { current_version: '1.0.0', latest_version: '', version: '' },
|
||||
workspacePermissionKeys: ['plugin.install'],
|
||||
} as ReturnType<typeof useAppContext>)
|
||||
|
||||
vi.mocked(usePluginPermissionSettings).mockReturnValue({
|
||||
data: {
|
||||
install_permission: PermissionType.everyone,
|
||||
debug_permission: PermissionType.everyone,
|
||||
},
|
||||
} as ReturnType<typeof usePluginPermissionSettings>)
|
||||
|
||||
const { result } = renderHook(() => useReferenceSetting(PluginCategoryEnum.tool), {
|
||||
systemFeatures: { rbac_enabled: false },
|
||||
})
|
||||
|
||||
expect(result.current.canDebugPlugin).toBe(true)
|
||||
expect(result.current.canDebugger).toBe(true)
|
||||
})
|
||||
|
||||
it('should use plugin keys even when legacy admin permission is configured and RBAC is enabled', () => {
|
||||
|
||||
@ -52,7 +52,9 @@ export const usePluginSettingsAccess = () => {
|
||||
const canInstallPlugin = hasPermission(workspacePermissionKeys, 'plugin.install') && legacyCanInstallPlugin
|
||||
const canUpdatePlugin = hasPermission(workspacePermissionKeys, 'plugin.install') && legacyCanInstallPlugin
|
||||
const canDeletePlugin = hasPermission(workspacePermissionKeys, 'plugin.delete') && legacyCanInstallPlugin
|
||||
const canDebugPlugin = hasPermission(workspacePermissionKeys, 'plugin.debug') && legacyCanDebugPlugin
|
||||
const canDebugPlugin = rbacEnabled
|
||||
? hasPermission(workspacePermissionKeys, 'plugin.debug')
|
||||
: legacyCanDebugPlugin
|
||||
|
||||
return {
|
||||
permission: permissions,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user