Skip to content

Commit

Permalink
expand selenium testing of scubagoggles reports, checks parent/indivi…
Browse files Browse the repository at this point in the history
…dual reports
  • Loading branch information
mitchelbaker-cisa committed Aug 1, 2024
1 parent 3bc5eab commit b484e70
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 29 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/run_smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
python-version: ["3.8.4", "3.12"]
# See https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json,
# ctrl + f and search "python-3.<minor>.<patch>-<darwin-arm64/win32/linux>" for supported versions
python-version: ["3.8.10", "3.9", "3.10", "3.12"]
runs-on: ${{ matrix.os }}
environment: Development
steps:
Expand Down
79 changes: 51 additions & 28 deletions Testing/Functional/SmokeTests/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
verify_all_outputs_exist,
verify_output_type,
)
from scubagoggles.orchestrator import gws_products

class SmokeTest:
def test_scubagoggles_output(self, subjectemail):
Expand All @@ -40,52 +41,74 @@ def test_scubagoggles_report(self, browser, domain):
h1 = browser.find_element(By.TAG_NAME, "h1").text
assert h1 == "SCuBA GWS Security Baseline Conformance Reports"

# verify domain is present in agency table
agency_table = browser.find_element(By.TAG_NAME, "table")
tbody = agency_table.find_element(By.TAG_NAME, "tbody")
rows = tbody.find_elements(By.TAG_NAME, "tr")
assert len(rows) == 2
assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain

baseline_names = [
"Google Calendar",
"Google Chat",
"Google Classroom",
"Common Controls",
"Google Drive and Docs",
"Gmail",
"Groups for Business",
"Google Meet",
"Rules",
"Google Sites"
]
products = {
product: { "title": f"{product} Baseline Report" }
for product in gws_products()["prod_to_fullname"].values()
}

print(products)

# Before entering loop check that we actually display 10 rows in table

for i in range(10):
# verify domain is present in agency table
tenant_table = browser.find_element(By.TAG_NAME, "table")
tbody = tenant_table.find_element(By.TAG_NAME, "tbody")
rows = tbody.find_elements(By.TAG_NAME, "tr")
assert len(rows) == 2
assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain

reports_table = browser.find_elements(By.TAG_NAME, "table")[1]
tbody = reports_table.find_element(By.TAG_NAME, "tbody")
rows = tbody.find_elements(By.TAG_NAME, "tr")
td = rows[i].find_elements(By.TAG_NAME, "td")[0]
assert td.text in baseline_names
product = td.text
assert product in products

individual_report_anchor = td.find_element(By.TAG_NAME, "a")
href = individual_report_anchor.get_attribute("href")
individual_report_anchor.click()
current_url = browser.current_url
assert href == current_url

# Check at the individual report level
tenant_table = browser.find_element(By.TAG_NAME, "table")
tbody = tenant_table.find_element(By.TAG_NAME, "tbody")
rows = tbody.find_elements(By.TAG_NAME, "tr")
assert len(rows) == 2
assert rows[1].find_elements(By.TAG_NAME, "td")[0].text == domain

h1 = browser.find_element(By.TAG_NAME, "h1").text
print(products[product])
print(products[product]["title"])
assert h1 == products[product]["title"]

policy_tables = browser.find_elements(By.TAG_NAME, "table")
for table in policy_tables[1:]:
# Verify policy table headers are correct
headers = (
table.find_element(By.TAG_NAME, "thead")
.find_elements(By.TAG_NAME, "tr")[0]
.find_elements(By.TAG_NAME, "th")
)
assert len(headers) == 5
assert headers[0].text == "Control ID"
assert headers[1].text == "Requirement" or "Rule Name"
assert headers[2].text == "Result"
assert headers[3].text == "Criticality"
assert headers[4].text == "Details" or "Rule Description"

# Verify policy table rows are populated
tbody = table.find_element(By.TAG_NAME, "tbody")
rows = tbody.find_elements(By.TAG_NAME, "tr")
assert len(rows) > 0

browser.back()
WebDriverWait(browser, 10).until(
expected_conditions.presence_of_element_located(
(By.TAG_NAME, "body")
)
)

# Navigation to detailed reports

# Check links work

# Verify tables are populated


except Exception as e:
browser.quit()
pytest.fail(f"An error occurred, {e}")

0 comments on commit b484e70

Please sign in to comment.