X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=tests%2FDBFixture.cpp;h=2a7238ab4c6012edba0f39f015ea74b06cfb0f20;hb=a7828fd8c2a30b7e48624e1cb3c424742cc2de7e;hp=20e1a4302c459d4028de5351febfedff41a31b1b;hpb=0c7a5e8c233996070520d87674372f1b5da2b9fe;p=platform%2Fcore%2Fsecurity%2Fkey-manager.git diff --git a/tests/DBFixture.cpp b/tests/DBFixture.cpp index 20e1a43..2a7238a 100644 --- a/tests/DBFixture.cpp +++ b/tests/DBFixture.cpp @@ -32,7 +32,7 @@ void DBFixture::init() high_resolution_clock::time_point srand_feed = high_resolution_clock::now(); srand(srand_feed.time_since_epoch().count()); - BOOST_REQUIRE_NO_THROW(m_db = DBCrypto(m_crypto_db_fname, defaultPass)); + BOOST_REQUIRE_NO_THROW(m_db = DB::Crypto(m_crypto_db_fname, defaultPass)); } double DBFixture::performance_get_time_elapsed_ms() @@ -73,7 +73,7 @@ void DBFixture::generate_label(unsigned int id, Label & output) void DBFixture::generate_perf_DB(unsigned int num_name, unsigned int num_elements) { // to speed up data creation - cache the row - DBRow rowPattern = create_default_row(DBDataType::BINARY_DATA); + DB::Row rowPattern = create_default_row(DataType::BINARY_DATA); rowPattern.data = RawBuffer(100, 20); rowPattern.dataSize = rowPattern.data.size(); rowPattern.tag = RawBuffer(AES_GCM_TAG_SIZE, 1); @@ -83,7 +83,7 @@ void DBFixture::generate_perf_DB(unsigned int num_name, unsigned int num_element generate_name(i, rowPattern.name); generate_label(i/num_elements, rowPattern.ownerLabel); - BOOST_REQUIRE_NO_THROW(m_db.saveDBRow(rowPattern)); + BOOST_REQUIRE_NO_THROW(m_db.saveRow(rowPattern)); } } @@ -113,16 +113,16 @@ long DBFixture::add_full_access_rights(unsigned int num_name, unsigned int num_n return iterations; } -DBRow DBFixture::create_default_row(DBDataType type) +DB::Row DBFixture::create_default_row(DataType type) { return create_default_row(m_default_name, m_default_label, type); } -DBRow DBFixture::create_default_row(const Name &name, +DB::Row DBFixture::create_default_row(const Name &name, const Label &label, - DBDataType type) + DataType type) { - DBRow row; + DB::Row row; row.name = name; row.ownerLabel = label; row.exportable = 1; @@ -131,11 +131,12 @@ DBRow DBFixture::create_default_row(const Name &name, row.iv = createDefaultPass(); row.encryptionScheme = 0; row.dataSize = 0; + row.backendId = CryptoBackend::OpenSSL; return row; } -void DBFixture::compare_row(const DBRow &lhs, const DBRow &rhs) +void DBFixture::compare_row(const DB::Row &lhs, const DB::Row &rhs) { BOOST_CHECK_MESSAGE(lhs.name == rhs.name, "namees didn't match! Got: " << rhs.name @@ -156,28 +157,31 @@ void DBFixture::compare_row(const DBRow &lhs, const DBRow &rhs) BOOST_CHECK_MESSAGE(lhs.data == rhs.data, "data didn't match! Got: " << rhs.data.size() << " , expected : " << lhs.data.size()); + + BOOST_CHECK_MESSAGE(lhs.backendId == rhs.backendId, + "backendId didn't match! Got: " << static_cast(rhs.backendId) + << " , expected : " << static_cast(lhs.backendId)); } -void DBFixture::check_DB_integrity(const DBRow &rowPattern) +void DBFixture::check_DB_integrity(const DB::Row &rowPattern) { - BOOST_REQUIRE_NO_THROW(m_db.saveDBRow(rowPattern)); - DBRow selectRow = rowPattern; + BOOST_REQUIRE_NO_THROW(m_db.saveRow(rowPattern)); - DBCrypto::DBRowOptional optional_row; - BOOST_REQUIRE_NO_THROW(optional_row = m_db.getDBRow("name", "label", DBDataType::BINARY_DATA)); + DB::Crypto::RowOptional optional_row; + BOOST_REQUIRE_NO_THROW(optional_row = m_db.getRow("name", "label", DataType::BINARY_DATA)); BOOST_REQUIRE_MESSAGE(optional_row, "Select didn't return any row"); - compare_row(selectRow, rowPattern); - DBRow name_duplicate = rowPattern; + compare_row(*optional_row, rowPattern); + DB::Row name_duplicate = rowPattern; name_duplicate.data = createDefaultPass(); name_duplicate.dataSize = name_duplicate.data.size(); unsigned int erased; - BOOST_REQUIRE_NO_THROW(erased = m_db.deleteDBRow("name", "label")); + BOOST_REQUIRE_NO_THROW(erased = m_db.deleteRow("name", "label")); BOOST_REQUIRE_MESSAGE(erased > 0, "Inserted row didn't exist in db"); - DBCrypto::DBRowOptional row_optional; - BOOST_REQUIRE_NO_THROW(row_optional = m_db.getDBRow("name", "label", DBDataType::BINARY_DATA)); + DB::Crypto::RowOptional row_optional; + BOOST_REQUIRE_NO_THROW(row_optional = m_db.getRow("name", "label", DataType::BINARY_DATA)); BOOST_REQUIRE_MESSAGE(!row_optional, "Select should not return row after deletion"); } @@ -188,17 +192,17 @@ void DBFixture::insert_row() void DBFixture::insert_row(const Name &name, const Label &owner_label) { - DBRow rowPattern = create_default_row(name, owner_label, DBDataType::BINARY_DATA); + DB::Row rowPattern = create_default_row(name, owner_label, DataType::BINARY_DATA); rowPattern.data = RawBuffer(100, 20); rowPattern.dataSize = rowPattern.data.size(); rowPattern.tag = RawBuffer(AES_GCM_TAG_SIZE, 1); - BOOST_REQUIRE_NO_THROW(m_db.saveDBRow(rowPattern)); + BOOST_REQUIRE_NO_THROW(m_db.saveRow(rowPattern)); } void DBFixture::delete_row(const Name &name, const Label &owner_label) { bool exit_flag; - BOOST_REQUIRE_NO_THROW(exit_flag = m_db.deleteDBRow(name, owner_label)); + BOOST_REQUIRE_NO_THROW(exit_flag = m_db.deleteRow(name, owner_label)); BOOST_REQUIRE_MESSAGE(true == exit_flag, "remove name failed: no rows removed"); } @@ -212,8 +216,8 @@ void DBFixture::add_permission(const Name &name, const Label &owner_label, const void DBFixture::read_row_expect_success(const Name &name, const Label &owner_label) { - DBCrypto::DBRowOptional row; - BOOST_REQUIRE_NO_THROW(row = m_db.getDBRow(name, owner_label, DBDataType::BINARY_DATA)); + DB::Crypto::RowOptional row; + BOOST_REQUIRE_NO_THROW(row = m_db.getRow(name, owner_label, DataType::BINARY_DATA)); BOOST_REQUIRE_MESSAGE(row, "row is empty"); BOOST_REQUIRE_MESSAGE(row->name == name, "name is not valid"); }