aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-11-14 16:55:07 -0500
committerJack Lloyd <[email protected]>2017-11-14 16:58:55 -0500
commit583741096b47b49e067e88fbf03575cdf86e7967 (patch)
tree3a8376318749608f0f0b04a38950eb18985db9f7 /src
parent50ebb336e119eacfacd20c4b005295cac986cdf2 (diff)
Catch exceptions in NIST validation tests
Diffstat (limited to 'src')
-rw-r--r--src/tests/test_x509_path.cpp74
1 files changed, 41 insertions, 33 deletions
diff --git a/src/tests/test_x509_path.cpp b/src/tests/test_x509_path.cpp
index cb0895369..c1d8a5b17 100644
--- a/src/tests/test_x509_path.cpp
+++ b/src/tests/test_x509_path.cpp
@@ -182,55 +182,63 @@ std::vector<Test::Result> NIST_Path_Validation_Tests::run()
for(auto i = expected.begin(); i != expected.end(); ++i)
{
- const std::string test_name = i->first;
- const std::string expected_result = i->second;
-
- const std::string test_dir = nist_test_dir + "/" + test_name;
-
Test::Result result("NIST path validation");
result.start_timer();
- const std::vector<std::string> all_files = Botan::get_files_recursive(test_dir);
+ const std::string test_name = i->first;
- if(all_files.empty())
+ try
{
- result.test_failure("No test files found in " + test_dir);
- results.push_back(result);
- continue;
- }
+ const std::string expected_result = i->second;
- Botan::Certificate_Store_In_Memory store;
+ const std::string test_dir = nist_test_dir + "/" + test_name;
- store.add_certificate(root_cert);
- store.add_crl(root_crl);
+ const std::vector<std::string> all_files = Botan::get_files_recursive(test_dir);
- for(auto const& file : all_files)
- {
- if(file.find(".crt") != std::string::npos && file != "end.crt")
+ if(all_files.empty())
{
- store.add_certificate(Botan::X509_Certificate(file));
+ result.test_failure("No test files found in " + test_dir);
+ results.push_back(result);
+ continue;
}
- else if(file.find(".crl") != std::string::npos)
+
+ Botan::Certificate_Store_In_Memory store;
+
+ store.add_certificate(root_cert);
+ store.add_crl(root_crl);
+
+ for(auto const& file : all_files)
{
- Botan::DataSource_Stream in(file, true);
- Botan::X509_CRL crl(in);
- store.add_crl(crl);
+ if(file.find(".crt") != std::string::npos && file != "end.crt")
+ {
+ store.add_certificate(Botan::X509_Certificate(file));
+ }
+ else if(file.find(".crl") != std::string::npos)
+ {
+ Botan::DataSource_Stream in(file, true);
+ Botan::X509_CRL crl(in);
+ store.add_crl(crl);
+ }
}
- }
- Botan::X509_Certificate end_user(test_dir + "/end.crt");
+ Botan::X509_Certificate end_user(test_dir + "/end.crt");
- // 1024 bit root cert
- Botan::Path_Validation_Restrictions restrictions(true, 80);
+ // 1024 bit root cert
+ Botan::Path_Validation_Restrictions restrictions(true, 80);
- Botan::Path_Validation_Result validation_result =
- Botan::x509_path_validate(end_user,
- restrictions,
- store);
+ Botan::Path_Validation_Result validation_result =
+ Botan::x509_path_validate(end_user,
+ restrictions,
+ store);
- result.test_eq(test_name + " path validation result",
- validation_result.result_string(),
- expected_result);
+ result.test_eq(test_name + " path validation result",
+ validation_result.result_string(),
+ expected_result);
+ }
+ catch(std::exception& e)
+ {
+ result.test_failure(test_name, e.what());
+ }
result.end_timer();
results.push_back(result);