Skip to content

Commit

Permalink
Refactor rename Disk.StatusLUKSEncrypted to StatusReachable
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalo-bulnes committed Jan 24, 2023
1 parent afd18ec commit 1cbf493
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions securedrop_client/export/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Disk(QObject):

Status = NewType("Status", str)
StatusUnknown = Status("unknown-isw32")
StatusLUKSEncrypted = Status("luks-encrypted-8563d")
StatusReachable = Status("luks-encrypted-8563d")
StatusUnreachable = Status("unreachable-ofbu4")

def __init__(
Expand Down Expand Up @@ -192,7 +192,7 @@ def _on_unknown_state_entered(self) -> None:

@pyqtSlot()
def _on_luks_encrypted_state_entered(self) -> None:
self._status = Disk.StatusLUKSEncrypted
self._status = Disk.StatusReachable

@pyqtSlot()
def _on_unreachable_state_entered(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion securedrop_client/gui/conversation/export/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def _show_generic_error_message(self) -> None:
@pyqtSlot()
def _on_disk_status_changed(self) -> None:
disk_status = self._export_disk.status
if disk_status == Disk.StatusLUKSEncrypted:
if disk_status == Disk.StatusReachable:
self._on_export_preflight_check_succeeded()
elif disk_status == Disk.StatusUnreachable:
self._on_export_preflight_check_failed()
Expand Down
32 changes: 16 additions & 16 deletions tests/export/test_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExportService(QObject):
export_failed = pyqtSignal(object)
export_succeeded = pyqtSignal(object)

def __init__(self, responses=[Disk.StatusLUKSEncrypted]):
def __init__(self, responses=[Disk.StatusReachable]):
super().__init__()

self.responses = responses[:]
Expand All @@ -42,7 +42,7 @@ def check_disk(self):
response = self.responses.pop(0)
# The disk is unreachable unless it's LUKS-encrypted.
# Note that using the Disk.Status type is merely for convenience and readability.
if response == Disk.StatusLUKSEncrypted:
if response == Disk.StatusReachable:
self.luks_encrypted_disk_found.emit()
else:
reason = object() # to comply with the Service API
Expand Down Expand Up @@ -100,10 +100,10 @@ def test_export_service_responds_as_configured(self):
client = ExportServiceClient()
responses = [
"not LUKS-encrypted", # whatever
Disk.StatusLUKSEncrypted,
Disk.StatusLUKSEncrypted,
Disk.StatusUnreachable, # not Disk.StatusLUKSEncrypted
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
Disk.StatusReachable,
Disk.StatusUnreachable, # not Disk.StatusReachable
Disk.StatusReachable,
# nothing else
]
export_service = ExportService(responses) # override default responses
Expand Down Expand Up @@ -165,9 +165,9 @@ def test_disk_status_is_unknown_by_default(self):

def test_disk_status_tracks_export_service_responses_when_watched(self):
responses = [
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
Disk.StatusUnreachable,
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
]
export_service = ExportService(responses)

Expand Down Expand Up @@ -205,7 +205,7 @@ def test_disk_status_tracks_export_service_responses_when_watched(self):
"Expected exactly 1 query to the export service, and 1 response immediately after the disk started being watched.", # noqa: E501
)
self.assertEqual(
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
disk.status,
"Expected disk status to track the last response, did not.",
)
Expand Down Expand Up @@ -239,7 +239,7 @@ def test_disk_status_tracks_export_service_responses_when_watched(self):
"Expected exactly a total of 3 queries, and 3 responses after the polling interval elapsed.", # noqa: E501
)
self.assertEqual(
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
disk.status,
"Expected disk status to track the last response, did not.",
)
Expand All @@ -258,9 +258,9 @@ def test_disk_status_tracks_export_service_responses_when_watched(self):

def test_disk_status_stops_tracking_export_service_responses_when_not_watched(self):
responses = [
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
Disk.StatusUnreachable,
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
]
export_service = ExportService(responses)
POLLING_INTERVAL = 100 # milliseconds
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_disk_status_stops_tracking_export_service_responses_when_not_watched(se
"Expected exactly 1 query to the export service, and 1 response immediately after the disk started being watched.", # noqa: E501
)
self.assertEqual(
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
disk.status,
"Expected disk status to track the last response, did not.",
)
Expand Down Expand Up @@ -345,9 +345,9 @@ def test_disk_signals_changes_in_disk_status(self):

export_service.luks_encrypted_disk_found.emit()
self.assertEqual(
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
disk.status,
"Expected disk status to become Disk.StatusLUKSEncrypted, did not.",
"Expected disk status to become Disk.StatusReachable, did not.",
)
self.assertEqual(
2,
Expand All @@ -357,7 +357,7 @@ def test_disk_signals_changes_in_disk_status(self):

export_service.luks_encrypted_disk_found.emit()
self.assertEqual(
Disk.StatusLUKSEncrypted,
Disk.StatusReachable,
disk.status,
"Didn't expect any change in disk status.",
)
Expand Down

0 comments on commit 1cbf493

Please sign in to comment.