Skip to content

Commit

Permalink
best practice improvements for how file protocol is handled before in…
Browse files Browse the repository at this point in the history
…voking selenium; adding caching for both windows/macos deps
  • Loading branch information
mitchelbaker-cisa committed Aug 1, 2024
1 parent 11117a1 commit a3f428f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .github/actions/setup-dependencies-macos/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ inputs:
runs:
using: "composite"
steps:
- name: Cache packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip=${{ hashFiles("**/requirements.txt") }}
restore-keys: ${{ runner.os }}-pip-

- name: Setup virtualenv
shell: bash
run: |
Expand Down
7 changes: 7 additions & 0 deletions .github/actions/setup-dependencies-windows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ inputs:
runs:
using: "composite"
steps:
- name: Cache packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip=${{ hashFiles("**/requirements.txt") }}
restore-keys: ${{ runner.os }}-pip-

- name: Setup virtualenv
shell: powershell
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/run_smoke_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,4 @@ jobs:
json: ${{ secrets.GWS_GITHUB_AUTOMATION_CREDS }}

- name: Execute ScubaGoggles and check for correct output
run: |
pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}"
run: pytest -s ./Testing/Functional/SmokeTests/ --subjectemail="${{ secrets.GWS_SUBJECT_EMAIL }}" --domain="${{ secrets.GWS_DOMAIN }}"
10 changes: 8 additions & 2 deletions Testing/Functional/SmokeTests/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
from smoke_test_utils import get_output_path, verify_all_outputs_exist, verify_output_type
from smoke_test_utils import (
get_output_path,
prepend_file_protocol,
verify_all_outputs_exist,
verify_output_type,
)

class SmokeTest:
def test_scubagoggles_output(self, subjectemail):
Expand All @@ -26,7 +31,8 @@ def test_scubagoggles_output(self, subjectemail):
def test_scubagoggles_report(self, browser, domain):
try:
output_path: str = get_output_path()
browser.get("file://" + os.path.join(output_path, "BaselineReports.html"))
report_path: str = prepend_file_protocol(os.path.join(output_path, "BaselineReports.html"))
browser.get(report_path)

h1 = browser.find_element(By.TAG_NAME, "h1").text
assert h1 == "SCuBA GWS Security Baseline Conformance Reports"
Expand Down
5 changes: 5 additions & 0 deletions Testing/Functional/SmokeTests/smoke_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ def get_output_path() -> str:
directories.sort(key=lambda d: os.path.getctime(d), reverse=True)
return os.path.join(os.getcwd(), directories[0])

def prepend_file_protocol(path: str) -> str:
if not path.startsWith("file://"):
path = "file://" + path
return path

def verify_output_type(output_path: str, contents: list[str]) -> list[str]:
entries: list[str] = os.listdir(output_path)
for entry in entries:
Expand Down

0 comments on commit a3f428f

Please sign in to comment.