Skip to content

Commit

Permalink
Rewrote Selenium Tests for Sysmon Summary Dashboard (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
rishagg01 committed May 14, 2024
1 parent 3620140 commit 66a65aa
Showing 1 changed file with 22 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException
from .lib import dashboard_test_function

class TestSysmonSummaryDashboard:
dashboard_id = "d2c73990-e5d4-11e9-8f1d-73a2ea4cc3ed"
Expand All @@ -15,52 +16,33 @@ def setup_login(self, driver, login):

def test_count_of_sysmon_events_by_event_code(self, setup_login, kibana_url, timeout):
driver = setup_login
driver.get(f"{kibana_url}/app/dashboards#/view/{self.dashboard_id}")
expected_cond = EC.presence_of_element_located((By.CLASS_NAME, "react-grid-layout"))
WebDriverWait(driver, timeout).until(expected_cond)
panel_title = "Count of Sysmon events by event code"
selector = f'div[data-title="{panel_title}"]'
expected_cond = EC.presence_of_element_located((By.CSS_SELECTOR, selector))
WebDriverWait(driver, timeout).until(expected_cond)
panel = driver.find_element(By.CSS_SELECTOR, selector)
assert "No results found" not in panel.get_attribute("innerHTML")
dashboard_test_function(driver, kibana_url, timeout, self.dashboard_id, "Count of Sysmon events by event code", ".tbvChart",".visError")


def test_total_number_of_sysmon_events_found(self, setup_login, kibana_url, timeout):
driver = setup_login
dashboard_test_function(driver, kibana_url, timeout, self.dashboard_id, "Total number of Sysmon events found", ".visualization",".dummyval")
# The arguement ".dummyval" is being used though it is not a valid selector.
# This panel should always have a visualization so there should never be no data message displayed.
# If there is no visualization rendered or "No Results found" message is displayed for this panel on dashboard, this test should fail which is correct behavior



def test_percentage_of_sysmon_events_by_event_code(self, setup_login, kibana_url, timeout):
driver = setup_login
driver.get(f"{kibana_url}/app/dashboards#/view/{self.dashboard_id}")
expected_cond = EC.presence_of_element_located((By.CLASS_NAME, "react-grid-layout"))
WebDriverWait(driver, timeout).until(expected_cond)
panel_title = "Percentage of Sysmon events by event code"
selector = f'div[data-title="{panel_title}"]'
expected_cond = EC.presence_of_element_located((By.CSS_SELECTOR, selector))
WebDriverWait(driver, timeout).until(expected_cond)
panel = driver.find_element(By.CSS_SELECTOR, selector)
assert "No results found" not in panel.get_attribute("innerHTML")

@pytest.mark.skip(reason="Skipping this test")
dashboard_test_function(driver, kibana_url, timeout, self.dashboard_id, "Percentage of Sysmon events by event code", ".echChart",".euiText")

def test_sysmon_events(self, setup_login, kibana_url, timeout):
driver = setup_login
driver.get(f"{kibana_url}/app/dashboards#/view/{self.dashboard_id}")
expected_cond = EC.presence_of_element_located((By.CLASS_NAME, "react-grid-layout"))
WebDriverWait(driver, timeout).until(expected_cond)
panel_title = "Sysmon events"
selector = f'div[data-title="{panel_title}"]'
expected_cond = EC.presence_of_element_located((By.CSS_SELECTOR, selector))
WebDriverWait(driver, timeout).until(expected_cond)
panel = driver.find_element(By.CSS_SELECTOR, selector)
assert "No results found" not in panel.get_attribute("innerHTML")

@pytest.mark.skip(reason="Skipping this test")
dashboard_test_function(driver, kibana_url, timeout, self.dashboard_id, "Sysmon events", ".echChart",".visError")

def test_top10_hosts_generating_most_sysmon_data(self, setup_login, kibana_url, timeout):
driver = setup_login
driver.get(f"{kibana_url}/app/dashboards#/view/{self.dashboard_id}")
expected_cond = EC.presence_of_element_located((By.CLASS_NAME, "react-grid-layout"))
WebDriverWait(driver, timeout).until(expected_cond)
panel_title = "Top 10 hosts generating the most Sysmon data"
selector = f'div[data-title="{panel_title}"]'
expected_cond = EC.presence_of_element_located((By.CSS_SELECTOR, selector))
WebDriverWait(driver, timeout).until(expected_cond)
panel = driver.find_element(By.CSS_SELECTOR, selector)
assert "No results found" not in panel.get_attribute("innerHTML")
dashboard_test_function(driver, kibana_url, timeout, self.dashboard_id, "Top 10 hosts generating the most Sysmon data", ".tbvChart",".visError")


def test_sysmon_events_code_reference(self, setup_login, kibana_url, timeout):
driver = setup_login
dashboard_test_function(driver, kibana_url, timeout, self.dashboard_id, "Sysmon event code reference", ".visualization",".dummyval")


0 comments on commit 66a65aa

Please sign in to comment.