Files
api_gateway/tests/test_api_keys.py
furyhawk 64b4daeb50 Add administrative portal and API key management features
- Implement admin portal at `/admin/portal` with dashboard and configuration editor.
- Add endpoints for API key creation, listing, and revocation.
- Introduce runtime configuration editing with validation.
- Enhance gateway settings to support API key protection.
- Create ApiKeyStore for managing API keys with persistence.
- Update tests to cover new admin functionalities and API key lifecycle.
2026-05-31 22:18:19 +08:00

20 lines
582 B
Python

from __future__ import annotations
from gateway_framework.api_keys import ApiKeyStore
def test_api_key_store_create_verify_revoke(tmp_path) -> None:
store = ApiKeyStore(tmp_path / "api_keys.json")
store.ensure_exists()
api_key, meta = store.create_key(name="integration-client")
assert api_key.startswith("ak_")
assert meta["name"] == "integration-client"
assert store.verify(api_key) is True
assert store.verify("ak_invalid") is False
revoked = store.revoke_key(meta["id"])
assert revoked is True
assert store.verify(api_key) is False