dify/api/tests/unit_tests/controllers/console
Jyong 79116d8c4b feat(knowledge-fs): scope dataset API keys by knowledge base type
Legacy knowledge bases (`datasets`) and KnowledgeFS spaces
(`knowledge_fs_control_spaces`) live in different tables, so a dataset API
key binding could only ever name a legacy dataset and the KnowledgeFS service
API never consulted bindings at all: a key scoped to specific knowledge bases
still reached every KnowledgeFS space in the workspace.

- Bindings carry a `resource_type` (`dataset` | `knowledge_fs_space`) and a
  nullable `control_space_id` (migration 9a4e7d1c2b60, existing rows stay
  `dataset`), with a CHECK that exactly one id column matches the type.
- `dataset_api_key_service` exposes the key scope by kind, validates and
  binds KnowledgeFS spaces (tenant-owned, not deleting/deleted), and cleans up
  keys scoped only to a space when its deletion is requested. The orphan-key
  cleanup is now NULL-safe so a space binding keeps a key alive.
- Legacy dataset routes only honour `dataset` bindings; the KnowledgeFS
  authorization service only honours `knowledge_fs_space` bindings and raises
  a scope error that the service API maps to 403 (unknown keys stay 401).
- Console key creation accepts `knowledge_space_ids`; list/create responses
  return them next to `dataset_ids`.
- The web scope picker lists KnowledgeFS spaces alongside legacy datasets
  when KnowledgeFS is enabled and submits the ids by kind; the scope column
  counts both.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015zw5G5SX3HmVfnZof6YWAc
2026-09-03 05:59:39 -04:00
..
agent refactor(api): decouple system features and web adapters (#40772) 2026-09-01 11:50:52 +00:00
app Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-02 10:31:10 +08:00
auth refactor(api): extract account login service and consolidate adapters (#41184) 2026-09-03 06:20:21 +00:00
billing test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
datasets feat(knowledge-fs): scope dataset API keys by knowledge base type 2026-09-03 05:59:39 -04:00
explore refactor(api): centralize remote file handling (#41627) 2026-09-03 06:00:13 +00:00
snippets refactor(models): pass session into Workflow accessors (#41464) 2026-08-29 14:28:15 +00:00
tag test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
workspace Merge remote-tracking branch 'origin/main' into deploy/konwledge 2026-09-03 16:32:30 +08:00
__init__.py feat: return data_source_info and data_source_detail_dict (#29912) 2026-01-05 11:04:03 +08:00
test_apikey.py fix(rbac): let agent.manage operate every agent page (#41583) 2026-09-02 01:45:42 +00:00
test_document_detail_api_data_source_info.py chore(api): align Python support with 3.12 (#34419) 2026-04-02 05:07:32 +00:00
test_extension.py refactor(console,web): dep-inject query params with @model_validate (#41646) 2026-09-03 01:50:22 +00:00
test_fastopenapi_init_validate.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_fastopenapi_setup.py test: centralize controller and storage config overrides (#40867) 2026-08-28 14:47:17 +00:00
test_fastopenapi_system.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_feature.py refactor(api): decouple system features and web adapters (#40772) 2026-09-01 11:50:52 +00:00
test_files_security.py refactor(console): inject file service (#41603) 2026-09-03 04:42:30 +00:00
test_files.py refactor(console): inject file service (#41603) 2026-09-03 04:42:30 +00:00
test_human_input_form.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_init_validate.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_notification.py refactor(api): decouple onboarding and notification services (#40759) 2026-08-31 04:37:07 +00:00
test_oauth_custom_client_permissions.py fix(api): protect custom OAuth client deletion (#40786) 2026-08-14 10:59:49 +00:00
test_onboarding.py refactor(api): decouple onboarding and notification services (#40759) 2026-08-31 04:37:07 +00:00
test_remote_files.py refactor(api): centralize remote file handling (#41627) 2026-09-03 06:00:13 +00:00
test_spec.py refactor(api): require active workspace in request context (#41280) 2026-09-02 06:54:47 +00:00
test_system.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_workflow_run_archive.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_workspace_account.py refactor(console): dep-inject account payloads with @model_validate (#41500) 2026-08-31 00:52:10 +00:00
test_workspace_credential_mutation_permissions.py chore: remove permission check (#41349) 2026-08-27 05:29:38 +00:00
test_workspace_members.py test: migrate auth and access controller ORM models to SQLite (#40572) 2026-08-21 06:12:29 +00:00
test_wraps.py refactor(api): decouple system features and web adapters (#40772) 2026-09-01 11:50:52 +00:00