ssu
coreconfigtest.cpp
Go to the documentation of this file.
1 
8 #include "coreconfigtest.h"
9 
10 #include <QtTest/QtTest>
11 
12 #include "libssu/ssucoreconfig_p.h"
13 
14 void CoreconfigTest::testCredentialsScope()
15 {
16  QCOMPARE(SsuCoreConfig::instance()->credentialsScope("/*ignored*/", false), QString("example"));
17 
18 }
19 
20 void 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 
26 void CoreconfigTest::testCredentialsUrl()
27 {
28  QCOMPARE(SsuCoreConfig::instance()->credentialsUrl("example"), QString("http://creden.tia.ls/"));
29 }
30 
31 void CoreconfigTest::testFlavour()
32 {
33  QCOMPARE(SsuCoreConfig::instance()->flavour(), QString("testing"));
34  SsuCoreConfig::instance()->setFlavour("release");
35  QCOMPARE(SsuCoreConfig::instance()->flavour(), QString("release"));
36 }
37 
38 void 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 
52 void CoreconfigTest::testDomain()
53 {
54  QCOMPARE(SsuCoreConfig::instance()->domain(), QString(""));
55  SsuCoreConfig::instance()->setDomain("foo");
56  QCOMPARE(SsuCoreConfig::instance()->domain(), QString("foo"));
57 }
58 
59 void 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 
70 void 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 
79 void 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 
91 void CoreconfigTest::testSslVerify()
92 {
93  QCOMPARE(SsuCoreConfig::instance()->useSslVerify(), true);
94  SsuCoreConfig::instance()->setValue("ssl-verify", false);
95  QCOMPARE(SsuCoreConfig::instance()->useSslVerify(), false);
96 }
SsuCoreConfig::setDeviceMode
Q_INVOKABLE void setDeviceMode(Ssu::DeviceModeFlags mode, enum Ssu::EditMode editMode=Ssu::Replace)
Definition: ssucoreconfig.cpp:111
Ssu::ReleaseMode
@ ReleaseMode
Enable Release mode.
Definition: ssu.h:69
Ssu::Add
@ Add
Make sure the given value is set in the bitmask.
Definition: ssu.h:92
coreconfigtest.h
SsuCoreConfig::setRelease
Q_INVOKABLE void setRelease(const QString &release, bool rnd=false)
Definition: ssucoreconfig.cpp:135
SsuCoreConfig::setDomain
Q_INVOKABLE void setDomain(const QString &domain)
Definition: ssucoreconfig.cpp:148
Ssu::Remove
@ Remove
Make sure the given value is not set in the bitmask.
Definition: ssu.h:93
ssucoreconfig_p.h
Ssu::LenientMode
@ LenientMode
Disable strict mode (i.e., keep unmanaged repositories)
Definition: ssu.h:70
SsuCoreConfig::setFlavour
Q_INVOKABLE void setFlavour(const QString &flavour)
Definition: ssucoreconfig.cpp:127
Ssu::Replace
@ Replace
Replace the old value with the new one.
Definition: ssu.h:91