2017-07-03 09:30:10 +02:00
|
|
|
/*!
|
|
|
|
* \brief Unit tests for \ref TransmitResponse
|
|
|
|
*
|
2019-05-22 10:08:38 +02:00
|
|
|
* \copyright Copyright (c) 2015-2019 Governikus GmbH & Co. KG, Germany
|
2017-07-03 09:30:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "paos/invoke/TransmitResponse.h"
|
|
|
|
|
2019-01-03 15:06:22 +01:00
|
|
|
#include "TestFileHelper.h"
|
|
|
|
|
2017-07-03 09:30:10 +02:00
|
|
|
#include <QtCore>
|
|
|
|
#include <QtTest>
|
|
|
|
|
|
|
|
using namespace governikus;
|
|
|
|
|
|
|
|
class test_TransmitResponse
|
|
|
|
: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void type()
|
|
|
|
{
|
|
|
|
TransmitResponse elem;
|
|
|
|
QCOMPARE(elem.mType, PaosType::TRANSMIT_RESPONSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void marshall()
|
|
|
|
{
|
|
|
|
TransmitResponse response;
|
|
|
|
QByteArray elem = response.marshall();
|
|
|
|
|
|
|
|
QVERIFY(elem.contains("<TransmitResponse "));
|
|
|
|
QVERIFY(elem.contains("</TransmitResponse>"));
|
|
|
|
QVERIFY(!elem.contains("OutputAPDU"));
|
|
|
|
|
|
|
|
TransmitResponse responseWithApdu;
|
|
|
|
responseWithApdu.setMessageId("dummy");
|
2019-01-03 15:06:22 +01:00
|
|
|
responseWithApdu.setOutputApdus(QByteArrayList {"bla"});
|
2017-07-03 09:30:10 +02:00
|
|
|
elem = responseWithApdu.marshall();
|
|
|
|
|
|
|
|
QVERIFY(elem.contains("<OutputAPDU>bla</OutputAPDU>"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-03 15:06:22 +01:00
|
|
|
void checkTemplate()
|
2017-07-03 09:30:10 +02:00
|
|
|
{
|
2019-01-03 15:06:22 +01:00
|
|
|
TransmitResponse response;
|
|
|
|
response.setResult(ECardApiResult(GlobalStatus::Code::Workflow_Wrong_Parameter_Invocation));
|
|
|
|
response.setOutputApdus(QByteArrayList{"a", "b", "c"});
|
|
|
|
auto data = QString::fromLatin1(response.marshall());
|
|
|
|
data.replace(QRegularExpression("<wsa:MessageID>.*</wsa:MessageID>"), "<wsa:MessageID>STRIP ME</wsa:MessageID>");
|
|
|
|
QCOMPARE(data, QString::fromLatin1(TestFileHelper::readFile(":/paos/TransmitResponse.xml")));
|
2017-07-03 09:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(test_TransmitResponse)
|
|
|
|
#include "test_TransmitResponse.moc"
|