Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRASM-2286:Add Regression Test Workflow with Dockerized Playwright in AWS #824

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0d15da6
Add new integration test, integration.yml
JCantu248 Jan 22, 2025
7b7bab4
vulnerabilities tests
jyang2139 Jan 28, 2025
21cb495
fixed tests
jyang2139 Jan 28, 2025
fb459ed
put test update
jyang2139 Jan 29, 2025
6fe3611
test
jyang2139 Jan 29, 2025
41a384c
Add method to return domain, vulnerability uids for other test cases.
JCantu248 Jan 30, 2025
15c37a7
updated test for new methods
jyang2139 Jan 30, 2025
f6ab796
Change get_domains, get_vulnerabilities to return entire object, not …
JCantu248 Feb 3, 2025
76d2a92
updates to id method
jyang2139 Feb 3, 2025
ebd4add
fixing environment variable
jyang2139 Feb 4, 2025
a083545
Merge pull request #774 from cisagov/jy_integration_tests
JCantu248 Feb 4, 2025
3df9356
Code cleanup for test_vulnerabilities.py.
JCantu248 Feb 5, 2025
dc09d63
Testing integration workflow on push.
JCantu248 Feb 6, 2025
bfd732a
Add requirements.txt, changes to test_domains.
JCantu248 Feb 6, 2025
17db7c3
Update integration.yml
aloftus23 Feb 6, 2025
c8454f6
Reverting integration.yml to only on deployment status.
JCantu248 Feb 6, 2025
6ba373a
Merge branch 'JD_integration_tests' of github.com:cisagov/XFD into JD…
JCantu248 Feb 6, 2025
45b81c9
Merge branch 'develop' into JD_integration_tests
JCantu248 Feb 26, 2025
6012cd3
Merge branch 'develop' of github.com:cisagov/XFD into JD_integration_…
JCantu248 Mar 11, 2025
abb21c2
Merge branch 'develop' of github.com:cisagov/XFD into develop
JCantu248 Mar 19, 2025
8e8f3eb
Merge branch 'develop' of github.com:cisagov/XFD into develop
JCantu248 Mar 21, 2025
2a42ebd
Add regression.yml for Dockerized Playwright actions, modifications t…
JCantu248 Mar 21, 2025
d1459d3
Remove integration tests that were accidentally included in this branch
JCantu248 Mar 21, 2025
b31871d
Fixed startup issue with Github secrets reference in container image.
JCantu248 Mar 21, 2025
30225d6
Create separate jobs for playwright tests on develop, integration bra…
JCantu248 Mar 27, 2025
a53fabb
Merge branch 'develop' of github.com:cisagov/XFD into CRASM_2286_Gith…
JCantu248 Mar 27, 2025
ada20d8
Add quotes for container image in playwright terraform config.
JCantu248 Mar 27, 2025
4c5403e
Add a comma after image.
JCantu248 Mar 27, 2025
12872c9
Fix yaml linter errors with line length on regression.yml
JCantu248 Mar 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -40,10 +40,6 @@ jobs:
touch .env
echo "X_API_KEY=${{ secrets['${{ matrix.environment | upper }}\
_X_API_KEY'] }}" >> .env
echo "DOMAIN_UID=${{ secrets['${{ matrix.environment | upper }}\
_DOMAIN_UID'] }}" >> .env
echo "SEARCH_IP=${{ secrets['${{ matrix.environment | upper }}\
_SEARCH_IP'] }}" >> .env

- name: Run integration tests
run: |
22 changes: 13 additions & 9 deletions integration/tests/test_domains.py
Original file line number Diff line number Diff line change
@@ -7,12 +7,12 @@
import pytest
import requests

BASE_URL = "http://localhost:3000"
BASE_URL = os.environ.get("BACKEND_DOMAIN")
X_API_KEY = os.environ.get("X_API_KEY")
BAD_ID = "01234567-0123-4567-8901-12345"


