Skip to content

Commit 27beb00

Browse files
fix: repair enrichment integration runner
1 parent f50b70b commit 27beb00

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

libs/file_enrichment_modules/tests/integration/run_e2e_test.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
DEFAULT_API_HOST = "localhost:7443"
3434
DEFAULT_USERNAME = "n"
3535
DEFAULT_PASSWORD = "n"
36+
DEFAULT_HASURA_ADMIN_SECRET = os.environ.get("HASURA_ADMIN_SECRET", "pass456")
3637
DEFAULT_PROJECT = "e2e-test"
3738
MAX_WAIT_SECONDS = 120
3839
POLL_INTERVAL_SECONDS = 5
@@ -41,7 +42,7 @@
4142
def check_nemesis_health(host: str, username: str, password: str) -> bool:
4243
"""Check if Nemesis API is healthy."""
4344
try:
44-
url = f"https://{host}/api/health"
45+
url = f"https://{host}/api/system/health"
4546
response = httpx.get(url, auth=(username, password), verify=False, timeout=10)
4647
return response.status_code == 200
4748
except Exception as e:
@@ -177,6 +178,7 @@ def wait_for_enrichment(
177178
host: str,
178179
username: str,
179180
password: str,
181+
hasura_admin_secret: str,
180182
project: str,
181183
module_name: str,
182184
max_wait: int = MAX_WAIT_SECONDS,
@@ -185,7 +187,7 @@ def wait_for_enrichment(
185187
print(f"Waiting for enrichment by module '{module_name}' (max {max_wait}s)...")
186188

187189
# Query Hasura for enrichment results
188-
hasura_url = f"https://{host}/v1/graphql"
190+
hasura_url = f"https://{host}/hasura/v1/graphql"
189191

190192
# Map module names to their analyzer names
191193
module_to_analyzer = {
@@ -199,30 +201,29 @@ def wait_for_enrichment(
199201
analyzer_name = module_to_analyzer.get(module_name, f"{module_name}_analyzer")
200202

201203
query = """
202-
query GetEnrichment($module_name: String!, $project: String!) {
204+
query GetEnrichment($module_name: String!, $finding_origin_name: String!, $project: String!) {
203205
enrichments(
204206
where: {
205207
module_name: {_eq: $module_name},
206-
file: {project: {_eq: $project}}
208+
files_enriched: {project: {_eq: $project}}
207209
},
208210
order_by: {created_at: desc},
209211
limit: 1
210212
) {
211-
id
212213
object_id
213214
module_name
214215
created_at
215-
results
216+
result_data
216217
}
217218
findings(
218219
where: {
219-
origin_name: {_eq: $module_name},
220-
file: {project: {_eq: $project}}
220+
origin_name: {_eq: $finding_origin_name},
221+
files_enriched: {project: {_eq: $project}}
221222
},
222223
order_by: {created_at: desc},
223224
limit: 10
224225
) {
225-
id
226+
finding_id
226227
object_id
227228
category
228229
finding_name
@@ -241,11 +242,13 @@ def wait_for_enrichment(
241242
json={
242243
"query": query,
243244
"variables": {
244-
"module_name": analyzer_name,
245+
"module_name": module_name,
246+
"finding_origin_name": analyzer_name,
245247
"project": project,
246248
},
247249
},
248250
auth=(username, password),
251+
headers={"x-hasura-admin-secret": hasura_admin_secret},
249252
verify=False,
250253
timeout=10,
251254
)
@@ -261,6 +264,10 @@ def wait_for_enrichment(
261264
"enrichments": enrichments,
262265
"findings": findings,
263266
}
267+
elif "errors" in data:
268+
print(f" GraphQL errors: {data['errors']}")
269+
else:
270+
print(f" GraphQL HTTP {response.status_code}: {response.text}")
264271

265272
print(f" No results yet, waiting {POLL_INTERVAL_SECONDS}s...")
266273
time.sleep(POLL_INTERVAL_SECONDS)
@@ -372,6 +379,11 @@ def main():
372379
default=DEFAULT_PASSWORD,
373380
help=f"API password (default: {DEFAULT_PASSWORD})",
374381
)
382+
parser.add_argument(
383+
"--hasura-admin-secret",
384+
default=DEFAULT_HASURA_ADMIN_SECRET,
385+
help="Hasura admin secret (default: HASURA_ADMIN_SECRET env var or compose default)",
386+
)
375387
parser.add_argument(
376388
"--project",
377389
default=DEFAULT_PROJECT,
@@ -453,6 +465,7 @@ def main():
453465
args.host,
454466
args.username,
455467
args.password,
468+
args.hasura_admin_secret,
456469
args.project,
457470
args.module,
458471
args.max_wait,

0 commit comments

Comments
 (0)