blob: 6809c376927a39c5ccf7558dd744d9f8faf4a4d6 [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
John Wedig8d5a3a02022-09-29 15:25:58 -070062 MOCK_METHOD(int, cryptKeyslotChangeByPassphrase,
63 (struct crypt_device * cd, int keyslotOld, int keyslotNew,
64 const char* passphrase, size_t passphraseSize,
65 const char* newPassphrase, size_t newPassphraseSize),
66 (override));
67
John Edward Broadbent59dffa62022-01-13 17:41:32 -080068 MOCK_METHOD(int, cryptActivateByPassphrase,
69 (struct crypt_device * cd, const char* name, int keyslot,
70 const char* passphrase, size_t passphrase_size,
71 uint32_t flags),
72 (override));
73
74 MOCK_METHOD(int, cryptDeactivate,
75 (struct crypt_device * cd, const char* name), (override));
76
77 MOCK_METHOD(int, cryptKeyslotDestroy,
78 (struct crypt_device * cd, const int slot), (override));
79
80 MOCK_METHOD(int, cryptKeySlotMax, (const char* type), (override));
81
82 MOCK_METHOD(crypt_keyslot_info, cryptKeySlotStatus,
83 (struct crypt_device * cd, int keyslot), (override));
84};
85
86} // namespace estoraged_test