Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Fix REST API test failures and add CDN integrity checks

LearningCircuit63221939a07a
diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.html
index a20bb17117..5f9a694973 100644
--- a/src/local_deep_research/web/templates/base.html
+++ b/src/local_deep_research/web/templates/base.html
@@ -6,8 +6,8 @@
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{% block title %}Deep Research System{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css" integrity="sha512-nVbtfXz0GkNOIiVnhIb+6rBS3jSkFMsszOl8X0OqhuvWDEQjMVCW7oKV3vyMelCfX3nhuCkDDQSb5kE4qi9JOQ==" crossorigin="anonymous" referrerpolicy="no-referrer">
{% block extra_head %}{% endblock %}
</head>
<body>
@@ -48,10 +48,10 @@
{% block templates %}{% endblock %}
<!-- Scripts -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js" integrity="sha512-s+NedSzEBxfi8oURfZ/h3AUzyj3QYrnMP0euRx5iR52QRnsV/bVexHa/Um/JbLzjWdGTmBZPufHyaEkb0dYUBw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.min.js" integrity="sha512-A+vBvS3Pv7mTfH+kyV8uGRi8PGLaWKqQlXytN6pHzTTjWFGL1j+1U8ZlXBNTH9HZlUwWVdF0XjGCu4VCe7EwFA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js" integrity="sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" integrity="sha512-qZvrmS2ekKPF2mSznTQsxqPgnpkI4DNTlrdUmTzrDgektczlKNRRhy5X5AAOnx5S09ydFYWWNSfcEqDTTHgtNA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- URL Configuration (must load first) -->
diff --git a/tests/api_tests/test_proper_csrf.py b/tests/api_tests/test_proper_csrf.py
index ad6ba0effe..a67c538165 100644
--- a/tests/api_tests/test_proper_csrf.py
+++ b/tests/api_tests/test_proper_csrf.py
@@ -79,8 +79,12 @@ class TestProperCSRF:
assert data.get("authenticated") is True
logger.info("✅ Authentication test passed!")
- def test_login_without_csrf(self, client):
+ def test_login_without_csrf(self, app):
"""Test that login fails without CSRF token."""
+ # Enable CSRF for this test
+ app.config["WTF_CSRF_ENABLED"] = True
+ client = app.test_client()
+
# Try to login without CSRF token
login_data = {
"username": "testuser",
@@ -96,8 +100,12 @@ class TestProperCSRF:
assert response.status_code != 302 # Should not redirect (success)
logger.info("✅ Login correctly rejected without CSRF token")
- def test_login_with_invalid_csrf(self, client):
+ def test_login_with_invalid_csrf(self, app):
"""Test that login fails with invalid CSRF token."""
+ # Enable CSRF for this test
+ app.config["WTF_CSRF_ENABLED"] = True
+ client = app.test_client()
+
# Get login page
response = client.get("/auth/login")
assert response.status_code == 200
diff --git a/tests/api_tests/test_research_creation.py b/tests/api_tests/test_research_creation.py
index 71f2a9e137..0f61b7b7ab 100644
--- a/tests/api_tests/test_research_creation.py
+++ b/tests/api_tests/test_research_creation.py
@@ -50,6 +50,8 @@ class TestResearchCreation:
research_data = {
"query": "Minimal test query",
"mode": "quick",
+ "model": "llama2",
+ "model_provider": "OLLAMA",
}
print(f"\n[DEBUG] Sending minimal research request: {research_data}")
@@ -88,6 +90,8 @@ class TestResearchCreation:
research_data = {
"query": "Status check test",
"mode": "quick",
+ "model": "llama2",
+ "model_provider": "OLLAMA",
}
response = authenticated_client.post(
@@ -125,6 +129,8 @@ class TestResearchCreation:
research_data = {
"query": "Termination test",
"mode": "quick",
+ "model": "llama2",
+ "model_provider": "OLLAMA",
}
response = authenticated_client.post(
@@ -155,6 +161,8 @@ class TestResearchCreation:
research_data = {
"query": f"Test {mode} mode",
"mode": mode,
+ "model": "llama2",
+ "model_provider": "OLLAMA",
}
response = authenticated_client.post(
@@ -182,8 +190,8 @@ class TestResearchCreation:
research_data = {
"query": "Custom model test",
"mode": "quick",
- "model_provider": "OPENAI",
- "model": "gpt-3.5-turbo",
+ "model_provider": "OLLAMA",
+ "model": "mistral",
"temperature": 0.5,
"max_tokens": 1000,
}
diff --git a/tests/api_tests/test_session_persistence.py b/tests/api_tests/test_session_persistence.py
index 619b80526f..0aaae46ac1 100644
--- a/tests/api_tests/test_session_persistence.py
+++ b/tests/api_tests/test_session_persistence.py
@@ -38,8 +38,10 @@ class TestSessionPersistence:
logger.info(f"POST /auth/login -> {response.status_code}")
- # Check if we got a session cookie
- assert any("session" in cookie.name for cookie in client.cookie_jar)
+ # Check if we're logged in by verifying successful redirect
+ assert (
+ response.status_code == 302
+ ) # Should redirect after successful login
# Access home page
response = client.get("/", follow_redirects=False)
@@ -128,7 +130,7 @@ class TestSessionPersistence:
assert data["authenticated"] is True
# Logout
- response = authenticated_client.get(
+ response = authenticated_client.post(
"/auth/logout", follow_redirects=True
)
assert response.status_code == 200
diff --git a/tests/api_tests/test_simple_auth.py b/tests/api_tests/test_simple_auth.py
index 60ebccbfa4..abf14124e4 100644
--- a/tests/api_tests/test_simple_auth.py
+++ b/tests/api_tests/test_simple_auth.py
@@ -100,8 +100,8 @@ class TestSimpleAuth:
assert data["authenticated"] is True
# Logout
- print("\n[DEBUG] Testing logout endpoint with GET method")
- response = authenticated_client.get(
+ print("\n[DEBUG] Testing logout endpoint with POST method")
+ response = authenticated_client.post(
"/auth/logout", follow_redirects=True
)
print(f"[DEBUG] Logout response status: {response.status_code}")
diff --git a/tests/api_tests/test_without_csrf.py b/tests/api_tests/test_without_csrf.py
index 69a0df93b0..dec5ff2b22 100644
--- a/tests/api_tests/test_without_csrf.py
+++ b/tests/api_tests/test_without_csrf.py
@@ -43,9 +43,13 @@ class TestWithoutCSRF:
# Re-enable CSRF
app.config["WTF_CSRF_ENABLED"] = True
- def test_login_requires_csrf_by_default(self, client):
- """Test that login requires CSRF token by default."""
- # Try login without CSRF token (CSRF should be enabled by default)
+ def test_login_requires_csrf_by_default(self, app):
+ """Test that login requires CSRF token when enabled."""
+ # Create a new client with CSRF enabled
+ app.config["WTF_CSRF_ENABLED"] = True
+ client = app.test_client()
+
+ # Try login without CSRF token (CSRF should be enabled)
login_data = {"username": "testuser", "password": "testpassword123"}
# Direct POST without CSRF token
diff --git a/tests/conftest.py b/tests/conftest.py
index 27c0ea53ff..0e1817c1a2 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -93,7 +93,7 @@ def client(app):
@pytest.fixture
def authenticated_client(client):
"""Create a test client with an authenticated user."""
- # Register a test user
+ # Try to register a test user (ignore if already exists)
client.post(
"/auth/register",
data={
@@ -104,6 +104,9 @@ def authenticated_client(client):
},
)
+ # If registration failed, it might be because user already exists, which is fine
+ # Just proceed to login
+
# Login the user
client.post(
"/auth/login",