mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
feat(rbac): agent RBAC/ACL scenes and resource-locator check bundles (#41768)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
60e983c493
commit
86134ea99e
152 files changed
+5360
-3405
No files matched your search
@@ -107,7 +107,7 @@ describe('CommonLayoutHydrationBoundary', () => {
|
||||
credits: 200,
|
||||
})
|
||||
mocks.permissionQueryFn.mockResolvedValue({
|
||||
workspace: { permission_keys: ['agent.manage'] },
|
||||
workspace: { permission_keys: ['agent.acl.preview'] },
|
||||
app: { default_permission_keys: [], overrides: [] },
|
||||
dataset: { default_permission_keys: [], overrides: [] },
|
||||
})
|
||||
|
||||
@@ -25,7 +25,7 @@ vi.mock('@/context/permission-state', async () => {
|
||||
vi.mock('@/features/agent-v2/permissions', () => {
|
||||
return {
|
||||
useCanManageAgents: () =>
|
||||
mockConsoleStateReader().workspacePermissionKeys.includes('agent.manage'),
|
||||
mockConsoleStateReader().workspacePermissionKeys.includes('agent.acl.preview'),
|
||||
}
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ type ConsoleStateFixture = {
|
||||
const baseContext: ConsoleStateFixture = {
|
||||
isLoadingCurrentWorkspace: false,
|
||||
isLoadingWorkspacePermissionKeys: false,
|
||||
workspacePermissionKeys: ['agent.manage'],
|
||||
workspacePermissionKeys: ['agent.acl.preview'],
|
||||
currentWorkspace: {
|
||||
id: 'workspace-1',
|
||||
},
|
||||
@@ -88,7 +88,7 @@ describe('AgentsAccessGuard', () => {
|
||||
expect(mockReplace).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('redirects to /apps without agent.manage', async () => {
|
||||
it('redirects to /apps without agent.acl.preview', async () => {
|
||||
setConsoleState({ workspacePermissionKeys: ['dataset.create_and_management'] })
|
||||
|
||||
render(
|
||||
@@ -103,7 +103,7 @@ describe('AgentsAccessGuard', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('renders children with agent.manage', () => {
|
||||
it('renders children with agent.acl.preview', () => {
|
||||
render(
|
||||
<AgentsAccessGuard>
|
||||
<div>agents</div>
|
||||
|
||||
@@ -464,7 +464,7 @@ const ownerWorkspacePermissionKeys = [
|
||||
'dataset.external.connect',
|
||||
'tool.manage',
|
||||
'mcp.manage',
|
||||
'agent.manage',
|
||||
'agent.acl.preview',
|
||||
'skill.view',
|
||||
]
|
||||
|
||||
@@ -750,10 +750,12 @@ describe('MainNav', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('hides the roster entry when the user lacks agent.manage', () => {
|
||||
it('hides the roster entry when the user lacks agent.acl.preview', () => {
|
||||
mockConsoleState.current = {
|
||||
...consoleState,
|
||||
workspacePermissionKeys: ownerWorkspacePermissionKeys.filter((key) => key !== 'agent.manage'),
|
||||
workspacePermissionKeys: ownerWorkspacePermissionKeys.filter(
|
||||
(key) => key !== 'agent.acl.preview',
|
||||
),
|
||||
}
|
||||
|
||||
renderMainNav()
|
||||
@@ -761,7 +763,7 @@ describe('MainNav', () => {
|
||||
expect(screen.queryByRole('link', { name: /Agents/ })).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows the roster entry when the user has agent.manage', () => {
|
||||
it('shows the roster entry when the user has agent.acl.preview', () => {
|
||||
renderMainNav()
|
||||
|
||||
expect(screen.getByRole('link', { name: /Agents/ })).toBeInTheDocument()
|
||||
@@ -898,7 +900,7 @@ describe('MainNav', () => {
|
||||
isCurrentWorkspaceEditor: false,
|
||||
isCurrentWorkspaceManager: false,
|
||||
isCurrentWorkspaceOwner: false,
|
||||
workspacePermissionKeys: ['app_library.access', 'tool.manage', 'agent.manage'],
|
||||
workspacePermissionKeys: ['app_library.access', 'tool.manage', 'agent.acl.preview'],
|
||||
}
|
||||
|
||||
renderMainNav({ branding: { enabled: false } })
|
||||
|
||||
@@ -63,7 +63,7 @@ describe('AgentSelectorContent', () => {
|
||||
mocks.agents = []
|
||||
})
|
||||
|
||||
it('offers the Agent Console link with agent.manage', async () => {
|
||||
it('offers the Agent Console link with agent.acl.preview', async () => {
|
||||
await renderSelector({ onStartFromScratch: vi.fn() })
|
||||
|
||||
const listbox = screen.getByRole('listbox')
|
||||
@@ -99,7 +99,7 @@ describe('AgentSelectorContent', () => {
|
||||
expect(listbox.querySelector('.overflow-y-auto')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('hides the Agent Console link without agent.manage', async () => {
|
||||
it('hides the Agent Console link without agent.acl.preview', async () => {
|
||||
mocks.canManageAgents = false
|
||||
|
||||
await renderSelector()
|
||||
@@ -107,7 +107,7 @@ describe('AgentSelectorContent', () => {
|
||||
expect(screen.queryByText(manageInConsoleLabel)).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('keeps start from scratch without agent.manage', async () => {
|
||||
it('keeps start from scratch without agent.acl.preview', async () => {
|
||||
mocks.canManageAgents = false
|
||||
|
||||
await renderSelector({ onStartFromScratch: vi.fn() })
|
||||
|
||||
Reference in new issue
Block a user