Commit 1b71a83c authored by Volker Krause's avatar Volker Krause
Browse files

Don't extract flight data from pkpass boarding passes without IATA BCBP

Cleartrip somehow puts an entire flight itinerary in there, something
pkpass isn't made for, so don't get confused by that.
parent ff4386a2
...@@ -74,19 +74,19 @@ private Q_SLOTS: ...@@ -74,19 +74,19 @@ private Q_SLOTS:
engine.setContextDate(QDateTime(QDate(2017, 12, 29), QTime(18, 46, 2))); engine.setContextDate(QDateTime(QDate(2017, 12, 29), QTime(18, 46, 2)));
engine.setPass(pass); engine.setPass(pass);
auto result = JsonLdDocument::fromJson(engine.extract()); auto result = JsonLdDocument::fromJson(engine.extract());
QCOMPARE(result.size(), 1);
ExtractorPostprocessor postproc; ExtractorPostprocessor postproc;
postproc.setContextDate(QDateTime(QDate(2017, 12, 29), QTime(18, 46, 2))); postproc.setContextDate(QDateTime(QDate(2017, 12, 29), QTime(18, 46, 2)));
postproc.process(result); postproc.process(result);
result = postproc.result(); result = postproc.result();
QCOMPARE(result.size(), 1); QVERIFY(result.size() <= 1);
const auto resJson = JsonLdDocument::toJson(result); const auto resJson = JsonLdDocument::toJson(result);
QFile ref(refFile); QFile ref(refFile);
QVERIFY(ref.open(QFile::ReadOnly)); QVERIFY(ref.open(QFile::ReadOnly));
const auto doc = QJsonDocument::fromJson(ref.readAll()); const auto doc = QJsonDocument::fromJson(ref.readAll());
QVERIFY(doc.isArray()); QVERIFY(doc.isArray());
QCOMPARE(doc.array().size(), result.size());
if (resJson != doc.array()) { if (resJson != doc.array()) {
qDebug().noquote() << QJsonDocument(resJson).toJson(); qDebug().noquote() << QJsonDocument(resJson).toJson();
......
...@@ -244,6 +244,9 @@ GenericExtractor::Result GenericPkPassExtractor::extract(KPkPass::Pass *pass, co ...@@ -244,6 +244,9 @@ GenericExtractor::Result GenericPkPassExtractor::extract(KPkPass::Pass *pass, co
const auto bcbpData = IataBcbpParser::parse(bcbp, iataContextDate(pass, contextDate).date()); const auto bcbpData = IataBcbpParser::parse(bcbp, iataContextDate(pass, contextDate).date());
if (bcbpData.size() == 1) { if (bcbpData.size() == 1) {
res = JsonLdDocument::apply(bcbpData.at(0), res).value<FlightReservation>(); res = JsonLdDocument::apply(bcbpData.at(0), res).value<FlightReservation>();
} else {
// if this doesn't contain IATA BCBP data we wont be able to get sufficient information out of this
return {};
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment