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 "states/StateCertificateDescriptionCheck.h"
|
|
|
|
|
|
|
|
#include "asn1/ASN1Util.h"
|
|
|
|
#include "asn1/CVCertificate.h"
|
|
|
|
#include "context/AuthContext.h"
|
2017-09-15 10:23:30 +02:00
|
|
|
#include "Result.h"
|
|
|
|
#include "TestFileHelper.h"
|
2017-07-03 09:30:10 +02:00
|
|
|
|
2017-07-03 09:33:28 +02:00
|
|
|
#include "TestAuthContext.h"
|
2017-07-03 09:30:10 +02:00
|
|
|
#include <QtCore>
|
|
|
|
#include <QtTest>
|
2017-09-15 10:23:30 +02:00
|
|
|
#include <QThread>
|
2017-07-03 09:30:10 +02:00
|
|
|
|
|
|
|
using namespace governikus;
|
|
|
|
|
|
|
|
|
|
|
|
class test_StateCertificateDescriptionCheck
|
|
|
|
: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
QScopedPointer<StateCertificateDescriptionCheck> mState;
|
|
|
|
QSharedPointer<AuthContext> mAuthContext;
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void fireStateStart(QEvent* pEvent);
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void init()
|
|
|
|
{
|
2017-07-03 09:33:28 +02:00
|
|
|
mAuthContext.reset(new TestAuthContext(nullptr, ":/paos/DIDAuthenticateEAC1.xml"));
|
2017-07-03 09:30:10 +02:00
|
|
|
mAuthContext->setTcTokenUrl(QUrl("https://dev-demo.governikus-eid.de:8443/Autent-DemoApplication/RequestServlet;jsessionid=14w5aKuENyd2D4ZsMmuaeX2g"));
|
|
|
|
|
|
|
|
mState.reset(new StateCertificateDescriptionCheck(mAuthContext));
|
|
|
|
mState->setStateName("StateCertificateDescriptionCheck");
|
|
|
|
|
|
|
|
connect(this, &test_StateCertificateDescriptionCheck::fireStateStart, mState.data(), &AbstractState::onEntry, Qt::ConnectionType::DirectConnection);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cleanup()
|
|
|
|
{
|
|
|
|
mState.reset();
|
|
|
|
mAuthContext.reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void noDescription()
|
|
|
|
{
|
|
|
|
mAuthContext->mDIDAuthenticateEAC1->mEac1InputType.mCertificateDescription = QSharedPointer<CertificateDescription>(new CertificateDescription());
|
|
|
|
mAuthContext->mDIDAuthenticateEAC1->mEac1InputType.mCertificateDescriptionAsBinary.clear();
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateCertificateDescriptionCheck::fireAbort);
|
2017-07-03 09:30:10 +02:00
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void noSubjectUrl()
|
|
|
|
{
|
2017-12-20 14:54:05 +01:00
|
|
|
const auto& desc = qSharedPointerConstCast<CertificateDescription>(mAuthContext->mDIDAuthenticateEAC1->mEac1InputType.mCertificateDescription);
|
|
|
|
desc->setSubjectUrl(QString());
|
2017-07-03 09:30:10 +02:00
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateCertificateDescriptionCheck::fireAbort);
|
2017-07-03 09:30:10 +02:00
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void nonMatchingDescription()
|
|
|
|
{
|
|
|
|
mAuthContext->mDIDAuthenticateEAC1->mEac1InputType.mCertificateDescription = QSharedPointer<CertificateDescription>(new CertificateDescription());
|
|
|
|
mAuthContext->mDIDAuthenticateEAC1->mEac1InputType.mCertificateDescriptionAsBinary = QByteArray::fromHex("1234567890abcdef");
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateCertificateDescriptionCheck::fireAbort);
|
2017-07-03 09:30:10 +02:00
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void matchingDescription()
|
|
|
|
{
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateCertificateDescriptionCheck::fireContinue);
|
2017-07-03 09:30:10 +02:00
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void subjectUrlNoSameOrigin()
|
|
|
|
{
|
|
|
|
mAuthContext->setTcTokenUrl(QUrl("https://dev-demo.governikus-eid.de:8442/Autent-DemoApplication/RequestServlet;jsessionid=14w5aKuENyd2D4ZsMmuaeX2g"));
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
QSignalSpy spy(mState.data(), &StateCertificateDescriptionCheck::fireAbort);
|
2017-07-03 09:30:10 +02:00
|
|
|
Q_EMIT fireStateStart(nullptr);
|
|
|
|
mAuthContext->setStateApproved();
|
|
|
|
|
|
|
|
QCOMPARE(spy.count(), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(test_StateCertificateDescriptionCheck)
|
|
|
|
#include "test_StateCertificateDescriptionCheck.moc"
|