2022-07-04 21:14:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
#include <Wallet/WalletApi.h>
|
|
|
|
|
2022-07-15 07:30:16 +00:00
|
|
|
#include <StatusGo/Utils.h>
|
|
|
|
|
2022-07-04 21:14:13 +00:00
|
|
|
#include <filesystem>
|
2022-10-19 13:41:53 +00:00
|
|
|
#include <string>
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
class QCoreApplication;
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
namespace Status::Onboarding
|
|
|
|
{
|
|
|
|
class OnboardingController;
|
|
|
|
class MultiAccount;
|
|
|
|
} // namespace Status::Onboarding
|
2022-07-04 21:14:13 +00:00
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
namespace Wallet = Status::StatusGo::Wallet;
|
|
|
|
namespace Accounts = Status::StatusGo::Accounts;
|
2022-07-15 07:30:16 +00:00
|
|
|
namespace GoUtils = Status::StatusGo::Utils;
|
2022-07-07 18:16:59 +00:00
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
namespace Status::Testing
|
|
|
|
{
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
class AutoCleanTempTestDir;
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
class ScopedTestAccount final
|
|
|
|
{
|
2022-07-04 21:14:13 +00:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
* \brief Create and logs in a new test account
|
|
|
|
* \param tempTestSubfolderName subfolder name of the temporary test folder where to initalize user data \see AutoCleanTempTestDir
|
|
|
|
* \todo make it more flexible by splitting into create account, login and wait for events
|
|
|
|
*/
|
2022-10-19 13:41:53 +00:00
|
|
|
explicit ScopedTestAccount(const std::string& tempTestSubfolderName,
|
|
|
|
const QString& accountName = defaultAccountName,
|
|
|
|
const QString& accountPassword = defaultAccountPassword);
|
2022-07-04 21:14:13 +00:00
|
|
|
~ScopedTestAccount();
|
|
|
|
|
|
|
|
void processMessages(size_t millis, std::function<bool()> shouldWaitUntilTimeout);
|
|
|
|
void logOut();
|
|
|
|
|
2022-07-13 16:45:18 +00:00
|
|
|
static Accounts::ChatOrWalletAccount firstChatAccount();
|
|
|
|
static Accounts::ChatOrWalletAccount firstWalletAccount();
|
2022-07-15 07:30:16 +00:00
|
|
|
/// Root account
|
2022-10-19 13:41:53 +00:00
|
|
|
const Status::Onboarding::MultiAccount& loggedInAccount() const;
|
2022-07-07 18:16:59 +00:00
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
QString password() const
|
|
|
|
{
|
|
|
|
return m_accountPassword;
|
|
|
|
};
|
|
|
|
StatusGo::HashedPassword hashedPassword() const
|
|
|
|
{
|
|
|
|
return GoUtils::hashPassword(m_accountPassword);
|
|
|
|
};
|
2022-07-07 18:16:59 +00:00
|
|
|
|
2022-07-04 21:14:13 +00:00
|
|
|
Status::Onboarding::OnboardingController* onboardingController() const;
|
|
|
|
|
2022-07-07 18:16:59 +00:00
|
|
|
const std::filesystem::path& fusedTestFolder() const;
|
2022-07-04 21:14:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<AutoCleanTempTestDir> m_fusedTestFolder;
|
|
|
|
std::unique_ptr<QCoreApplication> m_app;
|
|
|
|
std::filesystem::path m_testFolderPath;
|
|
|
|
std::shared_ptr<Status::Onboarding::OnboardingController> m_onboarding;
|
|
|
|
std::function<bool()> m_checkIfShouldContinue;
|
|
|
|
|
|
|
|
QString m_accountName;
|
|
|
|
QString m_accountPassword;
|
|
|
|
|
|
|
|
static constexpr auto defaultAccountName = "test_name";
|
|
|
|
static constexpr auto defaultAccountPassword = "test_pwd*";
|
|
|
|
};
|
|
|
|
|
2022-10-19 13:41:53 +00:00
|
|
|
} // namespace Status::Testing
|