diff --git a/tests/ut_urlresolver/urlresolvertest.cpp b/tests/ut_urlresolver/urlresolvertest.cpp index 1b141c7..a424564 100644 --- a/tests/ut_urlresolver/urlresolvertest.cpp +++ b/tests/ut_urlresolver/urlresolvertest.cpp @@ -6,6 +6,7 @@ */ #include "urlresolvertest.h" +#include "constants.h" #include "testutils/process.h" void UrlResolverTest::initTestCase(){ @@ -294,3 +295,31 @@ void UrlResolverTest::checkStoreAuthorizedKeys(){ QFile::ReadOther | QFile::WriteOther | QFile::ExeOther; QVERIFY((QFileInfo(QDir::home().filePath(".ssh")).permissions() & go_rwx) == 0); } + +void UrlResolverTest::checkVerifyResponse(){ + QDomDocument doc("foo"); + + QDomElement root = doc.createElement("foo"); + doc.appendChild(root); + + QDomElement action = doc.createElement("action"); + root.appendChild(action); + action.appendChild(doc.createTextNode("register")); + + QDomElement deviceId = doc.createElement("deviceId"); + root.appendChild(deviceId); + deviceId.appendChild(doc.createTextNode("deadbeef-dead-beef-dead")); + + QDomElement protocolVersion = doc.createElement("protocolVersion"); + root.appendChild(protocolVersion); + + QDomText protocolVersionText = doc.createTextNode(SSU_PROTOCOL_VERSION); + protocolVersion.appendChild(protocolVersionText); + + QVERIFY(ssu.verifyResponse(&doc)); + + protocolVersionText.setData(SSU_PROTOCOL_VERSION ".invalid"); + + QVERIFY2(!ssu.verifyResponse(&doc), + "Ssu::verifyResponse() should fail when protocolVersion does not match SSU_PROTOCOL_VERSION"); +} diff --git a/tests/ut_urlresolver/urlresolvertest.h b/tests/ut_urlresolver/urlresolvertest.h index 7783e46..40540bb 100644 --- a/tests/ut_urlresolver/urlresolvertest.h +++ b/tests/ut_urlresolver/urlresolvertest.h @@ -29,6 +29,7 @@ class UrlResolverTest: public QObject { void checkRegisterDevice(); void checkSetCredentials(); void checkStoreAuthorizedKeys(); + void checkVerifyResponse(); private: Ssu ssu;