From e28a49726d674abe988475b55b7d3ff500b4a5c9 Mon Sep 17 00:00:00 2001 From: AssemblyJohn Date: Wed, 23 Oct 2024 14:03:55 +0300 Subject: [PATCH] Fixed test file order read issus Signed-off-by: AssemblyJohn --- tests/tests.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/tests.cpp b/tests/tests.cpp index c42d607..2e87714 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -288,16 +288,25 @@ TEST_F(EvseSecurityTestsMulti, verify_multi_root_leaf_retrieval) { // We have 2 leafs ASSERT_EQ(result.info.size(), 2); - ASSERT_EQ(fs::path("certs/client/csms/CSMS_LEAF.pem"), result.info[0].certificate_single.value()); - ASSERT_EQ(fs::path("certs/client/csms/SECC_LEAF_GRIDSYNC.pem"), result.info[1].certificate_single.value()); + fs::path leaf_csms = fs::path("certs/client/csms/CSMS_LEAF.pem"); + fs::path leaf_grid = fs::path("certs/client/csms/SECC_LEAF_GRIDSYNC.pem"); + + // File order is not guaranteed + ASSERT_TRUE(leaf_csms == result.info[0].certificate_single.value() || + leaf_grid == result.info[0].certificate_single.value()); + ASSERT_TRUE(leaf_csms == result.info[1].certificate_single.value() || + leaf_grid == result.info[1].certificate_single.value()); ASSERT_TRUE(result.info[0].certificate_root.has_value()); ASSERT_TRUE(result.info[1].certificate_root.has_value()); - ASSERT_TRUE(equal_certificate_strings(result.info[0].certificate_root.value(), - read_file_to_string("certs/ca/v2g/V2G_ROOT_CA.pem"))); - ASSERT_TRUE(equal_certificate_strings(result.info[1].certificate_root.value(), - read_file_to_string("certs/ca/v2g/V2G_ROOT_GRIDSYNC_CA.pem"))); + std::string root_v2g = read_file_to_string("certs/ca/v2g/V2G_ROOT_CA.pem"); + std::string root_grid = read_file_to_string("certs/ca/v2g/V2G_ROOT_GRIDSYNC_CA.pem"); + + ASSERT_TRUE(equal_certificate_strings(result.info[0].certificate_root.value(), root_v2g) || + equal_certificate_strings(result.info[0].certificate_root.value(), root_grid)); + ASSERT_TRUE(equal_certificate_strings(result.info[1].certificate_root.value(), root_v2g) || + equal_certificate_strings(result.info[1].certificate_root.value(), root_grid)); } TEST_F(EvseSecurityTests, verify_normal_keygen) {