Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou committed Dec 13, 2024
1 parent 708b905 commit b6a9ed6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/ccf/cose_signatures_config_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <chrono>
Expand Down
20 changes: 20 additions & 0 deletions samples/apps/logging/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -2100,6 +2101,25 @@ namespace loggingapp
.set_auto_schema<void, void>()
.set_forwarding_required(ccf::endpoints::ForwardingRequired::Never)
.install();

auto get_cose_signatures_config =
[&](ccf::endpoints::ReadOnlyEndpointContext& ctx) {
auto config =
context.get_subsystem<ccf::cose::AbstractCOSESignaturesConfig>()
->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<void, void>()
.set_forwarding_required(ccf::endpoints::ForwardingRequired::Never)
.install();
}
};
}
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit b6a9ed6

Please sign in to comment.