Commit e418bbbf authored by George Papathanail's avatar George Papathanail
Browse files

fix: decalre x-correlator on fake caller contexts so header validation runs

parent 393c9cb0
Loading
Loading
Loading
Loading
+4 −1
Changes for tests/conformance/test_location_retrieval_conformance.py: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ import pytest
import schemathesis
from fastapi import Request

from open_exposure_gateway.api.camara.common import XCorrelatorHeader
from open_exposure_gateway.api.error_handlers import x_correlator_header
from open_exposure_gateway.core.auth.tokens import TokenFlow
from open_exposure_gateway.dependencies import CallerContext, get_caller_context
@@ -23,7 +24,9 @@ if TYPE_CHECKING:
pytestmark = pytest.mark.conformance


def _three_legged_caller_context(request: Request) -> CallerContext:
def _three_legged_caller_context(
    request: Request, x_correlator: XCorrelatorHeader = None
) -> CallerContext:
    """Location Retrieval always requires a three-legged token (core/authorization.py),
    unlike the other CAMARA APIs conftest's package-wide fake_caller_context covers."""
    return CallerContext(
+2 −1
Changes for tests/unit/conftest.py: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import pytest
from fastapi import Request
from fastapi.testclient import TestClient

from open_exposure_gateway.api.camara.common import XCorrelatorHeader
from open_exposure_gateway.api.camara.edge_application_management.v0_1_0_alpha_1.router import (
    BASE_PATH as EAM_BASE,
)
@@ -50,7 +51,7 @@ from tests.unit.fakes import (
)


def fake_caller_context(request: Request) -> CallerContext:
def fake_caller_context(request: Request, x_correlator: XCorrelatorHeader = None) -> CallerContext:
    """Override for get_caller_context: skips real JWT verification but keeps the
    x-correlator resolution real, since several tests assert on its propagation."""
    return CallerContext(
+4 −1
Changes for tests/unit/test_location_retrieval_flows.py: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import pytest
from fastapi import Request
from fastapi.testclient import TestClient

from open_exposure_gateway.api.camara.common import XCorrelatorHeader
from open_exposure_gateway.api.camara.location_retrieval.v0_5_0.router import (
    BASE_PATH as LOCATION_BASE,
)
@@ -21,7 +22,9 @@ from open_exposure_gateway.main import app
from tests.unit.fakes import FakeDataBus, FakeSRMClient


def _three_legged_caller_context(request: Request) -> CallerContext:
def _three_legged_caller_context(
    request: Request, x_correlator: XCorrelatorHeader = None
) -> CallerContext:
    """Location Retrieval always requires a three-legged token (core/authorization.py),
    unlike the other CAMARA APIs api_client's default fake_caller_context covers."""
    return CallerContext(