from __future__ import annotations
import inspect
import os
import pytest
from ._async_utils import is_async_callable
dcap_qvl = pytest.importorskip("dcap_qvl")
RUN_NETWORK = os.getenv("DCAP_QVL_RUN_NETWORK_TESTS") == "1"
def test_get_collateral_for_fmspc_exported() -> None:
assert hasattr(dcap_qvl, "get_collateral_for_fmspc")
assert callable(dcap_qvl.get_collateral_for_fmspc)
@pytest.mark.asyncio
async def test_get_collateral_for_fmspc_returns_awaitable() -> None:
ret = dcap_qvl.get_collateral_for_fmspc(
pccs_url="https://api.trustedservices.intel.com",
fmspc="000000000000",
ca="processor",
for_sgx=True,
)
assert inspect.isawaitable(ret)
if inspect.iscoroutine(ret):
ret.close()
@pytest.mark.asyncio
@pytest.mark.skipif(
not RUN_NETWORK,
reason="Network test disabled (set DCAP_QVL_RUN_NETWORK_TESTS=1 to enable)",
)
async def test_get_collateral_for_fmspc_network_smoke() -> None:
collateral = await dcap_qvl.get_collateral_for_fmspc(
pccs_url="https://api.trustedservices.intel.com",
fmspc="B0C06F000000",
ca="processor",
for_sgx=True,
)
assert collateral is not None
assert isinstance(collateral.root_ca_crl, (bytes, bytearray))
assert isinstance(collateral.pck_crl, (bytes, bytearray))
assert isinstance(collateral.tcb_info, str)
assert isinstance(collateral.qe_identity, str)