add a solution in case for no password set
[platform/core/security/key-manager.git] / tests / DBFixture.h
1 #pragma once
2
3 #include <test_common.h>
4 #include <ckm/ckm-type.h>
5 #include <protocols.h>
6 #include <chrono>
7
8 class DBFixture
9 {
10     public:
11         DBFixture();
12         DBFixture(const char *db_fname);
13
14         constexpr static const char* m_default_name = "name";
15         constexpr static const char* m_default_label = "label";
16
17         // ::::::::::::::::::::::::: helper methods :::::::::::::::::::::::::
18         static void generate_name(unsigned int id, CKM::Name & output);
19         static void generate_label(unsigned int id, CKM::Label & output);
20         static CKM::DB::Row create_default_row(CKM::DataType type = CKM::DataType::BINARY_DATA);
21         static CKM::DB::Row create_default_row(const CKM::Name &name,
22                                              const CKM::Label &label,
23                                              CKM::DataType type = CKM::DataType::BINARY_DATA);
24         static void compare_row(const CKM::DB::Row &lhs, const CKM::DB::Row &rhs);
25
26         // ::::::::::::::::::::::::: time measurement :::::::::::::::::::::::::
27         void performance_start(const char *operation_name);
28         void performance_stop(long num_operations_performed);
29
30         // ::::::::::::::::::::::::: DB :::::::::::::::::::::::::
31         void generate_perf_DB(unsigned int num_name, unsigned int num_label);
32         long add_full_access_rights(unsigned int num_name, unsigned int num_names_per_label);
33         void check_DB_integrity(const CKM::DB::Row &rowPattern);
34         void insert_row();
35         void insert_row(const CKM::Name &name, const CKM::Label &owner_label);
36         void delete_row(const CKM::Name &name, const CKM::Label &owner_label);
37         void add_permission(const CKM::Name &name, const CKM::Label &owner_label, const CKM::Label &accessor_label);
38         void read_row_expect_success(const CKM::Name &name, const CKM::Label &owner_label);
39
40         CKM::DB::Crypto    m_db;
41     private:
42         void    init();
43         double  performance_get_time_elapsed_ms();
44
45         constexpr static const char* m_crypto_db_fname = "/tmp/testme.db";
46         std::string m_operation;
47         std::chrono::high_resolution_clock::time_point m_start_time, m_end_time;
48 };