dify/api/tests/unit_tests/controllers/console/datasets
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
..
rag_pipeline test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
__init__.py fix: increase name length limit in ExternalDatasetCreatePayload (#31000) 2026-01-14 22:13:53 +09:00
test_data_source_notion_apis.py test: migrate residual controller ORM identities to real models (#40661) 2026-08-13 05:18:44 +00:00
test_data_source.py test: migrate RAG variable controller sessions and ORM models to SQLite (#40609) 2026-08-25 06:20:48 +00:00
test_datasets_document_download.py test: migrate dataset download sessions and ORM models to SQLite (#40630) 2026-09-01 09:28:50 +00:00
test_datasets_document.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_datasets_segments.py test: migrate console dataset segment sessions and ORM models to SQLite (#40515) 2026-08-21 06:50:14 +00:00
test_datasets.py feat(knowledge-fs): scope dataset API keys by knowledge base type 2026-09-03 05:59:39 -04:00
test_external_dataset_payload.py test: use sqlite3 session in test_external_dataset_service (#38696) 2026-08-06 08:27:37 +00:00
test_external.py fix(api): remove unsafe Bedrock test endpoint (#40742) 2026-08-13 19:47:13 +00:00
test_hit_testing_base.py refactor: explicit DB session propagation across backend paths (#38559) 2026-07-15 06:48:28 +00:00
test_hit_testing.py refactor: thread explicit sessions through app retrieval paths (#38309) 2026-07-02 17:00:47 +00:00
test_metadata.py test: enforce centralized config overrides (#40869) 2026-08-29 14:05:35 +00:00
test_website.py chore: dep inject for model in website crawl api (#40156) 2026-08-07 12:40:12 +00:00
test_wraps.py test: migrate controller sessions to SQLite (#40083) 2026-08-11 08:29:40 +00:00