dify/api/tests/unit_tests/controllers/console/datasets
yungle246 be6612f454 feat: allow knowledge base API keys to be scoped to a single dataset
Reintroduce the nullable api_tokens.dataset_id column (dropped in 2e9819ca5b28)
so dataset API keys can opt into per-knowledge-base scoping:

- NULL dataset_id keeps today's workspace-wide behavior, so every existing key
  and the existing /datasets/api-keys create route are unchanged.
- validate_dataset_token rejects a bound key for any other dataset, and for
  endpoints that carry no dataset id (e.g. list-all), with 403.
- CachedApiToken carries dataset_id with a None default so cache entries
  written before deploy keep deserializing.
- The per-dataset console routes in apikey.py (previously dead code that 500ed
  on a missing ApiToken.dataset_id) now create bound keys; their list returns
  bound keys plus workspace keys so the dataset page shows the full access
  picture.
- Frontend: the knowledge base API access popover gains an API keys entry; the
  secret key modal accepts datasetId, shows a scope column, and offers a
  workspace / this-knowledge-base scope choice on create. New strings are
  localized for all 23 locales.
2026-06-11 11:41:47 +09:00
..
rag_pipeline fix: validate conversation variable description length to prevent varchar(255) truncation error (#33038) 2026-06-10 07:28:12 +00:00
__init__.py fix: increase name length limit in ExternalDatasetCreatePayload (#31000) 2026-01-14 22:13:53 +09:00
test_data_source.py refactor(api): migrate tenant/user via DI for several endpoints (#37026) 2026-06-04 05:52:59 +00:00
test_datasets_document_download.py refactor(api): migrate tenant/user via DI for several endpoints (#37026) 2026-06-04 05:52:59 +00:00
test_datasets_document.py refactor(api): migrate tenant/user via DI for several endpoints (#37026) 2026-06-04 05:52:59 +00:00
test_datasets_segments.py refactor(api): migrate tenant/user via DI for several endpoints (#37026) 2026-06-04 05:52:59 +00:00
test_datasets.py feat: allow knowledge base API keys to be scoped to a single dataset 2026-06-11 11:41:47 +09:00
test_external_dataset_payload.py fix: increase name length limit in ExternalDatasetCreatePayload (#31000) 2026-01-14 22:13:53 +09:00
test_external.py refactor(api): migrate tenant/user via DI for several endpoints (#37026) 2026-06-04 05:52:59 +00:00
test_hit_testing_base.py refactor(api): migrate console/service_api.dataset.hit_testing to BaseModel (#36533) 2026-05-27 06:51:42 +00:00
test_hit_testing.py refactor(api): migrate console/service_api.dataset.hit_testing to BaseModel (#36533) 2026-05-27 06:51:42 +00:00
test_metadata.py refactor: inject current user into user-only controllers (#36754) 2026-05-31 15:03:15 +00:00
test_website.py chore: add type to test (#36324) 2026-05-18 08:47:47 +00:00
test_wraps.py chore: add Type to test (#35942) 2026-05-09 03:16:22 +00:00