Add backend id to database scheme
[platform/core/security/key-manager.git] / tests / test_db_crypto.cpp
index 9946a34..a493448 100644 (file)
@@ -19,6 +19,7 @@ const unsigned int c_test_retries = 1000;
 const unsigned int c_num_names = 500;
 const unsigned int c_num_names_add_test = 5000;
 const unsigned int c_names_per_label = 15;
+
 } // namespace anonymous
 
 BOOST_FIXTURE_TEST_SUITE(DBCRYPTO_TEST, DBFixture)
@@ -65,6 +66,22 @@ BOOST_AUTO_TEST_CASE(DBtestTransaction) {
     BOOST_CHECK_MESSAGE(!row_optional, "Row still present after rollback");
 }
 
+BOOST_AUTO_TEST_CASE(DBtestBackend) {
+    DB::Row rowPattern = create_default_row();
+    rowPattern.data = RawBuffer(32, 1);
+    rowPattern.dataSize = rowPattern.data.size();
+    rowPattern.tag = RawBuffer(AES_GCM_TAG_SIZE, 1);
+
+    rowPattern.backendId =  CryptoBackend::OpenSSL;
+    check_DB_integrity(rowPattern);
+
+    rowPattern.backendId =  CryptoBackend::TrustZone;
+    check_DB_integrity(rowPattern);
+
+    rowPattern.backendId =  CryptoBackend::None;
+    check_DB_integrity(rowPattern);
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 
@@ -247,6 +264,7 @@ void verifyDBisValid(DBFixture & fixture)
         ret_list.clear();
     }
 }
+
 struct DBVer1Migration : public DBFixture
 {
     DBVer1Migration() : DBFixture("/usr/share/ckm-db-test/testme_ver1.db")
@@ -258,6 +276,12 @@ struct DBVer2Migration : public DBFixture
     DBVer2Migration() : DBFixture("/usr/share/ckm-db-test/testme_ver2.db")
     {}
 };
+
+struct DBVer3Migration : public DBFixture
+{
+    DBVer3Migration() : DBFixture("/usr/share/ckm-db-test/testme_ver3.db")
+    {}
+};
 }
 
 BOOST_AUTO_TEST_CASE(DBMigrationDBVer1)
@@ -272,6 +296,12 @@ BOOST_AUTO_TEST_CASE(DBMigrationDBVer2)
     verifyDBisValid(DBver2);
 }
 
+BOOST_AUTO_TEST_CASE(DBMigrationDBVer3)
+{
+    DBVer3Migration DBver3;
+    verifyDBisValid(DBver3);
+}
+
 BOOST_AUTO_TEST_CASE(DBMigrationDBCurrent)
 {
     DBFixture currentDB;