Skip to content

Commit

Permalink
remove 3.8 from workflow; convert some static strings to const
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelbaker-cisa committed Aug 2, 2024
1 parent ec33d00 commit 1da117b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run_smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
os: [windows-latest, macos-latest]
# 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"]
python-version: ["3.9", "3.10", "3.11", "3.12"] # "3.8 fails with numpy uninstall"
runs-on: ${{ matrix.os }}
environment: Development
steps:
Expand Down
11 changes: 8 additions & 3 deletions Testing/Functional/SmokeTests/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,27 @@
run_selenium,
verify_scubaresults,
)

SAMPLE_REPORT = "sample-report"
SCUBA_RESULTS = "ScubaResults.json"
BASELINE_REPORTS = "BaselineReports.html"

class SmokeTest:
def test_scubagoggles_output(self, subjectemail):
try:
command: str = f"scubagoggles gws --subjectemail {subjectemail} --quiet"
subprocess.run(command, shell=True)
output_path: str = get_output_path()
output: list = verify_output_type(output_path, [])
required_entries = get_required_entries(os.path.join(os.getcwd(), "sample-report"), [])
required_entries = get_required_entries(os.path.join(os.getcwd(), SAMPLE_REPORT), [])
verify_all_outputs_exist(output, required_entries)
except (OSError, ValueError, Exception) as e:
pytest.fail(f"An error occurred, {e}")

def test_scubaresults(self):
try:
output_path: str = get_output_path()
scubaresults_path: str = os.path.join(output_path, "ScubaResults.json")
scubaresults_path: str = os.path.join(output_path, SCUBA_RESULTS)
with open(scubaresults_path) as jsonfile:
verify_scubaresults(jsonfile)
except ValueError as e:
Expand All @@ -46,7 +51,7 @@ def test_scubaresults(self):
def test_scubagoggles_report(self, browser, domain):
try:
output_path: str = get_output_path()
report_path: str = prepend_file_protocol(os.path.join(output_path, "BaselineReports.html"))
report_path: str = prepend_file_protocol(os.path.join(output_path, BASELINE_REPORTS))
browser.get(report_path)
run_selenium(browser, domain)
except (ValueError, Exception) as e:
Expand Down
9 changes: 7 additions & 2 deletions Testing/Functional/SmokeTests/smoke_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions

OUTPUT_DIRECTORY = "GWSBaselineConformance"
BASELINE_REPORT_H1 = "SCuBA GWS Security Baseline Conformance Reports"
CISA_GOV_URL = "https://www.cisa.gov/scuba"
SCUBAGOGGLES_BASELINES_URL = "https://github.com/cisagov/ScubaGoggles/tree/main/baselines"

def get_output_path() -> str:
directories: list = [d for d in os.listdir() if os.path.isdir(d) and d.startswith("GWSBaselineConformance")]
directories: list = [
d for d in os.listdir()
if os.path.isdir(d) and d.startswith(OUTPUT_DIRECTORY)
]
directories.sort(key=lambda d: os.path.getctime(d), reverse=True)
return os.path.join(os.getcwd(), directories[0])

Expand Down Expand Up @@ -68,7 +73,7 @@ def verify_scubaresults(jsonfile):
def run_selenium(browser, domain):
verify_navigation_links(browser)
h1 = browser.find_element(By.TAG_NAME, "h1").text
assert h1 == "SCuBA GWS Security Baseline Conformance Reports"
assert h1 == BASELINE_REPORT_H1

products = {
product: { "title": f"{product} Baseline Report" }
Expand Down

0 comments on commit 1da117b

Please sign in to comment.