diff --git a/tests/tests.cpp b/tests/tests.cpp index 970fc8f..c7c3d20 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -296,6 +296,41 @@ TEST_F(EvseSecurityTests, verify_basics) { ASSERT_TRUE(equal_certificate_strings(root_cert.get_export_string(), certificate_strings[root_cert_idx])); } +TEST_F(EvseSecurityTests, verify_oscp_cache) { + std::string ocsp_mock_response_data = "OCSP_MOCK_RESPONSE_DATA"; + std::string ocsp_mock_response_data2 = "OCSP_MOCK_RESPONSE_DATA_V2"; + + OCSPRequestDataList data = this->evse_security->get_v2g_ocsp_request_data(); + + ASSERT_EQ(data.ocsp_request_data_list.size(), 3); + + // Mock a response + for(auto& ocsp : data.ocsp_request_data_list) { + this->evse_security->update_ocsp_cache(ocsp.certificate_hash_data.value(), ocsp_mock_response_data); + } + + // Make sure all info was written and that it is correct + + // Write data again to test over-writing + for(auto& ocsp : data.ocsp_request_data_list) { + this->evse_security->update_ocsp_cache(ocsp.certificate_hash_data.value(), ocsp_mock_response_data2); + } + + // Make sure the info was over-written + + + // Retrieve OCSP data along with certificates + GetCertificateInfoResult response = this->evse_security->get_leaf_certificate_info(LeafCertificateType::V2G, EncodingFormat::PEM, true); + + ASSERT_EQ(response.status, GetCertificateInfoStatus::Accepted); + ASSERT_TRUE(response.info.has_value()); + + CertificateInfo info = response.info.value(); + + ASSERT_EQ(info.certificate_count, 2); + ASSERT_EQ(info.oscsp.size(), 2); +} + TEST_F(EvseSecurityTests, verify_directory_bundles) { const auto child_cert_str = read_file_to_string(std::filesystem::path("certs/client/csms/CSMS_LEAF.pem"));