AusweisApp2/test/qt/core/test_SelfAuthenticationData...

109 lines
5.6 KiB
C++
Raw Normal View History

2017-07-03 09:30:10 +02:00
/*!
* \brief Unit tests for \ref SelfAuthenticationData
*
2019-05-22 10:08:38 +02:00
* \copyright Copyright (c) 2014-2019 Governikus GmbH & Co. KG, Germany
2017-07-03 09:30:10 +02:00
*/
#include "SelfAuthenticationData.h"
2019-01-03 15:06:22 +01:00
#include "TestFileHelper.h"
2017-07-03 09:30:10 +02:00
#include <QtTest>
using namespace governikus;
class test_SelfAuthenticationData
: public QObject
{
Q_OBJECT
2019-01-03 15:06:22 +01:00
private Q_SLOTS:
void parsedCrap()
2017-07-03 09:30:10 +02:00
{
2019-01-03 15:06:22 +01:00
QTest::ignoreMessage(QtDebugMsg, "JSON parsing failed: \"illegal value\"");
SelfAuthenticationData selfAuthenticationData("abc");
QVERIFY(!selfAuthenticationData.isValid());
2017-07-03 09:30:10 +02:00
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DateOfExpiry), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::GivenNames), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::Nationality), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::IssuingState), QString());
2017-07-03 09:30:10 +02:00
}
void parsedValues()
{
2019-01-03 15:06:22 +01:00
const auto& data = TestFileHelper::readFile(":/self/SelfAuthenticationData.json");
SelfAuthenticationData selfAuthenticationData(data);
2017-07-03 09:30:10 +02:00
QVERIFY(selfAuthenticationData.isValid());
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DateOfExpiry), QString("2020-10-31+01:00"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DocumentType), QString("TA"));
2017-07-03 09:30:10 +02:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::IssuingState), QString("D"));
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::Nationality), QString("AZE"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::GivenNames), QStringLiteral("ANDR\u00c9"));
2017-07-03 09:30:10 +02:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::FamilyNames), QString("MUSTERMANN"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::ArtisticName), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::AcademicTitle), QString());
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::BirthName), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DateOfBirth), QString("1981-06-17+02:00"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfBirth), QString("FRANKFURT (ODER)"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceStreet), QStringLiteral("EHM-WELK-STRA\u00dfE 33"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceCity), QStringLiteral("L\u00dcBBENAU/SPREEWALD"));
2017-07-03 09:30:10 +02:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceCountry), QString("D"));
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceZipCode), QString("03222"));
2017-07-03 09:30:10 +02:00
}
void parsedValuesNoAddress()
{
2019-01-03 15:06:22 +01:00
const auto& data = TestFileHelper::readFile(":/self/SelfAuthenticationDataNoAddress.json");
SelfAuthenticationData selfAuthenticationData(data);
2017-07-03 09:30:10 +02:00
QVERIFY(selfAuthenticationData.isValid());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DocumentType), QString("TP"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::IssuingState), QString("D"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::GivenNames), QString("KARL"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::FamilyNames), QString("HILLEBRANDT"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::ArtisticName), QStringLiteral("GRAF V. L\u00DDSKY"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::AcademicTitle), QString("DR.HC."));
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::BirthName), QString("This data has not been stored in this chip generation."));
2017-07-03 09:30:10 +02:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DateOfBirth), QString("1952-06-17+01:00"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfBirth), QString("TRIER"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceStreet), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceCountry), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceZipCode), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceNoPlaceInfo), QString("keine Hauptwohnung in Deutschland"));
}
2019-01-03 15:06:22 +01:00
void parsedValuesNoStreet()
2017-07-03 09:30:10 +02:00
{
2019-01-03 15:06:22 +01:00
const auto& data = TestFileHelper::readFile(":/self/SelfAuthenticationDataNoStreet.json");
SelfAuthenticationData selfAuthenticationData(data);
QVERIFY(selfAuthenticationData.isValid());
2017-07-03 09:30:10 +02:00
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DocumentType), QString("TP"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::IssuingState), QString("D"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::GivenNames), QString("ANNEKATHRIN"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::FamilyNames), QString("LERCH"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::ArtisticName), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::AcademicTitle), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::BirthName), QString());
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::DateOfBirth), QString("1976-07-05+01:00"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfBirth), QStringLiteral("BAD K\u00D6NIGSHOFEN I. GRABFELD"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceCity), QStringLiteral("L\u00DCBBENAU/SPREEWALD"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceStreet), QString());
2017-07-03 09:30:10 +02:00
2019-01-03 15:06:22 +01:00
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceCountry), QString("D"));
QCOMPARE(selfAuthenticationData.getValue(SelfAuthData::PlaceOfResidenceZipCode), QString("06108"));
2017-07-03 09:30:10 +02:00
}
};
QTEST_GUILESS_MAIN(test_SelfAuthenticationData)
#include "test_SelfAuthenticationData.moc"