Skip to content

Commit

Permalink
fix: changed to use auto& ref as per review comment
Browse files Browse the repository at this point in the history
fix: re-enabled unit tests

Signed-off-by: James Chapman <[email protected]>
  • Loading branch information
james-ctc committed Aug 9, 2024
1 parent b1152d5 commit f70cf50
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lib/staging/tls/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ install(

# tests don't run successfully in CI pipeline
# pki.sh not installed or run from wrong directory
# add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME})
add_test(${TLS_GTEST_NAME} ${TLS_GTEST_NAME})
10 changes: 5 additions & 5 deletions lib/staging/tls/tests/tls_connection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ tls::Server::OptionalConfig ssl_init() {
auto server_config = std::make_unique<tls::Server::config_t>();
server_config->cipher_list = "ECDHE-ECDSA-AES128-SHA256";
server_config->ciphersuites = "";
server_config->chains.emplace_back();
server_config->chains[0].certificate_chain_file = "server_chain.pem";
server_config->chains[0].private_key_file = "server_priv.pem";
server_config->chains[0].trust_anchor_file = "server_root_cert.pem";
server_config->chains[0].ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
auto& ref = server_config->chains.emplace_back();
ref.certificate_chain_file = "server_chain.pem";
ref.private_key_file = "server_priv.pem";
ref.trust_anchor_file = "server_root_cert.pem";
ref.ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
server_config->host = "localhost";
server_config->service = "8444";
server_config->ipv6_only = false;
Expand Down
20 changes: 10 additions & 10 deletions lib/staging/tls/tests/tls_connection_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,16 @@ class TlsTest : public testing::Test {
server_config.cipher_list = "ECDHE-ECDSA-AES128-SHA256";
// server_config.ciphersuites = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384";
server_config.ciphersuites = "";
server_config.chains.emplace_back();
server_config.chains[0].certificate_chain_file = "server_chain.pem";
server_config.chains[0].private_key_file = "server_priv.pem";
server_config.chains[0].trust_anchor_file = "server_root_cert.pem";
server_config.chains[0].ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
server_config.chains.emplace_back();
server_config.chains[1].certificate_chain_file = "alt_server_chain.pem";
server_config.chains[1].private_key_file = "alt_server_priv.pem";
server_config.chains[1].trust_anchor_file = "alt_server_root_cert.pem";
server_config.chains[1].ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
auto& ref0 = server_config.chains.emplace_back();
ref0.certificate_chain_file = "server_chain.pem";
ref0.private_key_file = "server_priv.pem";
ref0.trust_anchor_file = "server_root_cert.pem";
ref0.ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
auto& ref1 = server_config.chains.emplace_back();
ref1.certificate_chain_file = "alt_server_chain.pem";
ref1.private_key_file = "alt_server_priv.pem";
ref1.trust_anchor_file = "alt_server_root_cert.pem";
ref1.ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
// server_config.verify_locations_file = "client_root_cert.pem";
server_config.host = "localhost";
server_config.service = "8444";
Expand Down
18 changes: 9 additions & 9 deletions lib/staging/tls/tests/tls_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ int main(int argc, char** argv) {
config.ciphersuites = "TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384";
}

config.chains.emplace_back();
config.chains[0].certificate_chain_file = "server_chain.pem";
config.chains[0].private_key_file = "server_priv.pem";
config.chains[0].trust_anchor_file = "server_root_cert.pem";
config.chains[0].ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
config.chains.emplace_back();
config.chains[1].certificate_chain_file = "alt_server_chain.pem";
config.chains[1].private_key_file = "alt_server_priv.pem";
config.chains[1].trust_anchor_file = "alt_server_root_cert.pem";
auto& ref0 = config.chains.emplace_back();
ref0.certificate_chain_file = "server_chain.pem";
ref0.private_key_file = "server_priv.pem";
ref0.trust_anchor_file = "server_root_cert.pem";
ref0.ocsp_response_files = {"ocsp_response.der", "ocsp_response.der"};
auto& ref1 = config.chains.emplace_back();
ref1.certificate_chain_file = "alt_server_chain.pem";
ref1.private_key_file = "alt_server_priv.pem";
ref1.trust_anchor_file = "alt_server_root_cert.pem";
config.verify_locations_file = "client_root_cert.pem";

config.service = "8444";
Expand Down
10 changes: 5 additions & 5 deletions modules/EvseV2G/connection/tls_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ bool build_config(tls::Server::config_t& config, struct v2g_context* ctx) {
// workaround (see above libevse-security comment)
const auto key_password = info.password.value_or("");

config.chains.emplace_back();
config.chains[0].certificate_chain_file = cert_path.c_str();
config.chains[0].private_key_file = key_path.c_str();
config.chains[0].private_key_password = key_password.c_str();
auto& ref = config.chains.emplace_back();
ref.certificate_chain_file = cert_path.c_str();
ref.private_key_file = key_path.c_str();
ref.private_key_password = key_password.c_str();

if (info.ocsp) {
for (const auto& ocsp : info.ocsp.value()) {
const char* file{nullptr};
if (ocsp.ocsp_path) {
file = ocsp.ocsp_path.value().c_str();
}
config.chains[0].ocsp_response_files.push_back(file);
ref.ocsp_response_files.push_back(file);
}
}

Expand Down

0 comments on commit f70cf50

Please sign in to comment.