fix: merge main, address code review feedback for security fix PR #816
- Merge origin/main into branch (resolve conflict in integrations_dashboard.html) - Add defensive JSON parsing with try/except for integration.config - Wrap tester() call in try/except to prevent 500 errors from bad config - Add i18n key integrations.connection_test_failed_fallback in en.json - Reference i18n key in template JS fallback message - Update SECURITY_AUDIT.md: add fix date (2026-03-23), update doc date - Remove accidental revert.sh file - Fix missing MagicMock/patch imports in test file - Add tests for invalid JSON config and tester exception error paths Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> Agent-Logs-Url: https://github.com/christianlouis/DocuElevate/sessions/daebb70e-059a-4601-8864-88eef49f99cf
This commit is contained in:
@@ -7,9 +7,9 @@ Targets the remaining uncovered branches from the 97.03% baseline:
|
||||
- 214 : test_google_drive_token — generic connection error (not token-related)
|
||||
- 302->306: get_google_drive_token_info — credentials already valid (no refresh)
|
||||
- 307->318: get_google_drive_token_info — credentials have no expiry
|
||||
- 395->397: save_dropbox_settings — refresh_token falsy inside use_oauth block
|
||||
- 449->451: save_dropbox_settings — refresh_token falsy in in-memory update
|
||||
- 468->470: save_dropbox_settings — folder_id falsy in db-persist block
|
||||
- 395->397: save_google_drive_settings — refresh_token falsy inside use_oauth block
|
||||
- 449->451: save_google_drive_settings — refresh_token falsy in in-memory update
|
||||
- 468->470: save_google_drive_settings — folder_id falsy in db-persist block
|
||||
"""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
@@ -152,10 +152,10 @@ class TestGetTokenInfoCredentialsBranches:
|
||||
|
||||
@pytest.mark.unit
|
||||
class TestSaveGoogleDriveSettingsFalsyFields:
|
||||
"""Cover branches 395->397, 449->451, 468->470 in save_dropbox_settings.
|
||||
"""Cover branches 395->397, 449->451, 468->470 in save_google_drive_settings.
|
||||
|
||||
Note: the Google Drive save endpoint is named save_dropbox_settings in the
|
||||
source (app/api/google_drive.py) due to an existing naming inconsistency.
|
||||
Note: the Google Drive save endpoint is named save_google_drive_settings in the
|
||||
source (app/api/google_drive.py).
|
||||
"""
|
||||
|
||||
@patch("app.api.google_drive.settings")
|
||||
@@ -167,7 +167,7 @@ class TestSaveGoogleDriveSettingsFalsyFields:
|
||||
|
||||
from starlette.requests import Request as StarletteRequest
|
||||
|
||||
from app.api.google_drive import save_dropbox_settings
|
||||
from app.api.google_drive import save_google_drive_settings
|
||||
|
||||
mock_request = MagicMock(spec=StarletteRequest)
|
||||
mock_request.session = {}
|
||||
@@ -175,7 +175,7 @@ class TestSaveGoogleDriveSettingsFalsyFields:
|
||||
|
||||
with patch("app.api.google_drive.save_setting_to_db"):
|
||||
with patch("app.api.google_drive.notify_settings_updated"):
|
||||
result = await save_dropbox_settings(
|
||||
result = await save_google_drive_settings(
|
||||
request=mock_request,
|
||||
refresh_token="", # falsy → branches 395->397 and 449->451
|
||||
client_id="cid",
|
||||
|
||||
Reference in New Issue
Block a user