This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-remoteproxy/tests/mockauthenticator.h
2018-08-09 14:19:40 +02:00

53 lines
1.3 KiB
C++

#ifndef MOCKAUTHENTICATOR_H
#define MOCKAUTHENTICATOR_H
#include <QTimer>
#include <QObject>
#include "authentication/authenticator.h"
using namespace remoteproxy;
class MockAuthenticationReply : public QObject
{
Q_OBJECT
public:
explicit MockAuthenticationReply(int timeout, Authenticator::AuthenticationError error, AuthenticationReply *authenticationReply, QObject *parent = nullptr);
AuthenticationReply *authenticationReply() const { return m_authenticationReply; }
Authenticator::AuthenticationError error() const { return m_error; }
private:
Authenticator::AuthenticationError m_error;
AuthenticationReply *m_authenticationReply;
signals:
void finished();
};
class MockAuthenticator : public Authenticator
{
Q_OBJECT
public:
explicit MockAuthenticator(QObject *parent = nullptr);
QString name() const override;
void setTimeoutDuration(int timeout);
void setExpectedAuthenticationError(Authenticator::AuthenticationError error = AuthenticationErrorNoError);
private:
int m_timeoutDuration = 1000;
Authenticator::AuthenticationError m_expectedError;
private slots:
void replyFinished();
public slots:
AuthenticationReply *authenticate(ProxyClient *proxyClient) override;
};
#endif // MOCKAUTHENTICATOR_H