def get_domain_ids():
def get_domains():
"""Get a tuple of domain IDs for testing."""
url = "{}/domain/search".format(BASE_URL)
json = {
@@ -29,17 +29,18 @@ def get_domain_ids():
assert "result" in data, "Results not found in response"
assert len(data["result"]) > 0, "No results found"

# Extract domain IDs
domain_ids = [domain["id"] for domain in data["result"]]
return tuple(domain_ids)
return data["result"]


domains = get_domains()


# mark tests with integration tag, run with pytest -m integration
@pytest.mark.integration
def test_get_domain_by_id():
"""Test get domain by id."""
domain_ids = get_domain_ids()
domain_id = random.choice(domain_ids)
selected_domain = random.choice(domains)
domain_id = selected_domain["id"]

url = "{}/domain/{}".format(BASE_URL, domain_id)
print(url)
@@ -67,11 +68,14 @@ def test_get_domain_by_id_fails_404():
@pytest.mark.integration
def test_search_domain_by_ip():
"""Test search domain by IP."""
selected_domain = random.choice(domains)
domain_ip = selected_domain["ip"]

url = "{}/domain/search".format(BASE_URL)
json = {
"page": 1,
"filters": {
"ip": os.environ.get("SEARCH_IP"),
"ip": domain_ip,
},
"pageSize": 10,
}
@@ -86,4 +90,4 @@ def test_search_domain_by_ip():

# Validate result contain the correct IP
for domain in data["result"]:
assert domain["ip"] == "127.39.232.192", "IP does not match"
assert domain["ip"] == domain_ip, "IP does not match"
20 changes: 12 additions & 8 deletions integration/tests/test_vulnerabilities.py
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
BAD_ID = "c0effe93-3647-475a-a0c5-0b629c348590"


def get_vulnerability_ids():
def get_vulnerabilities():
"""Get a tuple of vulnerability IDs for testing."""
url = "{}/vulnerabilities/search".format(BASE_URL)
json = {
@@ -28,19 +28,17 @@ def get_vulnerability_ids():
assert data is not None, "Response is empty"
assert "result" in data, "Results not found in response"
assert len(data["result"]) > 0, "No results found"
# Extract domain IDs
vulnerability_ids = [vulnerability["id"] for vulnerability in data["result"]]
return tuple(vulnerability_ids)


vulnerability_ids = get_vulnerability_ids()
vulnerability_id = random.choice(vulnerability_ids)
return data["result"]


# mark tests with integration tag, run with pytest -m integration
@pytest.mark.integration
def test_get_vulnerability_by_id():
"""Test get vulnerability by ID."""
vulnerabilities = get_vulnerabilities()
select_vulnerability = random.choice(vulnerabilities)
vulnerability_id = select_vulnerability["id"]
url = f"{BASE_URL}/vulnerabilities/{vulnerability_id}"
response = requests.get(url, headers={"X-API-KEY": X_API_KEY}, timeout=10)

@@ -51,7 +49,7 @@ def test_get_vulnerability_by_id():
assert data is not None, "Response is empty"
assert (
data["id"] == vulnerability_id
), f"Expected ID {vulnerability_id}, got {data['id']}"
), f"Expected ID {select_vulnerability}, got {data['id']}"


@pytest.mark.integration
@@ -107,6 +105,9 @@ def test_search_vulnerabilities():
def test_get_update_and_revert_vulnerability_by_id():
"""Test get vulnerability by ID, update fields, and revert back to original."""
# Step 1: Retrieve the original data using GET
vulnerabilities = get_vulnerabilities()
select_vulnerability = random.choice(vulnerabilities)
vulnerability_id = select_vulnerability["id"]
url = f"{BASE_URL}/vulnerabilities/{vulnerability_id}"
response = requests.get(url, headers={"X-API-KEY": X_API_KEY}, timeout=10)
assert (
@@ -214,6 +215,9 @@ def test_update_vulnerability_by_id_fails_404():
@pytest.mark.integration
def test_update_vulnerability_by_id_fails_422():
"""Test update vulnerability by ID fails with 422 due to invalid payload."""
vulnerabilities = get_vulnerabilities()
select_vulnerability = random.choice(vulnerabilities)
vulnerability_id = select_vulnerability["id"]
url = f"{BASE_URL}/vulnerabilities/{vulnerability_id}"
json = {
"id": vulnerability_id,