Versioning consistency and bump both the XPI and backend to version 0.2.0
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
## Copyright © 2026 Olaf Kolkman
|
||||
## SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
@@ -10,6 +11,7 @@ from cryptography.fernet import Fernet
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
||||
DB_PATH = BASE_DIR / 'data' / 'linklog.db'
|
||||
VERSION_FILE = BASE_DIR.parent / 'frontend' / 'version.json'
|
||||
|
||||
|
||||
def normalize_public_url(value: str) -> str:
|
||||
@@ -20,11 +22,19 @@ def normalize_public_url(value: str) -> str:
|
||||
return f'{scheme}://{value}'
|
||||
|
||||
|
||||
def load_version() -> str:
|
||||
# frontend/version.json is the single source of truth for the app version, shared by backend and frontend.
|
||||
try:
|
||||
return json.loads(VERSION_FILE.read_text())['version']
|
||||
except (OSError, KeyError, ValueError):
|
||||
return '0.0.0'
|
||||
|
||||
|
||||
@dataclass
|
||||
class Settings:
|
||||
app_env: str = os.getenv('APP_ENV', 'development').lower()
|
||||
app_name: str = os.getenv('LINKLOG_APP_NAME', 'LinkLog')
|
||||
version: str = os.getenv('LINKLOG_VERSION', '0.1.1')
|
||||
version: str = field(default_factory=load_version)
|
||||
database_url: str = os.getenv('LINKLOG_DATABASE_URL', f'sqlite:///{DB_PATH}')
|
||||
secret_key: str = os.getenv('LINKLOG_SECRET_KEY', 'dev-secret-key-change-me')
|
||||
data_encryption_key: str = os.getenv('LINKLOG_DATA_ENCRYPTION_KEY', '')
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
## SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import threading
|
||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||
from urllib.parse import parse_qs
|
||||
@@ -11,6 +12,7 @@ from unittest.mock import MagicMock, patch
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from backend.app.main import app
|
||||
from backend.app.core.config import settings
|
||||
from backend.app.database import get_connection, hash_password
|
||||
from backend.app.services.email_service import get_smtp_settings
|
||||
from backend.app.services.login_throttle import clear_login_failures
|
||||
@@ -31,7 +33,7 @@ def login_headers(username='alice'):
|
||||
|
||||
|
||||
def test_login_returns_token():
|
||||
assert app.version == '0.1.1'
|
||||
assert app.version == settings.version
|
||||
response = client.post('/api/auth/login', json={
|
||||
'email': 'alice@example.com',
|
||||
'password': 'secret123',
|
||||
@@ -806,7 +808,9 @@ def test_public_and_admin_pages_render_html():
|
||||
assert about_page.status_code == 200
|
||||
assert 'Save the good stuff' in about_page.text
|
||||
assert '<h2>Plugin</h2>' in about_page.text
|
||||
assert 'https://git.kolkman.org/olaf/Link-Log/raw/branch/main/XPI/signed/LinkLog-0.1.0.xpi' in about_page.text
|
||||
updates = json.loads((Path(__file__).resolve().parents[2] / 'webextension' / 'updates.json').read_text())
|
||||
latest_update = updates['addons']['linklog@kolkman.org']['updates'][0]
|
||||
assert latest_update['update_link'] in about_page.text
|
||||
assert 'id="auth-about-link" href="/about"' in about_page.text
|
||||
assert client.get('/admin').status_code == 200
|
||||
admin_page = client.get('/admin').text
|
||||
|
||||
Reference in New Issue
Block a user