Commit 355c4c03 authored by Martin Kampas's avatar Martin Kampas

ut_urlresolver: add checkRegisterDevice()

parent fa07e63c
......@@ -3,6 +3,9 @@ include(tests_common.pri)
QT += testlib
test_data.path = $${TESTS_DATA_PATH}
INSTALLS += test_data
test_data_etc.path = $${TESTS_DATA_PATH}/configroot/etc/ssu
test_data_usr_share.path = $${TESTS_DATA_PATH}/configroot/usr/share/ssu
INSTALLS += test_data_etc test_data_usr_share
-----BEGIN CERTIFICATE-----
MIICzDCCAjWgAwIBAgIJAMEYl4q2VM7YMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNV
BAYTAkZJMRkwFwYDVQQIDBBTb3V0aGVybiBGaW5sYW5kMREwDwYDVQQHDAhIZWxz
aW5raTEUMBIGA1UECgwLRm9vIEJhciBMdGQxEDAOBgNVBAMMB0ZvbyBCYXIxGTAX
BgkqhkiG9w0BCQEWCmZvb0BiYXIuZmkwIBcNMTMwNDA5MDk0MTAyWhgPMjExMzAz
MTYwOTQxMDJaMH4xCzAJBgNVBAYTAkZJMRkwFwYDVQQIDBBTb3V0aGVybiBGaW5s
YW5kMREwDwYDVQQHDAhIZWxzaW5raTEUMBIGA1UECgwLRm9vIEJhciBMdGQxEDAO
BgNVBAMMB0ZvbyBCYXIxGTAXBgkqhkiG9w0BCQEWCmZvb0BiYXIuZmkwgZ8wDQYJ
KoZIhvcNAQEBBQADgY0AMIGJAoGBAK1eqDzjWRv/ZY6XyyR0NTEcGavs57qOfK3t
BJpOsEcOX7W0u904HlK8zMFiNUCoIAz1W09TC5s69GusgBOtsOemtMKctHhF+FBk
ybVTns5vF6t4yx3vY2RFgvQDjFGHDlwpVzWTEYmzHucP+FsPd19/Pvjz3CqeIzZH
IHfHdtY7AgMBAAGjUDBOMB0GA1UdDgQWBBQNHO0P6yfLNbp9y662aTuUlkfOMzAf
BgNVHSMEGDAWgBQNHO0P6yfLNbp9y662aTuUlkfOMzAMBgNVHRMEBTADAQH/MA0G
CSqGSIb3DQEBBQUAA4GBAI7iH16ZtfncZ2+OUISdTzg3TlqlxOxnm5CEm0KCvAKy
kgDmvlXFJ3FjeNfSDwBqP0/hbONWaCIt1kXeMoosJc2B0zMNCIPRf8qJGXJacR+n
5sm+Vjgi2ofQ1dlsCI9jQbAMDJzQ0jHFX4a+Y9h8AwsmyxX/lOn4H3UOSNh1HNoS
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAK1eqDzjWRv/ZY6X
yyR0NTEcGavs57qOfK3tBJpOsEcOX7W0u904HlK8zMFiNUCoIAz1W09TC5s69Gus
gBOtsOemtMKctHhF+FBkybVTns5vF6t4yx3vY2RFgvQDjFGHDlwpVzWTEYmzHucP
+FsPd19/Pvjz3CqeIzZHIHfHdtY7AgMBAAECgYA/z8lor92KmpSMyX4x6rvxWYBx
cX9RgUSO1+CL0066uKWtwdor8I3osilDPJyRMdCqNFzpc42gEzEHuLRjidjEr9LO
74VyYGsZPehLUB9d6+SlWpa2BlDGTp60nUC4itLI/IxOjnG9ekIAFVF54w/OFmJo
dT3uAccRgf5PEahdEQJBANX/AwVCDmEWRKDcnmynsWvL/JMtDRhEfhDW5rl9QvcB
XDopJGur8qlbDgRX8B4JrM4GkOIHq63tHxmWc4BzudcCQQDPZjrYHeUhYYz/EKvr
7ME973zl3xgROjsimTY7zWil9mr7M3e/63A88fIkIB5QRFwiBz1N2frgc1rP5PpH
0yI9AkB7bIyqcLHobzZ/7R72njWnbcysejRuRbrMLZZ/b267Fi7CYM5fx5m68giA
mtOkD4J6hbD0nOX496WTVYIimRybAkAuLmRR9S4tJaygqxStHvXUlbwo72lLhLzg
Ml96J33y3pDpyIcUrBc86t7xHlnBo8ckKJqE+FG9otII0sLMNX49AkEAhorKyzXR
y9FfSstiuSpSubCRFFbCTYflgZhLk7vrBEPFhp3pVlWXszdiL07SoPPDvnEqdHlW
7VKuMhgxpp1rww==
-----END PRIVATE KEY-----
......@@ -125,6 +125,51 @@ void UrlResolverTest::checkReleaseRepoUrls(){
}
}
void UrlResolverTest::checkRegisterDevice(){
QDomDocument doc("foo");
QDomElement root = doc.createElement("foo");
doc.appendChild(root);
QDomElement certificate = doc.createElement("certificate");
root.appendChild(certificate);
QVERIFY2(!ssu.registerDevice(&doc),
"Ssu::registerDevice() should fail when 'certificate' is empty");
QFile certificateFile(TESTS_DATA_PATH "/mycert.crt");
QVERIFY(certificateFile.open(QIODevice::ReadOnly));
certificate.appendChild(doc.createTextNode(certificateFile.readAll()));
QDomElement privateKey = doc.createElement("privateKey");
root.appendChild(privateKey);
QVERIFY2(!ssu.registerDevice(&doc),
"Ssu::registerDevice() should fail when 'privateKey' is empty");
QFile privateKeyFile(TESTS_DATA_PATH "/mykey.key");
QVERIFY(privateKeyFile.open(QIODevice::ReadOnly));
privateKey.appendChild(doc.createTextNode(privateKeyFile.readAll()));
QDomElement user = doc.createElement("user");
root.appendChild(user);
user.appendChild(doc.createTextNode("john.doe"));
QSignalSpy registrationStatusChanged_spy(&ssu, SIGNAL(registrationStatusChanged()));
QVERIFY(ssu.registerDevice(&doc));
QVERIFY(registrationStatusChanged_spy.count() == 1);
QVERIFY(ssu.isRegistered());
ssu.unregister();
QVERIFY(registrationStatusChanged_spy.count() == 2);
QVERIFY(!ssu.isRegistered());
}
void UrlResolverTest::checkSetCredentials(){
QDomDocument doc("foo");
......
......@@ -26,6 +26,7 @@ class UrlResolverTest: public QObject {
void checkCleanUrl();
void simpleRepoUrlLookup();
void checkReleaseRepoUrls();
void checkRegisterDevice();
void checkSetCredentials();
void checkStoreAuthorizedKeys();
......
......@@ -8,6 +8,10 @@ HEADERS = urlresolvertest.h
SOURCES = main.cpp \
urlresolvertest.cpp
test_data.files = \
testdata/mycert.crt \
testdata/mykey.key \
test_data_etc.files = \
testdata/ssu.ini \
......
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