Skip to content

Commit

Permalink
SOAR-15940-updated unit tests for advanced_query_on_log_set to includ…
Browse files Browse the repository at this point in the history
…e schema validation
  • Loading branch information
rbowden-r7 committed Nov 10, 2023
1 parent de57cfb commit 21e01e7
Showing 1 changed file with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

from unittest import TestCase
from komand_rapid7_insightidr.actions.advanced_query_on_log_set import AdvancedQueryOnLogSet
from komand_rapid7_insightidr.actions.advanced_query_on_log_set.schema import Input, Output, AdvancedQueryOnLogSetInput, AdvancedQueryOnLogSetOutput
from komand_rapid7_insightidr.actions.advanced_query_on_log_set.schema import (
Input,
Output,
AdvancedQueryOnLogSetInput,
AdvancedQueryOnLogSetOutput,
)
from util import Util
from unittest.mock import patch
from jsonschema import validate
Expand All @@ -20,10 +25,10 @@ def setUpClass(cls) -> None:

def test_advanced_query_on_log_set_one_label(self, mock_get, mock_async_get):
test_input = {
Input.QUERY: "",
Input.LOG_SET: "Advanced Malware Alert",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes"
Input.QUERY: "",
Input.LOG_SET: "Advanced Malware Alert",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes",
}

validate(test_input, AdvancedQueryOnLogSetInput.schema)
Expand All @@ -39,10 +44,10 @@ def test_advanced_query_on_log_set_one_label(self, mock_get, mock_async_get):

def test_advanced_query_on_log_set_two_label(self, mock_get, mock_async_get):
test_input = {
Input.QUERY: "",
Input.LOG_SET: "Active Directory Admin Activity",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes"
Input.QUERY: "",
Input.LOG_SET: "Active Directory Admin Activity",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes",
}

validate(test_input, AdvancedQueryOnLogSetInput.schema)
Expand All @@ -58,10 +63,10 @@ def test_advanced_query_on_log_set_two_label(self, mock_get, mock_async_get):

def test_advanced_query_on_log_set_without_label(self, mock_get, mock_async_get):
test_input = {
Input.QUERY: "",
Input.LOG_SET: "Asset Authentication",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes"
Input.QUERY: "",
Input.LOG_SET: "Asset Authentication",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes",
}

validate(test_input, AdvancedQueryOnLogSetInput.schema)
Expand All @@ -76,10 +81,10 @@ def test_advanced_query_on_log_set_without_label(self, mock_get, mock_async_get)

def test_advanced_query_on_log_set_wrong_label(self, mock_get, mock_async_get):
test_input = {
Input.QUERY: "",
Input.LOG_SET: "Cloud Service Admin Activity",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes"
Input.QUERY: "",
Input.LOG_SET: "Cloud Service Admin Activity",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes",
}

validate(test_input, AdvancedQueryOnLogSetInput.schema)
Expand All @@ -94,10 +99,10 @@ def test_advanced_query_on_log_set_wrong_label(self, mock_get, mock_async_get):

def test_advanced_query_on_log_statistical_result_calculate(self, mock_get, mock_async_get):
test_input = {
Input.QUERY: "where(hostname='WindowsX64') calculate(count)",
Input.LOG_SET: "Cloud Service Activity",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes"
Input.QUERY: "where(hostname='WindowsX64') calculate(count)",
Input.LOG_SET: "Cloud Service Activity",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes",
}

validate(test_input, AdvancedQueryOnLogSetInput.schema)
Expand Down Expand Up @@ -156,10 +161,10 @@ def test_advanced_query_on_log_statistical_result_calculate(self, mock_get, mock

def test_advanced_query_on_log_statistical_result_groupby(self, mock_get, mock_async_get):
test_input = {
Input.QUERY: "groupby(r7_context.asset.name)",
Input.LOG_SET: "DNS Query",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes"
Input.QUERY: "groupby(r7_context.asset.name)",
Input.LOG_SET: "DNS Query",
Input.TIMEOUT: 60,
Input.RELATIVE_TIME: "Last 5 Minutes",
}

validate(test_input, AdvancedQueryOnLogSetInput.schema)
Expand Down Expand Up @@ -237,4 +242,4 @@ def test_advanced_query_on_log_statistical_result_groupby(self, mock_get, mock_a
}

self.assertEqual(actual, expected)
validate(actual, AdvancedQueryOnLogSetOutput.schema)
validate(actual, AdvancedQueryOnLogSetOutput.schema)

0 comments on commit 21e01e7

Please sign in to comment.