aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/test_certstor.cpp
diff options
context:
space:
mode:
authorKai Michaelis <[email protected]>2016-09-22 13:43:43 +0200
committerseu <[email protected]>2016-10-02 18:10:43 +0200
commit16eb674ecfc29102a0eef6c38929b78848c4467b (patch)
treeb6495bcd82d6809f0bc24be7ad5671157a385d5d /src/tests/test_certstor.cpp
parent6c8998cb853605f17cebb76dd61496b05941d04f (diff)
1st review round
Diffstat (limited to 'src/tests/test_certstor.cpp')
-rw-r--r--src/tests/test_certstor.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/tests/test_certstor.cpp b/src/tests/test_certstor.cpp
index 02865c72c..5d894640b 100644
--- a/src/tests/test_certstor.cpp
+++ b/src/tests/test_certstor.cpp
@@ -12,9 +12,12 @@
#include <botan/internal/filesystem.h>
#include <botan/pkcs8.h>
#include <botan/auto_rng.h>
+ #include <sstream>
+ extern "C" {
+ #include <unistd.h> // unlink()
+ }
#endif
-#include <iostream>
namespace Botan_Tests {
@@ -53,6 +56,20 @@ Test::Result test_certstor_insert_find_remove_test(
if(priv)
{
result.test_eq("Got wrong private key",key->pkcs8_private_key(),priv->pkcs8_private_key());
+
+ auto rev_certs = store.find_certs_for_key(*priv);
+
+ if(rev_certs.empty())
+ {
+ result.test_failure("No certificate");
+ }
+ else
+ {
+ bool found = std::any_of(rev_certs.begin(),rev_certs.end(),[&](std::shared_ptr<const Botan::X509_Certificate> c)
+ { return c->fingerprint() == cert.fingerprint(); });
+
+ result.test_eq("Got wrong/no certificate",found,true);
+ }
}
if(certs[4] != cert_key && certs[5] != cert_key)
@@ -193,7 +210,11 @@ class Certstor_Tests : public Test
try
{
- Botan::Certificate_Store_In_SQLite store(fn.first + ".db","123");
+ unlink((fn.first + ".db").c_str());
+
+ auto& rng = Test::rng();
+ std::string passwd(reinterpret_cast<const char*>(rng.random_vec(8).data()),8);
+ Botan::Certificate_Store_In_SQLite store(fn.first + ".db",passwd);
std::vector<std::pair<Botan::X509_Certificate,std::shared_ptr<Botan::Private_Key>>> retrieve;
for(auto&& cert_key_pair : test_data)