feat: prepare postgres sbom cutover
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a028f0-a42f-7582-89a8-ebaad7343834
This commit is contained in:
parent
cf7e3acb78
commit
ba535e1f8f
26 changed files with 1573 additions and 411 deletions
52
tests/test_postgres_integration.py
Normal file
52
tests/test_postgres_integration.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from sbom_nexus.api import create_app
|
||||
|
||||
POSTGRES_URL = os.getenv("SBOM_NEXUS_TEST_POSTGRES_URL")
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not POSTGRES_URL,
|
||||
reason="SBOM_NEXUS_TEST_POSTGRES_URL is not configured",
|
||||
)
|
||||
|
||||
|
||||
def test_migrated_postgres_runtime_contract() -> None:
|
||||
assert POSTGRES_URL is not None
|
||||
client = TestClient(create_app(POSTGRES_URL))
|
||||
|
||||
assert client.get("/state/health").json() == {
|
||||
"status": "ok",
|
||||
"store": "connected",
|
||||
"dialect": "postgresql",
|
||||
}
|
||||
response = client.put(
|
||||
"/repositories/postgres-contract",
|
||||
json={"active": True},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
|
||||
ingest = client.post(
|
||||
"/sbom/ingest/",
|
||||
json={
|
||||
"repo_slug": "postgres-contract",
|
||||
"entries": [
|
||||
{
|
||||
"package_name": "psycopg",
|
||||
"package_version": "3.2",
|
||||
"ecosystem": "python",
|
||||
"license_spdx": "LGPL-3.0-only",
|
||||
"is_direct": True,
|
||||
"is_dev": False,
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
assert ingest.status_code == 200
|
||||
assert ingest.json()["ingested"] == 1
|
||||
assert client.get("/sbom/postgres-contract").json()["entry_count"] == 1
|
||||
assert client.get("/sbom/report/licences/").json()["copyleft_direct_count"] == 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue