ssu
Loading...
Searching...
No Matches
coreconfigtest.cpp
Go to the documentation of this file.
1
7
8#include "coreconfigtest.h"
9
10#include <QtTest/QtTest>
11
13
14void CoreconfigTest::testCredentialsScope()
15{
16 QCOMPARE(SsuCoreConfig::instance()->credentialsScope("/*ignored*/", false), QString("example"));
17
18}
19
20void CoreconfigTest::testCredentials()
21{
22 QCOMPARE(SsuCoreConfig::instance()->credentials("example").first, QString("example_username"));
23 QCOMPARE(SsuCoreConfig::instance()->credentials("example").second, QString("example_password"));
24}
25
26void CoreconfigTest::testCredentialsUrl()
27{
28 QCOMPARE(SsuCoreConfig::instance()->credentialsUrl("example"), QString("http://creden.tia.ls/"));
29}
30
31void CoreconfigTest::testFlavour()
32{
33 QCOMPARE(SsuCoreConfig::instance()->flavour(), QString("testing"));
34 SsuCoreConfig::instance()->setFlavour("release");
35 QCOMPARE(SsuCoreConfig::instance()->flavour(), QString("release"));
36}
37
38void CoreconfigTest::testDeviceMode()
39{
40 SsuCoreConfig::instance()->remove("deviceMode");
41 QCOMPARE(SsuCoreConfig::instance()->deviceMode(), Ssu::ReleaseMode);
42 SsuCoreConfig::instance()->setDeviceMode(Ssu::ReleaseMode, Ssu::Add);
43 QCOMPARE(SsuCoreConfig::instance()->deviceMode(), Ssu::ReleaseMode);
44 SsuCoreConfig::instance()->setDeviceMode(Ssu::LenientMode, Ssu::Add);
45 QCOMPARE(SsuCoreConfig::instance()->deviceMode(), Ssu::ReleaseMode | Ssu::LenientMode);
46 SsuCoreConfig::instance()->setDeviceMode(Ssu::ReleaseMode, Ssu::Remove);
47 QCOMPARE(SsuCoreConfig::instance()->deviceMode(), Ssu::LenientMode);
48 SsuCoreConfig::instance()->setDeviceMode(Ssu::ReleaseMode, Ssu::Replace);
49 QCOMPARE(SsuCoreConfig::instance()->deviceMode(), Ssu::ReleaseMode);
50}
51
52void CoreconfigTest::testDomain()
53{
54 QCOMPARE(SsuCoreConfig::instance()->domain(), QString(""));
55 SsuCoreConfig::instance()->setDomain("foo");
56 QCOMPARE(SsuCoreConfig::instance()->domain(), QString("foo"));
57}
58
59void CoreconfigTest::testRegistered()
60{
61 QCOMPARE(SsuCoreConfig::instance()->isRegistered(), false);
62 SsuCoreConfig::instance()->setValue("registered", true);
63 QCOMPARE(SsuCoreConfig::instance()->isRegistered(), false);
64 SsuCoreConfig::instance()->setValue("privateKey", "fooKey");
65 QCOMPARE(SsuCoreConfig::instance()->isRegistered(), false);
66 SsuCoreConfig::instance()->setValue("certificate", "fooCert");
67 QCOMPARE(SsuCoreConfig::instance()->isRegistered(), true);
68}
69
70void CoreconfigTest::testLastCredentialsUpdate()
71{
72 QCOMPARE(SsuCoreConfig::instance()->lastCredentialsUpdate(), QDateTime());
73 SsuCoreConfig::instance()->setValue("lastCredentialsUpdate",
74 QDateTime::fromString("2013-04-08", Qt::ISODate));
75 QCOMPARE(SsuCoreConfig::instance()->lastCredentialsUpdate(),
76 QDateTime::fromString("2013-04-08", Qt::ISODate));
77}
78
79void CoreconfigTest::testRelease()
80{
81 QCOMPARE(SsuCoreConfig::instance()->release(false), QString("latest"));
82 QCOMPARE(SsuCoreConfig::instance()->release(true), QString("next"));
83 SsuCoreConfig::instance()->setRelease("next", false);
84 QCOMPARE(SsuCoreConfig::instance()->release(false), QString("next"));
85 QCOMPARE(SsuCoreConfig::instance()->release(true), QString("next"));
86 SsuCoreConfig::instance()->setRelease("latest", true);
87 QCOMPARE(SsuCoreConfig::instance()->release(false), QString("next"));
88 QCOMPARE(SsuCoreConfig::instance()->release(true), QString("latest"));
89}
90
91void CoreconfigTest::testSslVerify()
92{
93 QCOMPARE(SsuCoreConfig::instance()->useSslVerify(), true);
94 SsuCoreConfig::instance()->setValue("ssl-verify", false);
95 QCOMPARE(SsuCoreConfig::instance()->useSslVerify(), false);
96}
Q_INVOKABLE void setFlavour(const QString &flavour)
Q_INVOKABLE void setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode editMode=Ssu::Replace)
Q_INVOKABLE void setDomain(const QString &domain)
Q_INVOKABLE void setRelease(const QString &release, bool rnd=false)
@ ReleaseMode
Enable Release mode.
Definition ssu.h:70
@ LenientMode
Disable strict mode (i.e., keep unmanaged repositories).
Definition ssu.h:71
@ Replace
Replace the old value with the new one.
Definition ssu.h:92
@ Add
Make sure the given value is set in the bitmask.
Definition ssu.h:93
@ Remove
Make sure the given value is not set in the bitmask.
Definition ssu.h:94