blob: ebd9e111300783909986a129f252e0d8b1549078 [file] [log] [blame]
John Edward Broadbent59dffa62022-01-13 17:41:32 -08001
2#include "cryptErase.hpp"
3#include "cryptsetupInterface.hpp"
4#include "estoraged.hpp"
5#include "filesystemInterface.hpp"
6
7#include <unistd.h>
8
9#include <exception>
10#include <filesystem>
11#include <string>
12
13#include <gmock/gmock.h>
14#include <gtest/gtest.h>
15
16namespace estoraged_test
17{
18
19class MockFilesystemInterface : public estoraged::FilesystemInterface
20{
21 public:
22 MOCK_METHOD(int, runMkfs, (const std::string& logicalVolume), (override));
23
24 MOCK_METHOD(int, doMount,
25 (const char* source, const char* target,
26 const char* filesystemtype, unsigned long mountflags,
27 const void* data),
28 (override));
29
30 MOCK_METHOD(int, doUnmount, (const char* target), (override));
31
32 MOCK_METHOD(bool, createDirectory, (const std::filesystem::path& p),
33 (override));
34
35 MOCK_METHOD(bool, removeDirectory, (const std::filesystem::path& p),
36 (override));
37
38 MOCK_METHOD(bool, directoryExists, (const std::filesystem::path& p),
39 (override));
40};
41
42class MockCryptsetupInterface : public estoraged::CryptsetupInterface
43{
44 public:
45 MOCK_METHOD(int, cryptFormat,
46 (struct crypt_device * cd, const char* type, const char* cipher,
47 const char* cipher_mode, const char* uuid,
48 const char* volume_key, size_t volume_key_size, void* params),
49 (override));
50
51 MOCK_METHOD(int, cryptKeyslotAddByVolumeKey,
52 (struct crypt_device * cd, int keyslot, const char* volume_key,
53 size_t volume_key_size, const char* passphrase,
54 size_t passphrase_size),
55 (override));
56
57 MOCK_METHOD(int, cryptLoad,
58 (struct crypt_device * cd, const char* requested_type,
59 void* params),
60 (override));
61
62 MOCK_METHOD(int, cryptActivateByPassphrase,
63 (struct crypt_device * cd, const char* name, int keyslot,
64 const char* passphrase, size_t passphrase_size,
65 uint32_t flags),
66 (override));
67
68 MOCK_METHOD(int, cryptDeactivate,
69 (struct crypt_device * cd, const char* name), (override));
70
71 MOCK_METHOD(int, cryptKeyslotDestroy,
72 (struct crypt_device * cd, const int slot), (override));
73
74 MOCK_METHOD(int, cryptKeySlotMax, (const char* type), (override));
75
76 MOCK_METHOD(crypt_keyslot_info, cryptKeySlotStatus,
77 (struct crypt_device * cd, int keyslot), (override));
78};
79
80} // namespace estoraged_test