diff options
author | René Meusel <[email protected]> | 2017-07-21 10:16:58 +0200 |
---|---|---|
committer | René Meusel <[email protected]> | 2017-07-21 10:22:45 +0200 |
commit | a05c83297666915321ad5c627418f683e1bed1a8 (patch) | |
tree | 8d09e7a357cc9c0a919d176ba99c6fcc2aab1c92 /src/tests/test_ocsp.cpp | |
parent | 90e8cbbc023827a3a55e84ab0c0a3de7c80e681c (diff) |
add OCSP::Response::certificates() + unit test
Diffstat (limited to 'src/tests/test_ocsp.cpp')
-rw-r--r-- | src/tests/test_ocsp.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/test_ocsp.cpp b/src/tests/test_ocsp.cpp index 18708ddf6..e88fad0b4 100644 --- a/src/tests/test_ocsp.cpp +++ b/src/tests/test_ocsp.cpp @@ -86,6 +86,36 @@ class OCSP_Tests : public Test return result; } + Test::Result test_response_certificate_access() + { + Test::Result result("OCSP response certificate access"); + + try + { + Botan::OCSP::Response resp1(slurp_data_file("ocsp/resp1.der")); + const auto &certs1 = resp1.certificates(); + if(result.test_eq("Expected count of certificates", certs1.size(), 1)) + { + const auto cert = certs1.front(); + const Botan::X509_DN expected_dn({std::make_pair( + "X520.CommonName", + "Symantec Class 3 EV SSL CA - G3 OCSP Responder")}); + const bool matches = cert.subject_dn() == expected_dn; + result.test_eq("CN matches expected", matches, true); + } + + Botan::OCSP::Response resp2(slurp_data_file("ocsp/resp2.der")); + const auto &certs2 = resp2.certificates(); + result.test_eq("Expect no certificates", certs2.size(), 0); + } + catch(Botan::Exception& e) + { + result.test_failure("Parsing failed", e.what()); + } + + return result; + } + Test::Result test_request_encoding() { Test::Result result("OCSP request encoding"); @@ -192,6 +222,7 @@ class OCSP_Tests : public Test results.push_back(test_request_encoding()); results.push_back(test_response_parsing()); + results.push_back(test_response_certificate_access()); results.push_back(test_response_verification()); #if defined(BOTAN_HAS_ONLINE_REVOCATION_CHECKS) |