Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no longer mark replies as failed if they time out #819

Merged
merged 1 commit into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion securedrop_client/api_jobs/uploads.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def call_api(self, api_client: API, session: Session) -> str:
except (RequestTimeoutError, ServerConnectionError) as e:
message = "Failed to send reply for source {id} due to Exception: {error}".format(
id=self.source_uuid, error=e)
self._set_status_to_failed(session)
raise SendReplyJobTimeoutError(message, self.reply_uuid)
except Exception as e:
message = "Failed to send reply for source {id} due to Exception: {error}".format(
Expand Down
5 changes: 4 additions & 1 deletion securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,10 @@ def on_reply_failure(
exception: Union[SendReplyJobError, SendReplyJobTimeoutError]
) -> None:
logger.debug('{} failed to send'.format(exception.reply_uuid))
self.reply_failed.emit(exception.reply_uuid)

# only emit failure signal for non-timeout errors
if isinstance(exception, SendReplyJobError):
self.reply_failed.emit(exception.reply_uuid)

def get_file(self, file_uuid: str) -> db.File:
file = storage.get_file(self.session, file_uuid)
Expand Down
19 changes: 18 additions & 1 deletion tests/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from securedrop_client.api_jobs.downloads import (
DownloadChecksumMismatchException, DownloadDecryptionException, DownloadException
)
from securedrop_client.api_jobs.uploads import SendReplyJobError
from securedrop_client.api_jobs.uploads import SendReplyJobError, SendReplyJobTimeoutError

with open(os.path.join(os.path.dirname(__file__), 'files', 'test-key.gpg.pub.asc')) as f:
PUB_KEY = f.read()
Expand Down Expand Up @@ -1395,6 +1395,23 @@ def test_Controller_on_reply_failure(homedir, mocker, session_maker):
reply_succeeded.emit.assert_not_called()


def test_Controller_on_reply_failure_for_timeout(homedir, mocker, session_maker):
'''
Check that when the method is called, the client emits the correct signal.
'''
co = Controller('http://localhost', mocker.MagicMock(), session_maker, homedir)
reply_succeeded = mocker.patch.object(co, 'reply_succeeded')
reply_failed = mocker.patch.object(co, 'reply_failed')
debug_logger = mocker.patch('securedrop_client.logic.logger.debug')

exception = SendReplyJobTimeoutError('mock_error_message', 'mock_reply_uuid')
co.on_reply_failure(exception)

debug_logger.assert_called_once_with('{} failed to send'.format('mock_reply_uuid'))
reply_failed.emit.assert_not_called()
reply_succeeded.emit.assert_not_called()


def test_Controller_is_authenticated_property(homedir, mocker, session_maker):
'''
Check that the @property `is_authenticated`:
Expand Down