summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-17 06:04:29 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-17 06:04:29 (GMT)
commit31eba380348209feeb0a4e323d1b99e29bd2be09 (patch)
treeafca61a685b68d505c36be4bd9aca60fb8248caa
parent195019a3cea52eb8bcf6a929a0daed86355e647b (diff)
Continue to fix parsing
-rw-r--r--webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp21
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp28
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h12
3 files changed, 48 insertions, 13 deletions
diff --git a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
index 0e8876e..e22ccdb 100644
--- a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
+++ b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
@@ -82,7 +82,26 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult_data()
QTest::addColumn<WebEngineViewer::UpdateDataBaseInfo>("parseInfo");
QTest::newRow("emptydocument") << QStringLiteral("empty.json") << WebEngineViewer::CreatePhishingUrlDataBaseJob::InvalidData << WebEngineViewer::UpdateDataBaseInfo();
QTest::newRow("emptydocument2") << QStringLiteral("empty2.json") << WebEngineViewer::CreatePhishingUrlDataBaseJob::InvalidData << WebEngineViewer::UpdateDataBaseInfo();
- //QTest::newRow("test1") << QStringLiteral("test1.json") << WebEngineViewer::CreatePhishingUrlDataBaseJob::ValidData << WebEngineViewer::UpdateDataBaseInfo();
+ WebEngineViewer::UpdateDataBaseInfo value;
+ QVector<WebEngineViewer::Addition> additionList;
+ WebEngineViewer::Addition tmp;
+ tmp.prefixSize = 4;
+ tmp.hashString = QByteArrayLiteral("rnGLoQ==");
+ additionList.append(tmp);
+ QVector<WebEngineViewer::Removal> removalList;
+ WebEngineViewer::Removal tmpRemoval;
+ removalList.append(tmpRemoval);
+ value.minimumWaitDuration = QStringLiteral("593.440s");
+ value.threatType = QStringLiteral("MALWARE");
+ value.threatEntryType = QStringLiteral("URL");
+ value.responseType = QStringLiteral("PARTIAL_UPDATE");
+ value.platformType = QStringLiteral("WINDOWS");
+ value.newClientState = QStringLiteral("ChAIBRADGAEiAzAwMSiAEDABEAFGpqhd");
+ value.sha256 = QStringLiteral("YSgoRtsRlgHDqDA3LAhM1gegEpEzs1TjzU33vqsR8iM=");
+ value.additionList = additionList;
+ value.removalList = removalList;
+
+ QTest::newRow("test1") << QStringLiteral("test1.json") << WebEngineViewer::CreatePhishingUrlDataBaseJob::ValidData << value;
}
void CreatePhishingUrlDataBaseJobTest::shouldParseResult()
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index 4948608..dc0937d 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -279,7 +279,7 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
mapCheckSum.next();
if (mapCheckSum.key() == QLatin1String("sha256")) {
qDebug() << " sha256 value " << mapCheckSum.value().toString();
- databaseInfo.sha256 = mapIt.value().toString();
+ databaseInfo.sha256 = mapCheckSum.value().toString();
} else {
qDebug() << "Invalid checksum key" << mapCheckSum.key();
}
@@ -307,6 +307,7 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
}
} else if (i.key() == QLatin1String("minimumWaitDuration")) {
qDebug() << " minimumWaitDuration " << i.value().toString();
+ databaseInfo.minimumWaitDuration = i.value().toString();
} else {
qDebug() <<" map key unknown " << i.key();
}
@@ -317,3 +318,28 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
}
deleteLater();
}
+
+bool UpdateDataBaseInfo::operator==(const UpdateDataBaseInfo &other) const {
+ const bool val = (additionList == other.additionList) &&
+ (removalList == other.removalList) &&
+ (minimumWaitDuration == other.minimumWaitDuration) &&
+ (threatType == other.threatType) &&
+ (threatEntryType == other.threatEntryType) &&
+ (responseType == other.responseType) &&
+ (platformType == other.platformType) &&
+ (newClientState == other.newClientState) &&
+ (sha256 == other.sha256);
+ if (!val) {
+ qDebug() << " sha256 "<<sha256 << " other.sha256 "<< other.sha256;
+ qDebug() << " minimumWaitDuration "<<minimumWaitDuration << " other.minimumWaitDuration "<< other.minimumWaitDuration;
+ qDebug() << " threatType "<<threatType << " other.threatType "<< other.threatType;
+ qDebug() << " threatEntryType "<<threatEntryType << " other.threatEntryType "<< other.threatEntryType;
+ qDebug() << " responseType "<<responseType << " other.responseType "<< other.responseType;
+ qDebug() << " platformType "<<platformType << " other.platformType "<< other.platformType;
+ qDebug() << " newClientState "<<newClientState << " other.newClientState "<< other.newClientState;
+ qDebug() << " threatType "<<threatType << " other.threatType "<< other.threatType;
+
+
+ }
+ return val;
+}
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
index 7977e5c..1671483 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.h
@@ -72,17 +72,7 @@ struct UpdateDataBaseInfo {
QString platformType;
QString newClientState;
QString sha256;
- bool operator==(const UpdateDataBaseInfo &other) const {
- return (additionList == other.additionList) &&
- (removalList == other.removalList) &&
- (minimumWaitDuration == other.minimumWaitDuration) &&
- (threatType == other.threatType) &&
- (threatEntryType == other.threatEntryType) &&
- (responseType == other.responseType) &&
- (platformType == other.platformType) &&
- (newClientState == other.newClientState) &&
- (sha256 == other.sha256);
- }
+ bool operator==(const UpdateDataBaseInfo &other) const;
};
/* https://developers.google.com/safe-browsing/v4/update-api */