mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
refactor(api): establish dataset application boundaries (#41729)
Co-authored-by: Jyong <jyong@dify.ai>
This commit is contained in:
1 parent
c005932db9
commit
a67cd87eb0
417 files changed
+30522
-23751
No files matched your search
+3
-5
@@ -9,7 +9,7 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from models.source import DataSourceApiKeyAuthBinding
|
||||
from services.auth.errors import DataSourceApiKeyAuthCredentialValidationError
|
||||
from services.entities.data_source_api_key_auth_entities import (
|
||||
from services.data_source.entities.api_key_auth import (
|
||||
DataSourceApiKeyAuthBindingCreate,
|
||||
DataSourceApiKeyAuthCredentials,
|
||||
)
|
||||
@@ -82,9 +82,7 @@ def test_create_binding_successful(
|
||||
"credentials": {"auth_type": "bearer", "config": {"api_key": "secret"}},
|
||||
}
|
||||
|
||||
with patch(
|
||||
"services.auth.data_source_api_key_auth_service.DataSourceApiKeyAuthService.create_binding"
|
||||
) as create_auth:
|
||||
with patch("services.data_source.auth.api_key_service.DataSourceApiKeyAuthService.create_binding") as create_auth:
|
||||
response = test_client_with_containers.post(
|
||||
"/console/api/api-key-auth/data-source/binding",
|
||||
json=payload,
|
||||
@@ -111,7 +109,7 @@ def test_create_binding_failure(
|
||||
account, _tenant = create_console_account_and_tenant(db_session_with_containers)
|
||||
|
||||
with patch(
|
||||
"services.auth.data_source_api_key_auth_service.DataSourceApiKeyAuthService.create_binding",
|
||||
"services.data_source.auth.api_key_service.DataSourceApiKeyAuthService.create_binding",
|
||||
side_effect=DataSourceApiKeyAuthCredentialValidationError("Credentials rejected"),
|
||||
):
|
||||
response = test_client_with_containers.post(
|
||||
|
||||
+5
-5
@@ -7,8 +7,8 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from extensions.ext_application_services import ApplicationServices
|
||||
from models.source import DataSourceOauthBinding
|
||||
from services.data_source_oauth_service import InvalidDataSourceOAuthProviderError
|
||||
from services.entities.data_source_oauth_entities import DataSourceOAuthCallback
|
||||
from services.data_source.entities.oauth import DataSourceOAuthCallback
|
||||
from services.data_source.oauth_service import InvalidDataSourceOAuthProviderError
|
||||
from tests.test_containers_integration_tests.controllers.console.helpers import (
|
||||
authenticate_console_client,
|
||||
create_console_account_and_tenant,
|
||||
@@ -17,7 +17,7 @@ from tests.test_containers_integration_tests.controllers.console.helpers import
|
||||
|
||||
def _services(service: MagicMock) -> MagicMock:
|
||||
services = create_autospec(ApplicationServices, instance=True, spec_set=True)
|
||||
services.resolve_data_source_oauth.return_value = service
|
||||
services.data_sources.resolve_oauth.return_value = service
|
||||
return services
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ def test_get_oauth_url_invalid_provider(
|
||||
|
||||
service = MagicMock()
|
||||
services = _services(service)
|
||||
services.resolve_data_source_oauth.side_effect = InvalidDataSourceOAuthProviderError
|
||||
services.data_sources.resolve_oauth.side_effect = InvalidDataSourceOAuthProviderError
|
||||
with patch(
|
||||
"controllers.console.auth.data_source_oauth.application_services",
|
||||
return_value=services,
|
||||
@@ -99,7 +99,7 @@ def test_oauth_callback_missing_code(test_client_with_containers: FlaskClient) -
|
||||
def test_oauth_callback_invalid_provider(test_client_with_containers: FlaskClient) -> None:
|
||||
service = MagicMock()
|
||||
services = _services(service)
|
||||
services.resolve_data_source_oauth.side_effect = InvalidDataSourceOAuthProviderError
|
||||
services.data_sources.resolve_oauth.side_effect = InvalidDataSourceOAuthProviderError
|
||||
with patch(
|
||||
"controllers.console.auth.data_source_oauth.application_services",
|
||||
return_value=services,
|
||||
|
||||
Reference in new issue
Block a user