1 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 16 namespace estoraged_test 17 { 18 19 class MockFilesystemInterface : public estoraged::FilesystemInterface 20 { 21 public: 22 MOCK_METHOD(int, runMkfs, (const std::string& logicalVolumePath), 23 (override)); 24 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 43 class MockCryptsetupInterface : public estoraged::CryptsetupInterface 44 { 45 public: 46 MOCK_METHOD(int, cryptFormat, 47 (struct crypt_device * cd, const char* type, const char* cipher, 48 const char* cipher_mode, const char* uuid, 49 const char* volume_key, size_t volume_key_size, void* params), 50 (override)); 51 52 MOCK_METHOD(int, cryptKeyslotAddByVolumeKey, 53 (struct crypt_device * cd, int keyslot, const char* volume_key, 54 size_t volume_key_size, const char* passphrase, 55 size_t passphrase_size), 56 (override)); 57 58 MOCK_METHOD(int, cryptLoad, 59 (struct crypt_device * cd, const char* requested_type, 60 void* params), 61 (override)); 62 63 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 69 MOCK_METHOD(int, cryptActivateByPassphrase, 70 (struct crypt_device * cd, const char* name, int keyslot, 71 const char* passphrase, size_t passphrase_size, 72 uint32_t flags), 73 (override)); 74 75 MOCK_METHOD(int, cryptDeactivate, 76 (struct crypt_device * cd, const char* name), (override)); 77 78 MOCK_METHOD(int, cryptKeyslotDestroy, 79 (struct crypt_device * cd, const int slot), (override)); 80 81 MOCK_METHOD(int, cryptKeySlotMax, (const char* type), (override)); 82 83 MOCK_METHOD(crypt_keyslot_info, cryptKeySlotStatus, 84 (struct crypt_device * cd, int keyslot), (override)); 85 86 MOCK_METHOD(std::string, cryptGetDir, (), (override)); 87 }; 88 89 } // namespace estoraged_test 90