From 20effb7d2324f061d6a6f45188236ea4b12bfce9 Mon Sep 17 00:00:00 2001 From: Joshua Hiller Date: Sat, 27 Aug 2022 20:38:59 -0400 Subject: [PATCH] Expand unit testing to complete code coverage --- .github/wordlist.txt | 1 + tests/test_falcon_container.py | 4 ++++ tests/test_hosts.py | 2 ++ tests/test_uber_api_complete.py | 10 ++++++++++ 4 files changed, 17 insertions(+) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index 370733606..34330d9e9 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -751,3 +751,4 @@ userRolesActionV userActionV entitiesRolesV combinedUserRolesV +NoneType diff --git a/tests/test_falcon_container.py b/tests/test_falcon_container.py index 353e1a84f..82d26052f 100644 --- a/tests/test_falcon_container.py +++ b/tests/test_falcon_container.py @@ -3,6 +3,7 @@ """ import os import sys +import pytest # Authentication via the test_authorization.py from tests import test_authorization as Authorization # Import our sibling src folder into the path @@ -44,6 +45,9 @@ def test_get_credentials(self): """Pytest harness hook""" assert bool(falcon.get_credentials()["status_code"] in AllowedResponses) is True + @pytest.mark.skipif(os.getenv("DEBUG_API_BASE_URL", "us1").lower() in ["https://api.eu-1.crowdstrike.com", "eu1", "https://api.laggar.gcw.crowdstrike.com", "usgov1"], + reason="Unit testing unavailable on US-GOV-1 / EU-1" + ) def test_remaining_code_paths(self): """Pytest harness hook""" assert self.run_tests() is True diff --git a/tests/test_hosts.py b/tests/test_hosts.py index 11ca111ef..8ef9dc262 100644 --- a/tests/test_hosts.py +++ b/tests/test_hosts.py @@ -141,6 +141,8 @@ def hosts_generate_errors(self): "perform_action_params": falcon.PerformActionV2(body={}, parameters={'action_name': 'PooF'})["status_code"], "perform_action_null": falcon.PerformActionV2(body={}, parameters={})["status_code"], "get_device_details": falcon.GetDeviceDetails(ids='12345678')["status_code"], + "get_device_detailsv1": falcon.GetDeviceDetailsV1(ids='12345678')["status_code"], + "get_device_detailsv2": falcon.GetDeviceDetailsV2(ids='12345678')["status_code"], "query_hidden_devices": falcon.QueryHiddenDevices()["status_code"], "query_devices_by_filter_scroll": falcon.QueryDevicesByFilterScroll()["status_code"], "query_devices_by_filter": falcon.QueryDevicesByFilter()["status_code"], diff --git a/tests/test_uber_api_complete.py b/tests/test_uber_api_complete.py index 440a90619..beb3abd6a 100644 --- a/tests/test_uber_api_complete.py +++ b/tests/test_uber_api_complete.py @@ -162,6 +162,13 @@ def uberCCAWS_OverrideAndHeader(self): else: return False + def uberContainer_TestBodyIDsPayload(self): + successful = False + if falcon.command("GetDeviceDetails", ids="12345678")["status_code"] in AllowedResponses: + successful = True + + return successful + def uberCCAWS_TestMSSP(self): if falcon.command("QueryDetects", limit=1)["status_code"] == 429: pytest.skip("Rate limit hit") @@ -299,6 +306,9 @@ def test_PreferredDefaultLookup(self): falcon.command("report_executions_download_get", ids="1234567890")["status_code"] in AllowedResponses ) is True + def test_ContainerBodyIDPayload(self): + assert self.uberContainer_TestBodyIDsPayload() is True + def test_GenerateActionNameError(self): assert self.uberCCHosts_GenerateActionNameError(params=None) is True