mirror of
https://github.com/langgenius/dify.git
synced 2026-05-31 22:26:19 +08:00
Co-authored-by: GareArc <garethcxy@dify.ai> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: L1nSn0w <l1nsn0w@qq.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: gigglewang <gigglewang@dify.ai> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
"""Unit tests for the openapi bearer-scope catalog and TokenKind registry."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
|
|
def test_apps_read_permitted_external_scope_present():
|
|
from libs.oauth_bearer import Scope
|
|
|
|
assert Scope.APPS_READ_PERMITTED_EXTERNAL.value == "apps:read:permitted-external"
|
|
|
|
|
|
def test_dfoe_token_kind_carries_apps_read_permitted_external():
|
|
from libs.oauth_bearer import Scope, build_registry
|
|
|
|
registry = build_registry(MagicMock(), MagicMock())
|
|
dfoe = next(k for k in registry.kinds() if k.prefix == "dfoe_")
|
|
assert Scope.APPS_READ_PERMITTED_EXTERNAL in dfoe.scopes
|
|
|
|
|
|
def test_dfoa_token_kind_does_not_carry_apps_read_permitted_external():
|
|
"""dfoa_ relies on Scope.FULL umbrella; the explicit permitted scope
|
|
is reserved for dfoe_."""
|
|
from libs.oauth_bearer import Scope, build_registry
|
|
|
|
registry = build_registry(MagicMock(), MagicMock())
|
|
dfoa = next(k for k in registry.kinds() if k.prefix == "dfoa_")
|
|
assert Scope.APPS_READ_PERMITTED_EXTERNAL not in dfoa.scopes
|