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.

test: delete 8 no-assert / dead-code security + rate-limit tests (#4286)

LearningCircuitb80ce2b3d462
diff --git a/tests/security/test_api_security.py b/tests/security/test_api_security.py
index 6124442360..9ba28c580c 100644
--- a/tests/security/test_api_security.py
+++ b/tests/security/test_api_security.py
@@ -77,38 +77,6 @@ class TestAPISecurityOWASPTop10:
f"{endpoint} returned {response.status_code} without auth"
)
- # API3:2023 - Broken Object Property Level Authorization
- @pytest.mark.skip(reason="documentation/placeholder test - not implemented")
- def test_api3_broken_property_level_authorization(self, client):
- """
- Test that users can only modify allowed object properties.
-
- Mass Assignment vulnerability:
- - User sends extra fields in request
- - API blindly assigns all fields to object
- - User escalates privileges or modifies restricted fields
- """
- # Example vulnerable code:
- # user.update(**request.json) # All fields from request
-
- # Should only allow specific fields:
- # allowed = ['name', 'email']
- # user.update({k: v for k, v in request.json.items() if k in allowed})
-
- # Test sending restricted fields
- client.post(
- "/api/v1/quick_summary",
- json={
- "query": "test query",
- "is_admin": True, # Attempt privilege escalation
- "user_id": "different_user", # Attempt to modify other user
- },
- content_type="application/json",
- )
-
- # Should ignore extra fields or reject request
- assert True # Implementation-specific
-
# API4:2023 - Unrestricted Resource Consumption
def test_api4_unrestricted_resource_consumption(self, client):
"""
@@ -185,40 +153,6 @@ class TestAPISecurityOWASPTop10:
pass # Implementation-specific
- # API7:2023 - Server Side Request Forgery (SSRF)
- def test_api7_ssrf_prevention(self, client):
- """
- Test prevention of Server-Side Request Forgery.
-
- SSRF: Attacker makes server send requests to unintended destinations
- - Internal network scanning
- # - Accessing cloud metadata endpoints
- - Reading local files
- """
- # LDR fetches external web content for research
- # This is a potential SSRF vector
-
- # DevSkim: ignore DS137138 - Intentionally using insecure URLs for SSRF testing
- ssrf_payloads = [
- "http://localhost/admin", # Local services
- "http://127.0.0.1:22", # Internal ports
- "http://169.254.169.254/latest/meta-data/", # AWS metadata
- "file:///etc/passwd", # Local file access
- "http://[::]:80/", # IPv6 localhost
- "http://0.0.0.0/admin", # Alternative localhost
- ]
-
- for payload in ssrf_payloads:
- client.post(
- "/api/v1/quick_summary",
- json={"query": "research", "custom_url": payload},
- content_type="application/json",
- )
-
- # Should validate URL and block internal/local addresses
- # Should whitelist allowed domains
- assert True # Implementation-specific URL validation
-
# API8:2023 - Security Misconfiguration
def test_api8_security_misconfiguration(self, client):
"""
@@ -375,29 +309,6 @@ class TestAPIRateLimiting:
app.config["SECURITY_CORS_ALLOWED_ORIGINS"] = "*"
return app.test_client()
- def test_rate_limiting_on_expensive_endpoints(self, client):
- """Test that expensive operations are rate limited."""
- # Make many requests to expensive endpoint
- endpoint = "/api/v1/quick_summary"
- request_count = 50
-
- responses = []
- for i in range(request_count):
- response = client.post(
- endpoint,
- json={"query": f"test query {i}"},
- content_type="application/json",
- )
- responses.append(response)
-
- # If rate limiting is implemented, should get 429 Too Many Requests
- [r.status_code for r in responses]
-
- # Rate limiting may not be enabled in testing mode
- # This test documents expected behavior for production
-
- pass
-
@pytest.mark.skip(reason="documentation/placeholder test - not implemented")
def test_api_security_documentation():
diff --git a/tests/security/test_auth_security.py b/tests/security/test_auth_security.py
index 57de7a3a06..c3728be9f2 100644
--- a/tests/security/test_auth_security.py
+++ b/tests/security/test_auth_security.py
@@ -89,24 +89,6 @@ class TestSessionSecurity:
app.config["WTF_CSRF_ENABLED"] = False
return app.test_client()
- @pytest.mark.skip(reason="documentation/placeholder test - not implemented")
- def test_session_cookie_secure_flags(self, client):
- """Test that session cookies have secure flags set."""
- client.get("/")
-
- # Check Set-Cookie header for security flags:
- # - HttpOnly: Prevents JavaScript access (XSS mitigation)
- # - Secure: Only sent over HTTPS (in production)
- # - SameSite: CSRF protection
-
- # In production, these should be set:
- # Set-Cookie: session=...; HttpOnly; Secure; SameSite=Lax
-
- # In testing/localhost, Secure flag may not be set
- # This documents expected production behavior
-
- pass # Placeholder for future validation
-
@pytest.mark.skip(reason="documentation/placeholder test - not implemented")
def test_session_expiration(self, client):
"""Test that sessions expire appropriately."""
@@ -268,51 +250,6 @@ class TestAuthenticationEdgeCases:
app.config["WTF_CSRF_ENABLED"] = False
return app.test_client()
- def test_brute_force_protection(self, client):
- """Test protection against brute force login attacks."""
- # Brute force protection mechanisms:
- # 1. Rate limiting on login endpoint
- # 2. Account lockout after failed attempts
- # 3. CAPTCHA after multiple failures
- # 4. Exponential backoff
-
- # For local tool, may not be critical
- # For public-facing deployment, is essential
-
- # Test multiple failed login attempts
- for i in range(10):
- client.post(
- "/auth/login",
- data={"username": "admin", "password": f"wrong_password_{i}"},
- )
- # Should eventually trigger rate limiting or lockout
- # Implementation-specific behavior
-
- pass # Placeholder for rate limiting tests
-
- @pytest.mark.skip(reason="documentation/placeholder test - not implemented")
- def test_username_enumeration_prevention(self, client):
- """Test that login doesn't leak username existence."""
- # Username enumeration attack:
- # - Attacker tries different usernames
- # - Different error messages reveal if username exists:
- # "Invalid password" vs "User doesn't exist"
-
- # Protection: Same error message for both cases
- # "Invalid username or password"
-
- # Test login with non-existent username
- client.post(
- "/auth/login",
- data={"username": "nonexistent_user_12345", "password": "wrong"},
- )
-
- # Test login with existing username but wrong password
- # (Would need actual user in test DB)
-
- # Both should return same generic error
- pass # Implementation-specific
-
def test_sql_injection_in_authentication(self, client):
"""Test that authentication is protected against SQL injection."""
# SQL injection in login form
diff --git a/tests/test_llm_rate_limiting.py b/tests/test_llm_rate_limiting.py
index e9f473140a..747936a7a8 100644
--- a/tests/test_llm_rate_limiting.py
+++ b/tests/test_llm_rate_limiting.py
@@ -15,7 +15,6 @@ from local_deep_research.web_search_engines.rate_limiting.llm import ( # noqa:
create_rate_limited_llm_wrapper,
is_llm_rate_limit_error,
)
-from tenacity import RetryError # noqa: E402
class TestLLMRateLimitDetection:
@@ -130,55 +129,6 @@ class TestRateLimitedLLMWrapper:
assert response.content == "Test response"
mock_llm.invoke.assert_called_once_with("Test prompt")
- def test_invoke_with_rate_limit_error(self, mock_llm, mock_db_settings):
- """Test handling of rate limit errors during invoke."""
- # Skip this test since rate limiting is disabled by default
- pytest.skip("Rate limiting is disabled by default")
-
- # Make the LLM always raise a rate limit error (no success after retries)
- mock_llm.invoke.side_effect = Exception(
- "Error: 429 Resource has been exhausted"
- )
-
- wrapper = create_rate_limited_llm_wrapper(mock_llm, provider="openai")
-
- # Mock the tracker to avoid actual waits
- with patch.object(
- wrapper.rate_limiter, "get_wait_time", return_value=0.01
- ):
- with patch.object(wrapper.rate_limiter, "record_outcome"):
- # The retry logic will try 3 times then raise RetryError
- with pytest.raises(RetryError):
- wrapper.invoke("Test prompt")
-
- # Verify it tried 3 times
- assert mock_llm.invoke.call_count == 3
-
- def test_successful_retry_after_rate_limit(
- self, mock_llm, mock_db_settings
- ):
- """Test successful retry after rate limit error."""
- # Skip this test since rate limiting is disabled by default
- pytest.skip("Rate limiting is disabled by default")
-
- # First call fails with rate limit, second succeeds
- mock_llm.invoke.side_effect = [
- Exception("Error: 429 Too many requests"),
- AIMessage(content="Success after retry"),
- ]
-
- wrapper = create_rate_limited_llm_wrapper(mock_llm, provider="openai")
-
- # Mock the tracker to avoid actual waits
- with patch.object(
- wrapper.rate_limiter, "get_wait_time", return_value=0.01
- ):
- with patch.object(wrapper.rate_limiter, "record_outcome"):
- response = wrapper.invoke("Test prompt")
-
- assert response.content == "Success after retry"
- assert mock_llm.invoke.call_count == 2
-
def test_attribute_passthrough(self, mock_llm, mock_db_settings):
"""Test that attributes are passed through to the base LLM."""
mock_llm.custom_attribute = "test_value"