2 * Copyright (c) 2016-2020 Samsung Electronics Co., Ltd. All rights reserved
4 * Contact: Kyungwook Tak <k.tak@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
19 * @author Maciej Karpiuk (m.karpiuk2@samsung.com)
25 #include <ckm/ckm-type.h>
26 #include <protocols.h>
28 #include <data-type.h>
29 #include <db-crypto.h>
33 enum class DBCryptoThrows : bool { no, yes };
34 DBFixture(DBCryptoThrows dbCryptoThrows = DBCryptoThrows::no);
35 explicit DBFixture(const char *legacy_db_fname, const char *db_fname,
36 DBCryptoThrows dbCryptoThrows = DBCryptoThrows::no);
38 constexpr static const char *m_default_name = "name";
39 constexpr static const char *m_default_owner = "label";
41 // ::::::::::::::::::::::::: helper methods :::::::::::::::::::::::::
42 static void generate_name(unsigned int id, CKM::Name &output);
43 static void generate_owner(unsigned int id, CKM::ClientId &output);
44 static CKM::DB::Row create_default_row(CKM::DataType type =
45 CKM::DataType::BINARY_DATA);
46 static CKM::DB::Row create_default_row(const CKM::Name &name,
47 const CKM::ClientId &owner,
48 CKM::DataType type = CKM::DataType::BINARY_DATA);
49 static CKM::DB::Row create_default_binary_row();
50 static void compare_row(const CKM::DB::Row &lhs, const CKM::DB::Row &rhs);
52 // ::::::::::::::::::::::::: DB :::::::::::::::::::::::::
53 void generate_db(unsigned int num_name, unsigned int names_per_owner);
54 long add_full_access_rights(unsigned int num_name,
55 unsigned int num_names_per_owner);
56 void check_DB_integrity(const CKM::DB::Row &rowPattern);
58 void insert_row(const CKM::Name &name, const CKM::ClientId &owner);
59 void delete_row(const CKM::Name &name, const CKM::ClientId &owner);
60 void add_permission(const CKM::Name &name, const CKM::ClientId &owner,
61 const CKM::ClientId &accessor);
62 void read_row_expect_success(const CKM::Name &name,
63 const CKM::ClientId &owner);
68 void init(DBCryptoThrows dbCryptoThrows);
69 static void unlinkDb();
71 constexpr static const char *m_crypto_legacy_db_fname = "/tmp/testme.db";
72 constexpr static const char *m_crypto_db_fname = "/tmp/testme0.db";