2017-07-03 09:30:10 +02:00
|
|
|
/*!
|
2018-03-28 15:10:51 +02:00
|
|
|
* \copyright Copyright (c) 2014-2018 Governikus GmbH & Co. KG, Germany
|
2017-07-03 09:30:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QtCore/QtCore>
|
|
|
|
#include <QtTest/QtTest>
|
2017-09-15 10:23:30 +02:00
|
|
|
#include <QThread>
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
#include "controller/AuthController.h"
|
|
|
|
#include "paos/retrieve/StartPaosResponse.h"
|
|
|
|
#include "states/StateBuilder.h"
|
|
|
|
#include "states/StateStartPaosResponse.h"
|
2017-09-15 10:23:30 +02:00
|
|
|
#include "TestFileHelper.h"
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
using namespace governikus;
|
|
|
|
|
|
|
|
|
|
|
|
class test_StateStartPaosResponse
|
|
|
|
: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
QScopedPointer<StateStartPaosResponse> mState;
|
|
|
|
QSharedPointer<AuthContext> mAuthContext;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void fireStateStart(QEvent* pEvent);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
mAuthContext.reset(new AuthContext(nullptr));
|
|
|
|
mState.reset(StateBuilder::createState<StateStartPaosResponse>(mAuthContext));
|
|
|
|
connect(this, &test_StateStartPaosResponse::fireStateStart, mState.data(), &AbstractState::onEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cleanup()
|
|
|
|
{
|
|
|
|
mState.reset();
|
|
|
|
mAuthContext.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void takeResultFromStartPAOSResponse()
|
|
|
|
{
|
|
|
|
QSharedPointer<StartPaosResponse> startPAOSResponse(new StartPaosResponse(TestFileHelper::readFile(":/paos/StartPAOSResponse3.xml")));
|
|
|
|
mAuthContext->setStartPaosResponse(startPAOSResponse);
|
2017-12-20 14:54:05 +01:00
|
|
|
mAuthContext->setStatus(CardReturnCodeUtil::toGlobalStatus(CardReturnCode::CANCELLATION_BY_USER));
|
2017-07-03 09:30:10 +02:00
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateStartPaosResponse::fireAbort);
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
2017-07-03 09:33:28 +02:00
|
|
|
const Result& result = mState->getContext()->getStatus();
|
|
|
|
QCOMPARE(result.getMajor(), Result::Major::Error);
|
|
|
|
QCOMPARE(result.getMinor(), GlobalStatus::Code::Paos_Error_DP_Timeout_Error);
|
2017-07-03 09:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
void emitErrorIfResultError()
|
2017-07-03 09:30:10 +02:00
|
|
|
{
|
|
|
|
QSharedPointer<StartPaosResponse> startPAOSResponse(new StartPaosResponse(TestFileHelper::readFile(":/paos/StartPAOSResponse3.xml")));
|
|
|
|
mAuthContext->setStartPaosResponse(startPAOSResponse);
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateStartPaosResponse::fireAbort);
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
void emitSuccessIfResultOk()
|
2017-07-03 09:30:10 +02:00
|
|
|
{
|
|
|
|
QSharedPointer<StartPaosResponse> startPAOSResponse(new StartPaosResponse(TestFileHelper::readFile(":/paos/StartPAOSResponse1.xml")));
|
|
|
|
mAuthContext->setStartPaosResponse(startPAOSResponse);
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateStartPaosResponse::fireContinue);
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(test_StateStartPaosResponse)
|
|
|
|
#include "test_StateStartPaosResponse.moc"
|