From b6a9ed6a26c71592e5c3881c971f14ef02341d84 Mon Sep 17 00:00:00 2001 From: Amaury Chamayou Date: Fri, 13 Dec 2024 16:50:38 +0000 Subject: [PATCH] Test --- .../ccf/cose_signatures_config_interface.h | 1 + samples/apps/logging/logging.cpp | 20 +++++++++++++++++++ tests/e2e_logging.py | 18 +++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/include/ccf/cose_signatures_config_interface.h b/include/ccf/cose_signatures_config_interface.h index fdc819ca22f..32a0df01a6d 100644 --- a/include/ccf/cose_signatures_config_interface.h +++ b/include/ccf/cose_signatures_config_interface.h @@ -2,6 +2,7 @@ // Licensed under the Apache 2.0 License. #pragma once +#include "ccf/node/cose_signatures_config.h" #include "ccf/node_subsystem_interface.h" #include diff --git a/samples/apps/logging/logging.cpp b/samples/apps/logging/logging.cpp index 11f8997fa08..894bee70f2f 100644 --- a/samples/apps/logging/logging.cpp +++ b/samples/apps/logging/logging.cpp @@ -7,6 +7,7 @@ // CCF #include "ccf/app_interface.h" #include "ccf/common_auth_policies.h" +#include "ccf/cose_signatures_config_interface.h" #include "ccf/crypto/cose.h" #include "ccf/crypto/verifier.h" #include "ccf/ds/hash.h" @@ -2100,6 +2101,25 @@ namespace loggingapp .set_auto_schema() .set_forwarding_required(ccf::endpoints::ForwardingRequired::Never) .install(); + + auto get_cose_signatures_config = + [&](ccf::endpoints::ReadOnlyEndpointContext& ctx) { + auto config = + context.get_subsystem() + ->get_cose_signatures_config(); + + ctx.rpc_ctx->set_response_status(HTTP_STATUS_OK); + ctx.rpc_ctx->set_response_body(nlohmann::json(config).dump()); + }; + + make_read_only_endpoint( + "/cose_signatures_config", + HTTP_GET, + get_cose_signatures_config, + auth_policies) + .set_auto_schema() + .set_forwarding_required(ccf::endpoints::ForwardingRequired::Never) + .install(); } }; } diff --git a/tests/e2e_logging.py b/tests/e2e_logging.py index 06949390dc3..4eb2f3ee226 100644 --- a/tests/e2e_logging.py +++ b/tests/e2e_logging.py @@ -2251,6 +2251,23 @@ def run_app_space_js(args): run_main_tests(network, args) +def test_cose_config(network, args): + + configs = set() + + for node in network.get_joined_nodes(): + with node.client("user0") as c: + r = c.get("/cose_signatures_config") + assert r.status_code == http.HTTPStatus.OK.value, r.status_code + configs.add(r.body.text()) + + assert len(configs) == 1, configs + assert ( + configs.pop() == '{"issuer":"service.example.com","subject":"ledger.signature"}' + ), configs + return network + + def run_main_tests(network, args): test_basic_constraints(network, args) test(network, args) @@ -2295,6 +2312,7 @@ def run_main_tests(network, args): test_genesis_receipt(network, args) if args.package == "samples/apps/logging/liblogging": test_etags(network, args) + test_cose_config(network, args) def run_parsing_errors(args):