mirror of
https://github.com/furyhawk/api_gateway.git
synced 2026-07-21 02:06:50 +00:00
- 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.
20 lines
582 B
Python
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
|