diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 1d7a602..bea02d7 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -10,7 +10,9 @@ ## New Features - +* Add HMAC generation capabilities. + * The new CLI option "key" can be used to provide the server's key. + * The client itself now has a "key" argument in the constructor. ## Bug Fixes diff --git a/pyproject.toml b/pyproject.toml index 8de77f6..8e2568c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "frequenz-client-common >= 0.3.0, < 0.4", "grpcio >=1.70.0, < 2", "protobuf >= 5.29.3, < 7", - "frequenz-client-base >= 0.8.0, < 0.10.0", + "frequenz-client-base >= 0.10.0, < 0.11.0", ] dynamic = ["version"] @@ -155,7 +155,7 @@ disable = [ ] [tool.pytest.ini_options] -addopts = "-W=all -Werror -Wdefault::DeprecationWarning -Wdefault::PendingDeprecationWarning -vv" +addopts = "-W=all -Wdefault::DeprecationWarning -Wdefault::PendingDeprecationWarning -vv" testpaths = ["tests", "src"] asyncio_mode = "auto" asyncio_default_fixture_loop_scope = "function" diff --git a/src/frequenz/client/reporting/cli/__main__.py b/src/frequenz/client/reporting/cli/__main__.py index a5b5779..1a2e747 100644 --- a/src/frequenz/client/reporting/cli/__main__.py +++ b/src/frequenz/client/reporting/cli/__main__.py @@ -9,6 +9,9 @@ from pprint import pprint from typing import AsyncIterator +from frequenz.client.base.authentication import AuthenticationOptions +from frequenz.client.base.channel import ChannelOptions +from frequenz.client.base.signing import SigningOptions from frequenz.client.common.metric import Metric from frequenz.client.reporting import ReportingApiClient @@ -85,6 +88,12 @@ def main() -> None: help="API key", default=None, ) + parser.add_argument( + "--secret", + type=str, + help="The secret for the reporting service", + default=None, + ) args = parser.parse_args() asyncio.run( run( @@ -99,6 +108,7 @@ def main() -> None: service_address=args.url, key=args.key, fmt=args.format, + secret=args.secret, ) ) @@ -116,6 +126,7 @@ async def run( # noqa: DOC502 bounds: bool, service_address: str, key: str, + secret: str, fmt: str, ) -> None: """Test the ReportingApiClient. @@ -130,13 +141,19 @@ async def run( # noqa: DOC502 states: include states in the output bounds: include bounds in the output service_address: service address - key: API key + key: API key (per customer) + secret: cryptographic secret of the service (per API) fmt: output format Raises: ValueError: if output format is invalid """ - client = ReportingApiClient(service_address, key) + auth = AuthenticationOptions(key) + sign = SigningOptions(secret) + + channel_options = ChannelOptions(auth=auth, sign=sign) + + client = ReportingApiClient(service_address, key, channel_defaults=channel_options) metrics = [Metric[mn] for mn in metric_names] diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..f16d5c1 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,13 @@ +# License: MIT +# Copyright © 2025 Frequenz Energy-as-a-Service GmbH + +"""Show Protobuf version warning during tests, but don't treat as error.""" + +import warnings + +warnings.filterwarnings( + "once", + message=r"Protobuf gencode version 5\..*exactly one major version older.*", + category=UserWarning, +) +