Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
Limmen committed Jul 8, 2024
1 parent 00fe92a commit 4b79964
Showing 1 changed file with 19 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,12 @@ def test_stop_snort_ides(self, mock_stop_snort_ids) -> None:
)

@patch("csle_common.controllers.snort_ids_controller.SnortIDSController.start_snort_manager")
@patch(
"csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_idses_monitor_threads_statuses_by_ip_and_port"
)
@patch("csle_common.controllers.snort_ids_controller.SnortIDSController."
"get_snort_idses_monitor_threads_statuses_by_ip_and_port")
@patch("csle_collector.snort_ids_manager.query_snort_ids_manager.start_snort_ids")
@patch("grpc.insecure_channel")
def test_start_snort_ids(
self, mock_insecure_channel, mock_start_snort_ids, mock_get_statuses, mock_start_manager
) -> None:
def test_start_snort_ids(self, mock_insecure_channel, mock_start_snort_ids, mock_get_statuses, mock_start_manager) \
-> None:
"""
Test utility function for starting the Snort IDS on a specific IP
Expand Down Expand Up @@ -111,13 +109,12 @@ def test_start_snort_ids(
mock_start_snort_ids.assert_called()

@patch("csle_common.controllers.snort_ids_controller.SnortIDSController.start_snort_manager")
@patch(
"csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_idses_monitor_threads_statuses_by_ip_and_port"
)
@patch("csle_common.controllers.snort_ids_controller.SnortIDSController."
"get_snort_idses_monitor_threads_statuses_by_ip_and_port")
@patch("csle_collector.snort_ids_manager.query_snort_ids_manager.stop_snort_ids")
@patch("grpc.insecure_channel")
def test_stop_snort_ids(
self, mock_insecure_channel, mock_stop_snort_ids, mock_get_statuses, mock_start_manager
self, mock_insecure_channel, mock_stop_snort_ids, mock_get_statuses, mock_start_manager
) -> None:
"""
Test utility function for stopping the Snort IDS on a specific IP
Expand Down Expand Up @@ -245,14 +242,12 @@ def test_start_snort_idses_monitor_threads(self, mock_start_monitor_thread) -> N
self.logger.info.assert_called_once_with("Starting Snort IDS monitor thread on IP: 10.0.0.1")

@patch("csle_common.controllers.snort_ids_controller.SnortIDSController.start_snort_manager")
@patch(
"csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_idses_monitor_threads_statuses_by_ip_and_port"
)
@patch("csle_common.controllers.snort_ids_controller.SnortIDSController."
"get_snort_idses_monitor_threads_statuses_by_ip_and_port")
@patch("csle_collector.snort_ids_manager.query_snort_ids_manager.start_snort_ids_monitor")
@patch("grpc.insecure_channel")
def test_start_snort_idses_monitor_thread(
self, mock_insecure_channel, mock_start_monitor, mock_get_statuses, mock_start_manager
):
def test_start_snort_idses_monitor_thread(self, mock_insecure_channel, mock_start_monitor, mock_get_statuses,
mock_start_manager) -> None:
"""
Test a method that sends a request to the SnortIDSManager on a specific container that runs
an IDS to start the IDS manager and the monitor thread
Expand Down Expand Up @@ -335,7 +330,8 @@ def test_stop_snort_idses_monitor_thread(self, mock_insecure_channel, mock_stop_

@patch("csle_common.controllers.snort_ids_controller.SnortIDSController.start_snort_managers")
@patch(
"csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_idses_monitor_threads_statuses_by_ip_and_port"
"csle_common.controllers.snort_ids_controller.SnortIDSController."
"get_snort_idses_monitor_threads_statuses_by_ip_and_port"
)
def test_get_snort_idses_monitor_threads_statuses(self, mock_get_statuses, mock_start_managers) -> None:
"""
Expand Down Expand Up @@ -365,9 +361,8 @@ def test_get_snort_idses_monitor_threads_statuses(self, mock_get_statuses, mock_

@patch("grpc.insecure_channel")
@patch("csle_collector.snort_ids_manager.query_snort_ids_manager.get_snort_ids_monitor_status")
def test_get_snort_idses_monitor_threads_statuses_by_ip_and_port(
self, mock_get_status, mock_insecure_channel
) -> None:
def test_get_snort_idses_monitor_threads_statuses_by_ip_and_port(self, mock_get_status, mock_insecure_channel) \
-> None:
"""
Test a method that sends a request to the SnortIDSManager with a specific port and ip
to get the status of the IDS monitor thread
Expand Down Expand Up @@ -407,14 +402,13 @@ def test_get_snort_idses_managers_ports(self) -> None:

@patch("csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_ids_managers_ips")
@patch("csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_idses_managers_ports")
@patch(
"csle_common.controllers.snort_ids_controller.SnortIDSController.get_snort_idses_monitor_threads_statuses_by_ip_and_port"
)
@patch("csle_common.controllers.snort_ids_controller.SnortIDSController."
"get_snort_idses_monitor_threads_statuses_by_ip_and_port")
@patch("csle_common.util.emulation_util.EmulationUtil.physical_ip_match")
@patch("csle_collector.snort_ids_manager.snort_ids_manager_util.SnortIdsManagerUtil.snort_ids_monitor_dto_empty")
def test_get_snort_managers_info(
self, mock_snort_ids_monitor_dto_empty, mock_physical_ip_match, mock_get_statuses, mock_get_ports, mock_get_ips
) -> None:
self, mock_snort_ids_monitor_dto_empty, mock_physical_ip_match, mock_get_statuses, mock_get_ports,
mock_get_ips) -> None:
"""
Test the method that extracts the information of the Snort managers for a given emulation
Expand Down Expand Up @@ -445,7 +439,6 @@ def test_get_snort_managers_info(
logger=self.logger,
physical_server_ip=physical_server_ip,
)

mock_get_ips.assert_called_once_with(emulation_env_config=emulation_env_config)
mock_get_ports.assert_called_once_with(emulation_env_config=emulation_env_config)
mock_get_statuses.assert_any_call(port=50051, ip="10.0.0.1")

0 comments on commit 4b79964

Please sign in to comment.