Federation data and actor keys (phase 1, step 1)
- federation_settings (per user; off, followers-only, not discoverable by default) and federation_keys (RSA-2048; NULL user = instance actor), on the federation migration branch - Private keys encrypted at rest with Fernet, keyed by HKDF-SHA256 from FEDERATION_KEY_SECRET (now required, 32+ chars, never printed) - Keys are created when a user first enables sharing and never regenerated; sharing.shared_user() treats unknown and non-sharing users identically - One flask-smorest Api per app (get_api(app)), so apps with and without federation never share an OpenAPI spec - Test fixtures for a second, federation-enabled app on the same DB Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
00ad8e9e6d
commit
98c65547f3
12 files changed
+513
-5
No files matched your search
@@ -142,3 +142,43 @@ def ui_token(user):
|
||||
def auth(ui_token):
|
||||
"""Authorization headers for the default user."""
|
||||
return {"Authorization": f"Bearer {ui_token}"}
|
||||
|
||||
|
||||
# --- Federation ---------------------------------------------------------------------
|
||||
|
||||
from scrobbler.config import TestConfig as _TestConfig # noqa: E402
|
||||
|
||||
|
||||
class FederatedTestConfig(_TestConfig):
|
||||
FEDERATION_ENABLED = "1"
|
||||
FEDERATION_DOMAIN = "scrobble.test"
|
||||
FEDERATION_BASE_URL = "https://scrobble.test"
|
||||
FEDERATION_KEY_SECRET = "test-only-federation-key-secret-0123456789"
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def fed_app(app):
|
||||
"""A second app, with federation on, sharing the test database."""
|
||||
return create_app(FederatedTestConfig)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fed_client(fed_app):
|
||||
return fed_app.test_client()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fed_ctx(fed_app):
|
||||
"""Run the test inside the federation app's context (for services using current_app)."""
|
||||
with fed_app.app_context():
|
||||
yield
|
||||
db.session.remove()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sharing_user(fed_ctx, user):
|
||||
"""The default user, with sharing switched on."""
|
||||
from scrobbler.federation import sharing
|
||||
|
||||
sharing.update(user.id, {"enabled": True, "display_name": "Alice", "bio": "Listening."})
|
||||
return user
|
||||
Reference in new issue
Block a user