blob: 2a0ad8e62fdf0102569643c013f793a2379c32f8 [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:
John Wedig2443a022023-03-17 13:42:32 -070022 MOCK_METHOD(int, runMkfs, (const std::string& logicalVolumePath),
23 (override));
John Edward Broadbent59dffa62022-01-13 17:41:32 -080024
25 MOCK_METHOD(int, doMount,
26 (const char* source, const char* target,
27 const char* filesystemtype, unsigned long mountflags,
28 const void* data),
29 (override));
30
31 MOCK_METHOD(int, doUnmount, (const char* target), (override));
32
33 MOCK_METHOD(bool, createDirectory, (const std::filesystem::path& p),
34 (override));
35
36 MOCK_METHOD(bool, removeDirectory, (const std::filesystem::path& p),
37 (override));
38
39 MOCK_METHOD(bool, directoryExists, (const std::filesystem::path& p),
40 (override));
41};
42
43class MockCryptsetupInterface : public estoraged::CryptsetupInterface
44{
45 public:
46 MOCK_METHOD(int, cryptFormat,
47 (struct crypt_device * cd, const char* type, const char* cipher,
Patrick Williamsc0f85482025-03-03 16:49:57 -050048 const char* cipherMode, const char* uuid,
49 const char* volumeKey, size_t volumeKeySize, void* params),
John Edward Broadbent59dffa62022-01-13 17:41:32 -080050 (override));
51
52 MOCK_METHOD(int, cryptKeyslotAddByVolumeKey,
Patrick Williamsc0f85482025-03-03 16:49:57 -050053 (struct crypt_device * cd, int keyslot, const char* volumeKey,
54 size_t volumeKeySize, const char* passphrase,
55 size_t passphraseSize),
John Edward Broadbent59dffa62022-01-13 17:41:32 -080056 (override));
57
58 MOCK_METHOD(int, cryptLoad,
Patrick Williamsc0f85482025-03-03 16:49:57 -050059 (struct crypt_device * cd, const char* requestedType,
John Edward Broadbent59dffa62022-01-13 17:41:32 -080060 void* params),
61 (override));
62
John Wedig8d5a3a02022-09-29 15:25:58 -070063 MOCK_METHOD(int, cryptKeyslotChangeByPassphrase,
64 (struct crypt_device * cd, int keyslotOld, int keyslotNew,
65 const char* passphrase, size_t passphraseSize,
66 const char* newPassphrase, size_t newPassphraseSize),
67 (override));
68
John Edward Broadbent59dffa62022-01-13 17:41:32 -080069 MOCK_METHOD(int, cryptActivateByPassphrase,
70 (struct crypt_device * cd, const char* name, int keyslot,
Patrick Williamsc0f85482025-03-03 16:49:57 -050071 const char* passphrase, size_t passphraseSize, uint32_t flags),
John Edward Broadbent59dffa62022-01-13 17:41:32 -080072 (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));
John Wedig2443a022023-03-17 13:42:32 -070084
85 MOCK_METHOD(std::string, cryptGetDir, (), (override));
John Edward Broadbent59dffa62022-01-13 17:41:32 -080086};
87
88} // namespace estoraged_test