diff --git a/packages/cpp/ArmoniK.Api.Client/source/channel/ChannelFactory.cpp b/packages/cpp/ArmoniK.Api.Client/source/channel/ChannelFactory.cpp index e7090d539..e2155367b 100644 --- a/packages/cpp/ArmoniK.Api.Client/source/channel/ChannelFactory.cpp +++ b/packages/cpp/ArmoniK.Api.Client/source/channel/ChannelFactory.cpp @@ -108,17 +108,18 @@ bool initialize_protocol_endpoint(const common::options::ControlPlane &controlPl * @param userPrivatePem The client key for mTLS * @return a pointer to a certificate provider interface */ -std::shared_ptr create_certificate_provider(const std::string &rootCertificate, - const std::string &userPublicPem, - const std::string &userPrivatePem) { +std::shared_ptr create_certificate_provider(absl::string_view rootCertificate, + absl::string_view userPublicPem, + absl::string_view userPrivatePem) { if (rootCertificate.empty()) { return std::make_shared( - std::vector{IdentityKeyCertPair{userPrivatePem, userPublicPem}}); + std::vector{IdentityKeyCertPair{userPrivatePem.data(), userPublicPem.data()}}); } else if (userPrivatePem.empty() || userPublicPem.empty()) { - return std::make_shared(rootCertificate); + return std::make_shared(rootCertificate.data()); } else { return std::make_shared( - rootCertificate, std::vector{IdentityKeyCertPair{userPrivatePem, userPublicPem}}); + rootCertificate.data(), + std::vector{IdentityKeyCertPair{userPrivatePem.data(), userPublicPem.data()}}); } } diff --git a/packages/cpp/ArmoniK.Api.Tests/header/common.h b/packages/cpp/ArmoniK.Api.Tests/header/common.h index a5b519e25..f763a1079 100644 --- a/packages/cpp/ArmoniK.Api.Tests/header/common.h +++ b/packages/cpp/ArmoniK.Api.Tests/header/common.h @@ -23,8 +23,8 @@ void init(std::shared_ptr &channel, armonik::api::grpc::v1::TaskO * @param num_calls the number of call of rpc * @return */ -bool rpcCalled(const std::string &service_name, const std::string &rpc_name, int num_calls = 1, - const std::string &endpoint = "http://localhost:4999/calls.json"); +bool rpcCalled(absl::string_view service_name, absl::string_view rpc_name, int num_calls = 1, + absl::string_view endpoint = "http://localhost:4999/calls.json"); /** * @@ -32,14 +32,14 @@ bool rpcCalled(const std::string &service_name, const std::string &rpc_name, int * @param endpoint the call endpoint * @return */ -bool all_rpc_called(const std::string &service_name, const std::vector &missings = {}, - const std::string &endpoint = "http://localhost:4999/calls.json"); +bool all_rpc_called(absl::string_view service_name, const std::vector &missings = {}, + absl::string_view endpoint = "http://localhost:4999/calls.json"); /** * * @param endpoint The reset endpoint */ -void clean_up(const std::string &endpoint = "http://localhost:4999/reset"); +void clean_up(absl::string_view endpoint = "http://localhost:4999/reset"); /** * A fixture class to reset the RPC calls diff --git a/packages/cpp/ArmoniK.Api.Tests/source/MockTest.cpp b/packages/cpp/ArmoniK.Api.Tests/source/MockTest.cpp index 669ecc32e..a874dec70 100644 --- a/packages/cpp/ArmoniK.Api.Tests/source/MockTest.cpp +++ b/packages/cpp/ArmoniK.Api.Tests/source/MockTest.cpp @@ -20,14 +20,13 @@ size_t WriteCallback(void *ptr, size_t size, size_t num_elt, std::string *data) return size * num_elt; } -bool rpcCalled(const std::string &service_name, const std::string &rpc_name, int num_calls, - const std::string &endpoint) { +bool rpcCalled(absl::string_view service_name, absl::string_view rpc_name, int num_calls, absl::string_view endpoint) { auto curl = curl_easy_init(); std::string read_buffer; std::cout << endpoint << std::endl; if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, endpoint.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, endpoint.data()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &read_buffer); @@ -43,7 +42,7 @@ bool rpcCalled(const std::string &service_name, const std::string &rpc_name, int try { dom::element response_json = parser.parse(read_buffer); - if (response_json[service_name][rpc_name].get_int64() == num_calls) { + if (response_json[service_name.data()][rpc_name.data()].get_int64() == num_calls) { return true; } } catch (const simdjson_error &e) { @@ -53,13 +52,13 @@ bool rpcCalled(const std::string &service_name, const std::string &rpc_name, int return false; } -bool all_rpc_called(const std::string &service_name, const std::vector &missings, - const std::string &endpoint) { +bool all_rpc_called(absl::string_view service_name, const std::vector &missings, + absl::string_view endpoint) { auto curl = curl_easy_init(); std::string read_buffer; std::cout << endpoint << std::endl; if (curl) { - curl_easy_setopt(curl, CURLOPT_URL, endpoint.c_str()); + curl_easy_setopt(curl, CURLOPT_URL, endpoint.data()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &read_buffer); @@ -76,11 +75,11 @@ bool all_rpc_called(const std::string &service_name, const std::vector missing_rpcs; - for (auto rpc_name : response_json[service_name].get_array()) { - if (response_json[service_name][rpc_name].get_int64() == 0) { + for (auto rpc_name : response_json[service_name.data()].get_array()) { + if (response_json[service_name.data()][rpc_name].get_int64() == 0) { missing_rpcs.emplace_back(rpc_name.get_string().value().data()); } } @@ -101,11 +100,11 @@ bool all_rpc_called(const std::string &service_name, const std::vector