refactor: move settings and secrets stores to app_server (#14165)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Tim O'Farrell
2026-04-27 13:54:33 -06:00
committed by GitHub
parent 3a40ecb931
commit 9e3aed7f53
21 changed files with 36 additions and 36 deletions

View File

@@ -9,6 +9,7 @@ from fastapi import FastAPI
from fastapi.testclient import TestClient
from pydantic import SecretStr
from openhands.app_server.secrets.file_secrets_store import FileSecretsStore
from openhands.app_server.secrets.secrets_router import (
router as secrets_router,
)
@@ -19,7 +20,6 @@ from openhands.integrations.provider import (
)
from openhands.storage import get_file_store
from openhands.storage.data_models.secrets import Secrets
from openhands.storage.secrets.file_secrets_store import FileSecretsStore
@pytest.fixture
@@ -45,7 +45,7 @@ def file_secrets_store(temp_dir):
file_store = get_file_store('local', temp_dir)
store = FileSecretsStore(file_store)
with patch(
'openhands.storage.secrets.file_secrets_store.FileSecretsStore.get_instance',
'openhands.app_server.secrets.file_secrets_store.FileSecretsStore.get_instance',
AsyncMock(return_value=store),
):
yield store

View File

@@ -6,6 +6,9 @@ from fastapi import Request
from fastapi.testclient import TestClient
from pydantic import SecretStr
from openhands.app_server.secrets.secrets_store import SecretsStore
from openhands.app_server.settings.file_settings_store import FileSettingsStore
from openhands.app_server.settings.settings_store import SettingsStore
from openhands.integrations.provider import ProviderToken, ProviderType
from openhands.integrations.service_types import UserGitInfo
from openhands.sdk.llm import LLM
@@ -19,9 +22,6 @@ from openhands.server.user_auth.user_auth import UserAuth
from openhands.storage.data_models.secrets import Secrets
from openhands.storage.data_models.settings import Settings
from openhands.storage.memory import InMemoryFileStore
from openhands.storage.secrets.secrets_store import SecretsStore
from openhands.storage.settings.file_settings_store import FileSettingsStore
from openhands.storage.settings.settings_store import SettingsStore
_EXPOSE = {'expose_secrets': True}
@@ -103,7 +103,7 @@ def test_client():
return_value=MockUserAuth(),
),
patch(
'openhands.storage.settings.file_settings_store.FileSettingsStore.get_instance',
'openhands.app_server.settings.file_settings_store.FileSettingsStore.get_instance',
AsyncMock(return_value=FileSettingsStore(InMemoryFileStore())),
),
):

View File

@@ -4,12 +4,12 @@ from unittest.mock import AsyncMock, patch
import pytest
from openhands.app_server.settings.file_settings_store import FileSettingsStore
from openhands.core.config.mcp_config import MCPConfig, RemoteMCPServer
from openhands.sdk.llm import LLM
from openhands.sdk.settings import AgentSettings
from openhands.server.user_auth.default_user_auth import DefaultUserAuth
from openhands.storage.data_models.settings import Settings
from openhands.storage.settings.file_settings_store import FileSettingsStore
def _sdk_mcp_config(settings: Settings) -> MCPConfig | None:

View File

@@ -7,15 +7,15 @@ from fastapi import Request
from fastapi.testclient import TestClient
from pydantic import SecretStr
from openhands.app_server.secrets.secrets_store import SecretsStore
from openhands.app_server.settings.file_settings_store import FileSettingsStore
from openhands.app_server.settings.settings_store import SettingsStore
from openhands.integrations.provider import ProviderToken, ProviderType
from openhands.integrations.service_types import UserGitInfo
from openhands.server.app import app
from openhands.server.user_auth.user_auth import UserAuth
from openhands.storage.data_models.secrets import Secrets
from openhands.storage.memory import InMemoryFileStore
from openhands.storage.secrets.secrets_store import SecretsStore
from openhands.storage.settings.file_settings_store import FileSettingsStore
from openhands.storage.settings.settings_store import SettingsStore
class MockUserAuth(UserAuth):
@@ -75,7 +75,7 @@ def test_client():
return_value=MockUserAuth(),
),
patch(
'openhands.storage.settings.file_settings_store.FileSettingsStore.get_instance',
'openhands.app_server.settings.file_settings_store.FileSettingsStore.get_instance',
AsyncMock(return_value=FileSettingsStore(InMemoryFileStore())),
),
):

View File

@@ -6,15 +6,15 @@ from fastapi import Request
from fastapi.testclient import TestClient
from pydantic import SecretStr
from openhands.app_server.secrets.secrets_store import SecretsStore
from openhands.app_server.settings.file_settings_store import FileSettingsStore
from openhands.app_server.settings.settings_store import SettingsStore
from openhands.integrations.provider import ProviderToken, ProviderType
from openhands.integrations.service_types import UserGitInfo
from openhands.server.app import app
from openhands.server.user_auth.user_auth import UserAuth
from openhands.storage.data_models.secrets import Secrets
from openhands.storage.memory import InMemoryFileStore
from openhands.storage.secrets.secrets_store import SecretsStore
from openhands.storage.settings.file_settings_store import FileSettingsStore
from openhands.storage.settings.settings_store import SettingsStore
class MockUserAuth(UserAuth):
@@ -71,7 +71,7 @@ def test_client():
return_value=MockUserAuth(),
),
patch(
'openhands.storage.settings.file_settings_store.FileSettingsStore.get_instance',
'openhands.app_server.settings.file_settings_store.FileSettingsStore.get_instance',
AsyncMock(return_value=FileSettingsStore(InMemoryFileStore())),
),
):

View File

@@ -4,12 +4,12 @@ from unittest.mock import MagicMock, patch
import pytest
from pydantic import SecretStr
from openhands.app_server.settings.file_settings_store import FileSettingsStore
from openhands.core.config.openhands_config import OpenHandsConfig
from openhands.sdk.llm import LLM
from openhands.sdk.settings import AgentSettings, ConversationSettings
from openhands.storage.data_models.settings import Settings
from openhands.storage.files import FileStore
from openhands.storage.settings.file_settings_store import FileSettingsStore
@pytest.fixture
@@ -106,7 +106,7 @@ async def test_get_instance():
config = OpenHandsConfig(file_store='local', file_store_path='/test/path')
with patch(
'openhands.storage.settings.file_settings_store.get_file_store'
'openhands.app_server.settings.file_settings_store.get_file_store'
) as mock_get_store:
mock_store = MagicMock(spec=FileStore)
mock_get_store.return_value = mock_store