~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.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
fix(tests): narrow broad status-code tautologies in 3 security test files (#4160)
LearningCircuit5f864718902e
diff --git a/tests/security/test_api_security.py b/tests/security/test_api_security.pyindex d723dec5fe..8a37397547 100644--- a/tests/security/test_api_security.py+++ b/tests/security/test_api_security.py@@ -67,9 +67,15 @@ class TestAPISecurityOWASPTop10:for endpoint in protected_endpoints:# Try accessing without authenticationresponse = client.get(endpoint)- # Should return 401 Unauthorized, 403 Forbidden, 404 Not Found- # or 405 Method Not Allowed (if endpoint only accepts POST)- assert response.status_code in [401, 403, 404, 405]+ # Should be one of the auth-block codes:+ # 401 Unauthorized, 403 Forbidden, 404 Not Found (route hidden),+ # 405 Method Not Allowed (endpoint only accepts POST).+ # MUST NOT be 200 — that would mean the endpoint is reachable+ # without authentication, which is what this OWASP API2 test+ # exists to catch.+ assert response.status_code in {401, 403, 404, 405}, (+ f"{endpoint} returned {response.status_code} without auth"+ )# API3:2023 - Broken Object Property Level Authorizationdef test_api3_broken_property_level_authorization(self, client):@@ -123,7 +129,7 @@ class TestAPISecurityOWASPTop10:# Should have request size limit (413 Payload Too Large)# Or validate query length (400/422)# Current implementation may return 500 for edge cases- assert response.status_code in [200, 400, 401, 413, 422, 500]+ assert response.status_code == 401, response.status_code# Test rate limiting (if implemented)# Make many requests rapidly@@ -153,7 +159,7 @@ class TestAPISecurityOWASPTop10:for endpoint in admin_endpoints:response = client.get(endpoint)# Should return 401 Unauthorized, 403 Forbidden, or 404 Not Found- assert response.status_code in [401, 403, 404]+ assert response.status_code == 404, response.status_code# API6:2023 - Unrestricted Access to Sensitive Business Flows@pytest.mark.skip(reason="documentation/placeholder test - not implemented")@@ -234,7 +240,7 @@ class TestAPISecurityOWASPTop10:response = client.get("/api/v1/nonexistent")# Should return generic error, not stack trace# 401 is also acceptable (auth guard rejects before routing)- assert response.status_code in [401, 404]+ assert response.status_code == 404, response.status_code# API9:2023 - Improper Inventory Management@pytest.mark.skip(reason="documentation/placeholder test - not implemented")@@ -306,7 +312,7 @@ class TestAPIInputValidation:)# Should return 400 Bad Request (or 401 if auth guard rejects first)- assert response.status_code in [400, 401, 422]+ assert response.status_code == 401, response.status_codedef test_missing_required_fields_rejected(self, client):"""Test that requests with missing required fields are rejected."""@@ -319,7 +325,7 @@ class TestAPIInputValidation:# Should return 400 Bad Request or 422 Unprocessable Entity# 401 is also valid (auth guard rejects unauthenticated requests)- assert response.status_code in [400, 401, 422]+ assert response.status_code == 401, response.status_codedef test_invalid_data_types_rejected(self, client):"""Test that invalid data types are rejected."""@@ -332,7 +338,7 @@ class TestAPIInputValidation:# Should validate data types and reject non-string query# 401 is also valid (auth guard rejects unauthenticated requests)- assert response.status_code in [400, 401, 422]+ assert response.status_code == 401, response.status_codedef test_boundary_value_validation(self, client):"""Test validation of boundary values."""@@ -351,7 +357,7 @@ class TestAPIInputValidation:# Should validate and reject invalid inputs (400/422)# 401 is also valid (auth guard rejects unauthenticated requests)- assert response.status_code in [200, 400, 401, 422, 500]+ assert response.status_code == 401, response.status_codeclass TestAPIRateLimiting:diff --git a/tests/security/test_auth_security.py b/tests/security/test_auth_security.pyindex 82a35dd1b4..7be48f2c30 100644--- a/tests/security/test_auth_security.py+++ b/tests/security/test_auth_security.py@@ -144,7 +144,7 @@ class TestSessionSecurity:# Test logout endpointresponse = client.post("/auth/logout")- assert response.status_code in [200, 302] # OK or redirect+ assert response.status_code == 302, response.status_code# After logout, protected pages should require re-authentication# This is tested in access control tests@@ -199,8 +199,14 @@ class TestAccessControl:for endpoint in protected_endpoints:response = client.get(endpoint)- # Should redirect to login or return 401/403- assert response.status_code in [302, 401, 403, 404]+ # Should be one of the auth-block codes:+ # 302 Redirect to login, 401 Unauthorized, 403 Forbidden,+ # 404 Not Found (route hidden behind decorator).+ # MUST NOT be 200 — that would mean the endpoint is reachable+ # without authentication.+ assert response.status_code in {302, 401, 403, 404}, (+ f"{endpoint} returned {response.status_code} without auth"+ )@pytest.mark.skip(reason="documentation/placeholder test - not implemented")def test_authentication_required_decorator(self):@@ -321,7 +327,7 @@ class TestAuthenticationEdgeCases:data={"username": username, "password": "anything"},)# Should not authenticate with SQL injection- assert response.status_code in [401, 400, 302]+ assert response.status_code == 401, response.status_codedef test_empty_credentials_handling(self, client):"""Test that empty username/password are rejected."""diff --git a/tests/security/test_csrf_protection.py b/tests/security/test_csrf_protection.pyindex 9e25b4f2fa..6d4234ef97 100644--- a/tests/security/test_csrf_protection.py+++ b/tests/security/test_csrf_protection.py@@ -74,7 +74,7 @@ class TestCSRFProtection:# Should be rejected (400 Bad Request or redirect with error)# Flask-WTF typically returns 400 for missing CSRF token- assert response.status_code in [400, 302, 401]+ assert response.status_code == 400, response.status_codedef test_post_request_with_invalid_csrf_token_rejected(self, client):"""Test that POST requests with invalid CSRF token are rejected."""@@ -90,7 +90,7 @@ class TestCSRFProtection:)# Should be rejected- assert response.status_code in [400, 302, 401]+ assert response.status_code == 400, response.status_codedef test_post_request_with_valid_csrf_token_accepted(self, client):"""Test that POST requests with valid CSRF token are processed."""