Skip to content

Commit

Permalink
ut_urlresolver: add checkVerifyResponse()
Browse files Browse the repository at this point in the history
  • Loading branch information
martyone committed Apr 10, 2013
1 parent 355c4c0 commit 046248a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/ut_urlresolver/urlresolvertest.cpp
Expand Up @@ -6,6 +6,7 @@
*/

#include "urlresolvertest.h"
#include "constants.h"
#include "testutils/process.h"

void UrlResolverTest::initTestCase(){
Expand Down Expand Up @@ -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");
}
1 change: 1 addition & 0 deletions tests/ut_urlresolver/urlresolvertest.h
Expand Up @@ -29,6 +29,7 @@ class UrlResolverTest: public QObject {
void checkRegisterDevice();
void checkSetCredentials();
void checkStoreAuthorizedKeys();
void checkVerifyResponse();

private:
Ssu ssu;
Expand Down

0 comments on commit 046248a

Please sign in to comment.