From c21d1bbe35874428e3951f06563f16e1d3a562b4 Mon Sep 17 00:00:00 2001 From: Brayan Almonte Date: Mon, 9 Oct 2023 14:08:13 -0400 Subject: [PATCH] feat(api): add AuthorizedKeys reset option for the OT-2 (#13743) --- api/src/opentrons/config/reset.py | 1 + .../test_settings_reset_options.tavern.yaml | 30 +++++++++++++++++++ .../service/legacy/routers/test_settings.py | 5 ++++ 3 files changed, 36 insertions(+) diff --git a/api/src/opentrons/config/reset.py b/api/src/opentrons/config/reset.py index ccba3b2fdcb..42a2b606106 100644 --- a/api/src/opentrons/config/reset.py +++ b/api/src/opentrons/config/reset.py @@ -49,6 +49,7 @@ class ResetOptionId(str, Enum): ResetOptionId.pipette_offset, ResetOptionId.tip_length_calibrations, ResetOptionId.runs_history, + ResetOptionId.authorized_keys, ] _FLEX_RESET_OPTIONS = [ ResetOptionId.boot_scripts, diff --git a/robot-server/tests/integration/test_settings_reset_options.tavern.yaml b/robot-server/tests/integration/test_settings_reset_options.tavern.yaml index 7dc49479bba..4025206afee 100644 --- a/robot-server/tests/integration/test_settings_reset_options.tavern.yaml +++ b/robot-server/tests/integration/test_settings_reset_options.tavern.yaml @@ -27,6 +27,10 @@ stages: - id: runsHistory name: Clear Runs History description: !re_search 'Erase this device''s stored history of protocols and runs.' + - id: authorizedKeys + name: SSH Authorized Keys + description: !re_search 'Clear the ssh authorized keys' + --- test_name: POST Reset bootScripts option marks: @@ -123,6 +127,32 @@ stages: message: "gripperOffsetCalibrations is not a valid reset option." errorCode: "4000" --- +test_name: POST Reset authorizedKeys option +marks: + - usefixtures: + - ot2_server_base_url +stages: + - name: POST Reset authorizedKeys true + request: + url: '{ot2_server_base_url}/settings/reset' + method: POST + json: + authorizedKeys: true + response: + status_code: 200 + json: + message: "Options 'authorized_keys' were reset" + - name: POST Reset authorizedKeys false + request: + url: '{ot2_server_base_url}/settings/reset' + method: POST + json: + authorizedKeys: false + response: + status_code: 200 + json: + message: 'Nothing to do' +--- test_name: POST Reset non existant option marks: - usefixtures: diff --git a/robot-server/tests/service/legacy/routers/test_settings.py b/robot-server/tests/service/legacy/routers/test_settings.py index 65acd3978aa..8658d49b79a 100644 --- a/robot-server/tests/service/legacy/routers/test_settings.py +++ b/robot-server/tests/service/legacy/routers/test_settings.py @@ -437,6 +437,7 @@ def test_available_resets(api_client): "bootScripts", "tipLengthCalibrations", "runsHistory", + "authorizedKeys", ] ) == sorted([item["id"] for item in options_list]) @@ -474,6 +475,7 @@ async def mock_get_persistence_resetter() -> PersistenceResetter: "pipetteOffsetCalibrations": False, "tipLengthCalibrations": False, "runsHistory": False, + "authorizedKeys": False, }, set(), ], @@ -485,6 +487,7 @@ async def mock_get_persistence_resetter() -> PersistenceResetter: "tipLengthCalibrations": True, "deckCalibration": True, "runsHistory": True, + "authorizedKeys": True, # TODO(mm, 2023-08-04): Figure out how to test Flex-only options, # then add gripperOffsetCalibrations and onDeviceDisplay. }, @@ -498,8 +501,10 @@ async def mock_get_persistence_resetter() -> PersistenceResetter: # mark_directory_reset() being an async method, and api_client having # its own event loop that interferes with making this test async. ResetOptionId.runs_history, + ResetOptionId.authorized_keys, }, ], + [{"authorizedKeys": True}, {ResetOptionId.authorized_keys}], [{"bootScripts": True}, {ResetOptionId.boot_scripts}], [{"pipetteOffsetCalibrations": True}, {ResetOptionId.pipette_offset}], [{"tipLengthCalibrations": True}, {ResetOptionId.tip_length_calibrations}],