Commit c4d77eca authored by Martin Kampas's avatar Martin Kampas

ut_coreconfig: initial commit

parent 97455f51
......@@ -3,6 +3,7 @@ CONFIG += ordered coverage debug
SUBDIRS = \
testutils \
testutils/sandboxhook.pro \
ut_coreconfig \
ut_rndssucli \
ut_settings \
ut_ssuurlresolver \
......
......@@ -3,6 +3,11 @@
<!-- Test suite, name mandatory - the same as test package name -->
<suite name="sync-app-tests" domain="ssu">
<!-- At least one set per suite, name and description mandatory -->
<set name="coreconfig" description="Test to determine if code configuration file processing works properly" feature="coreconfig">
<case name="ut_coreconfig" type="Functional" description="Core config processing test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_coreconfig</step>
</case>
</set>
<set name="rndssucli" description="Test to determine if ssu command line tool works properly" feature="rndssucli">
<case name="ut_rndssucli" type="Functional" description="SSU command line utility test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_rndssucli</step>
......
/**
* @file coreconfigtest.cpp
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/
#include "coreconfigtest.h"
#include <QtTest/QtTest>
#include "libssu/ssucoreconfig.h"
void CoreconfigTest::testCredentialsScope(){
QCOMPARE(SsuCoreConfig::instance()->credentialsScope("/*ignored*/", false), QString("example"));
}
void CoreconfigTest::testCredentials(){
QCOMPARE(SsuCoreConfig::instance()->credentials("example").first, QString("example_username"));
QCOMPARE(SsuCoreConfig::instance()->credentials("example").second, QString("example_password"));
}
void CoreconfigTest::testCredentialsUrl(){
QCOMPARE(SsuCoreConfig::instance()->credentialsUrl("example"), QString("http://creden.tia.ls/"));
}
void CoreconfigTest::testFlavour(){
QCOMPARE(SsuCoreConfig::instance()->flavour(), QString("testing"));
SsuCoreConfig::instance()->setFlavour("release");
QCOMPARE(SsuCoreConfig::instance()->flavour(), QString("release"));
}
void CoreconfigTest::testDeviceMode(){
SsuCoreConfig::instance()->remove("deviceMode");
QCOMPARE(SsuCoreConfig::instance()->deviceMode(), (int)Ssu::ReleaseMode);
SsuCoreConfig::instance()->setDeviceMode(Ssu::ReleaseMode, Ssu::Add);
QCOMPARE(SsuCoreConfig::instance()->deviceMode(), (int)Ssu::ReleaseMode);
SsuCoreConfig::instance()->setDeviceMode(Ssu::LenientMode, Ssu::Add);
QCOMPARE(SsuCoreConfig::instance()->deviceMode(), (int)Ssu::ReleaseMode | Ssu::LenientMode);
SsuCoreConfig::instance()->setDeviceMode(Ssu::ReleaseMode, Ssu::Remove);
QCOMPARE(SsuCoreConfig::instance()->deviceMode(), (int)Ssu::LenientMode);
SsuCoreConfig::instance()->setDeviceMode(Ssu::ReleaseMode, Ssu::Replace);
QCOMPARE(SsuCoreConfig::instance()->deviceMode(), (int)Ssu::ReleaseMode);
}
void CoreconfigTest::testDomain(){
QCOMPARE(SsuCoreConfig::instance()->domain(), QString(""));
SsuCoreConfig::instance()->setDomain("foo");
QCOMPARE(SsuCoreConfig::instance()->domain(), QString("foo"));
}
void CoreconfigTest::testRegistered(){
QCOMPARE(SsuCoreConfig::instance()->isRegistered(), false);
SsuCoreConfig::instance()->setValue("registered", true);
QCOMPARE(SsuCoreConfig::instance()->isRegistered(), false);
SsuCoreConfig::instance()->setValue("privateKey", "fooKey");
QCOMPARE(SsuCoreConfig::instance()->isRegistered(), false);
SsuCoreConfig::instance()->setValue("certificate", "fooCert");
QCOMPARE(SsuCoreConfig::instance()->isRegistered(), true);
}
void CoreconfigTest::testLastCredentialsUpdate(){
QCOMPARE(SsuCoreConfig::instance()->lastCredentialsUpdate(), QDateTime());
SsuCoreConfig::instance()->setValue("lastCredentialsUpdate",
QDateTime::fromString("2013-04-08", Qt::ISODate));
QCOMPARE(SsuCoreConfig::instance()->lastCredentialsUpdate(),
QDateTime::fromString("2013-04-08", Qt::ISODate));
}
void CoreconfigTest::testRelease(){
QCOMPARE(SsuCoreConfig::instance()->release(false), QString("latest"));
QCOMPARE(SsuCoreConfig::instance()->release(true), QString("next"));
SsuCoreConfig::instance()->setRelease("next", false);
QCOMPARE(SsuCoreConfig::instance()->release(false), QString("next"));
QCOMPARE(SsuCoreConfig::instance()->release(true), QString("next"));
SsuCoreConfig::instance()->setRelease("latest", true);
QCOMPARE(SsuCoreConfig::instance()->release(false), QString("next"));
QCOMPARE(SsuCoreConfig::instance()->release(true), QString("latest"));
}
void CoreconfigTest::testSslVerify(){
QCOMPARE(SsuCoreConfig::instance()->useSslVerify(), true);
SsuCoreConfig::instance()->setValue("ssl-verify", false);
QCOMPARE(SsuCoreConfig::instance()->useSslVerify(), false);
}
/**
* @file coreconfigtest.h
* @copyright 2013 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2013
*/
#ifndef _CORECONFIGTEST_H
#define _CORECONFIGTEST_H
#include <QObject>
class CoreconfigTest: public QObject {
Q_OBJECT
private slots:
void testCredentialsScope();
void testCredentials();
void testCredentialsUrl();
void testFlavour();
void testDeviceMode();
void testDomain();
void testRegistered();
void testLastCredentialsUpdate();
void testRelease();
void testSslVerify();
};
#endif
/**
* @file main.cpp
* @copyright 2012 Jolla Ltd.
* @author Martin Kampas <martin.kampas@tieto.com>
* @date 2012
*/
#include <QtTest/QtTest>
#include "libssu/sandbox_p.h"
#include "coreconfigtest.h"
int main(int argc, char **argv){
Sandbox sandbox(QString("%1/configroot").arg(TESTS_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
CoreconfigTest coreconfigTest;
if (QTest::qExec(&coreconfigTest, argc, argv))
return 1;
return 0;
}
[General]
initialized=true
flavour=testing
registered=false
rndRelease=next
release=latest
adaptation=
ca-certificate=
credentials-scope=example
credentials-url-example = http://creden.tia.ls/
[credentials-example]
username = example_username
password = example_password
[repository-urls]
[repository-url-variables]
TARGET = ut_coreconfig
include(../testapplication.pri)
include(ut_coreconfig_dependencies.pri)
HEADERS = \
coreconfigtest.h \
SOURCES = \
main.cpp \
coreconfigtest.cpp \
test_data_etc.files = \
testdata/ssu.ini \
test_data_usr_share.files = \
testdata/ssu-defaults.ini \
include(../../libssu/libssu.pri)
include(../testutils/testutils.pri)
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