Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion axme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from axme_sdk import AxmeClient, AxmeClientConfig
from axme_sdk import __version__, AxmeClient, AxmeClientConfig
from axme_sdk.exceptions import (
AxmeAuthError,
AxmeError,
Expand All @@ -9,6 +9,7 @@
)

__all__ = [
"__version__",
"AxmeClient",
"AxmeClientConfig",
"AxmeAuthError",
Expand Down
3 changes: 3 additions & 0 deletions axme_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
__version__ = "0.2.0"

from .client import AxmeClient, AxmeClientConfig
from .mesh import MeshClient
from .exceptions import (
Expand All @@ -10,6 +12,7 @@
)

__all__ = [
"__version__",
"AxmeClient",
"AxmeClientConfig",
"MeshClient",
Expand Down
2 changes: 2 additions & 0 deletions axme_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1885,9 +1885,11 @@ def _notify_mcp_observer(self, event: dict[str, Any]) -> None:
observer(event)

def _default_headers(self) -> dict[str, str]:
from . import __version__ as _sdk_version
headers = {
"x-api-key": self._config.api_key,
"Content-Type": "application/json",
"X-Axme-Client": f"axme-sdk-python/{_sdk_version}",
}
if self._config.actor_token:
headers["Authorization"] = f"Bearer {self._config.actor_token}"
Expand Down
15 changes: 15 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def _client(
retry_backoff_seconds=retry_backoff_seconds,
auto_trace_id=auto_trace_id,
)
from axme import __version__ as _sdk_version
default_headers = {
"x-api-key": cfg.api_key,
"Content-Type": "application/json",
"X-Axme-Client": f"axme-sdk-python/{_sdk_version}",
}
if cfg.actor_token:
default_headers["Authorization"] = f"Bearer {cfg.actor_token}"
Expand Down Expand Up @@ -103,6 +105,19 @@ def handler(request: httpx.Request) -> httpx.Response:
assert client.health(trace_id="trace-123") == {"ok": True}


def test_health_sends_x_axme_client_header() -> None:
"""Every outgoing request must carry X-Axme-Client: axme-sdk-python/<version>."""
from axme_sdk import __version__ as sdk_version

def handler(request: httpx.Request) -> httpx.Response:
client_header = request.headers.get("x-axme-client", "")
assert client_header == f"axme-sdk-python/{sdk_version}", client_header
return httpx.Response(200, json={"ok": True})

client = _client(handler)
assert client.health() == {"ok": True}


def test_health_includes_actor_token_authorization_when_configured() -> None:
def handler(request: httpx.Request) -> httpx.Response:
assert request.headers["x-api-key"] == "platform-key"
Expand Down
Loading