159dffa63SJohn Edward Broadbent 259dffa63SJohn Edward Broadbent #include "cryptErase.hpp" 359dffa63SJohn Edward Broadbent #include "cryptsetupInterface.hpp" 459dffa63SJohn Edward Broadbent #include "estoraged.hpp" 559dffa63SJohn Edward Broadbent #include "filesystemInterface.hpp" 659dffa63SJohn Edward Broadbent 759dffa63SJohn Edward Broadbent #include <unistd.h> 859dffa63SJohn Edward Broadbent 959dffa63SJohn Edward Broadbent #include <exception> 1059dffa63SJohn Edward Broadbent #include <filesystem> 1159dffa63SJohn Edward Broadbent #include <string> 1259dffa63SJohn Edward Broadbent 1359dffa63SJohn Edward Broadbent #include <gmock/gmock.h> 1459dffa63SJohn Edward Broadbent #include <gtest/gtest.h> 1559dffa63SJohn Edward Broadbent 1659dffa63SJohn Edward Broadbent namespace estoraged_test 1759dffa63SJohn Edward Broadbent { 1859dffa63SJohn Edward Broadbent 1959dffa63SJohn Edward Broadbent class MockFilesystemInterface : public estoraged::FilesystemInterface 2059dffa63SJohn Edward Broadbent { 2159dffa63SJohn Edward Broadbent public: 22*2443a021SJohn Wedig MOCK_METHOD(int, runMkfs, (const std::string& logicalVolumePath), 23*2443a021SJohn Wedig (override)); 2459dffa63SJohn Edward Broadbent 2559dffa63SJohn Edward Broadbent MOCK_METHOD(int, doMount, 2659dffa63SJohn Edward Broadbent (const char* source, const char* target, 2759dffa63SJohn Edward Broadbent const char* filesystemtype, unsigned long mountflags, 2859dffa63SJohn Edward Broadbent const void* data), 2959dffa63SJohn Edward Broadbent (override)); 3059dffa63SJohn Edward Broadbent 3159dffa63SJohn Edward Broadbent MOCK_METHOD(int, doUnmount, (const char* target), (override)); 3259dffa63SJohn Edward Broadbent 3359dffa63SJohn Edward Broadbent MOCK_METHOD(bool, createDirectory, (const std::filesystem::path& p), 3459dffa63SJohn Edward Broadbent (override)); 3559dffa63SJohn Edward Broadbent 3659dffa63SJohn Edward Broadbent MOCK_METHOD(bool, removeDirectory, (const std::filesystem::path& p), 3759dffa63SJohn Edward Broadbent (override)); 3859dffa63SJohn Edward Broadbent 3959dffa63SJohn Edward Broadbent MOCK_METHOD(bool, directoryExists, (const std::filesystem::path& p), 4059dffa63SJohn Edward Broadbent (override)); 4159dffa63SJohn Edward Broadbent }; 4259dffa63SJohn Edward Broadbent 4359dffa63SJohn Edward Broadbent class MockCryptsetupInterface : public estoraged::CryptsetupInterface 4459dffa63SJohn Edward Broadbent { 4559dffa63SJohn Edward Broadbent public: 4659dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptFormat, 4759dffa63SJohn Edward Broadbent (struct crypt_device * cd, const char* type, const char* cipher, 4859dffa63SJohn Edward Broadbent const char* cipher_mode, const char* uuid, 4959dffa63SJohn Edward Broadbent const char* volume_key, size_t volume_key_size, void* params), 5059dffa63SJohn Edward Broadbent (override)); 5159dffa63SJohn Edward Broadbent 5259dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptKeyslotAddByVolumeKey, 5359dffa63SJohn Edward Broadbent (struct crypt_device * cd, int keyslot, const char* volume_key, 5459dffa63SJohn Edward Broadbent size_t volume_key_size, const char* passphrase, 5559dffa63SJohn Edward Broadbent size_t passphrase_size), 5659dffa63SJohn Edward Broadbent (override)); 5759dffa63SJohn Edward Broadbent 5859dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptLoad, 5959dffa63SJohn Edward Broadbent (struct crypt_device * cd, const char* requested_type, 6059dffa63SJohn Edward Broadbent void* params), 6159dffa63SJohn Edward Broadbent (override)); 6259dffa63SJohn Edward Broadbent 638d5a3a07SJohn Wedig MOCK_METHOD(int, cryptKeyslotChangeByPassphrase, 648d5a3a07SJohn Wedig (struct crypt_device * cd, int keyslotOld, int keyslotNew, 658d5a3a07SJohn Wedig const char* passphrase, size_t passphraseSize, 668d5a3a07SJohn Wedig const char* newPassphrase, size_t newPassphraseSize), 678d5a3a07SJohn Wedig (override)); 688d5a3a07SJohn Wedig 6959dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptActivateByPassphrase, 7059dffa63SJohn Edward Broadbent (struct crypt_device * cd, const char* name, int keyslot, 7159dffa63SJohn Edward Broadbent const char* passphrase, size_t passphrase_size, 7259dffa63SJohn Edward Broadbent uint32_t flags), 7359dffa63SJohn Edward Broadbent (override)); 7459dffa63SJohn Edward Broadbent 7559dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptDeactivate, 7659dffa63SJohn Edward Broadbent (struct crypt_device * cd, const char* name), (override)); 7759dffa63SJohn Edward Broadbent 7859dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptKeyslotDestroy, 7959dffa63SJohn Edward Broadbent (struct crypt_device * cd, const int slot), (override)); 8059dffa63SJohn Edward Broadbent 8159dffa63SJohn Edward Broadbent MOCK_METHOD(int, cryptKeySlotMax, (const char* type), (override)); 8259dffa63SJohn Edward Broadbent 8359dffa63SJohn Edward Broadbent MOCK_METHOD(crypt_keyslot_info, cryptKeySlotStatus, 8459dffa63SJohn Edward Broadbent (struct crypt_device * cd, int keyslot), (override)); 85*2443a021SJohn Wedig 86*2443a021SJohn Wedig MOCK_METHOD(std::string, cryptGetDir, (), (override)); 8759dffa63SJohn Edward Broadbent }; 8859dffa63SJohn Edward Broadbent 8959dffa63SJohn Edward Broadbent } // namespace estoraged_test 90