Commit 8499335d authored by Pekka Lundstrom's avatar Pekka Lundstrom

Implemented domain and domain-specific blocks in respos.ini

Signed-off-by: default avatarPekka Lundstrom <pekka.lundstrom@jollamobile.com>
parent 881a7833
......@@ -256,6 +256,13 @@ QString Ssu::flavour(){
return "release";
}
QString Ssu::domain(){
if (settings->contains("domain"))
return settings->value("domain").toString();
else
return "";
}
bool Ssu::isRegistered(){
if (!settings->contains("privateKey"))
return false;
......@@ -352,6 +359,19 @@ QString Ssu::repoUrl(QString repoName, bool rndRepo, QHash<QString, QString> rep
repoParameters.insert("deviceFamily", deviceFamily());
repoParameters.insert("deviceModel", deviceModel());
// Domain variables
QString domainSection = domain() + "-domain";
QStringList sections = repoSettings->childGroups();
if (sections.contains(domainSection))
repoSettings->beginGroup(domainSection);
else
repoSettings->beginGroup("default-domain");
QStringList domainKeys = repoSettings->allKeys();
foreach (const QString &key, domainKeys){
repoParameters.insert(key, repoSettings->value(key).toString());
}
repoSettings->endGroup();
if (settings->contains("repository-urls/" + repoName))
r = settings->value("repository-urls/" + repoName).toString();
else {
......@@ -451,8 +471,11 @@ void Ssu::sendRegistration(QString username, QString password){
ssuCaCertificate = settings->value("ca-certificate").toString();
if (!settings->contains("register-url")){
setError("URL for SSU registration not set (config key 'register-url')");
return;
ssuRegisterUrl = repoUrl("register-url");
if (ssuRegisterUrl.isEmpty()){
setError("URL for SSU registration not set (config key 'register-url')");
return;
}
} else
ssuRegisterUrl = settings->value("register-url").toString();
......@@ -565,6 +588,11 @@ void Ssu::setRelease(QString release, bool rnd){
settings->setValue("release", release);
}
void Ssu::setDomain(QString domain){
settings->setValue("domain", domain);
settings->sync();
}
void Ssu::storeAuthorizedKeys(QByteArray data){
QDir dir;
......@@ -605,8 +633,11 @@ void Ssu::updateCredentials(bool force){
ssuCaCertificate = settings->value("ca-certificate").toString();
if (!settings->contains("credentials-url")){
setError("URL for credentials update not set (config key 'credentials-url')");
return;
ssuCredentialsUrl = repoUrl("credentials-url");
if (ssuCredentialsUrl.isEmpty()){
setError("URL for credentials update not set (config key 'credentials-url')");
return;
}
} else
ssuCredentialsUrl = settings->value("credentials-url").toString();
......
......@@ -64,6 +64,11 @@ class Ssu: public QObject {
* @return current flavour (usually something like testing, release, ..)
*/
Q_INVOKABLE QString flavour();
/**
* Get the current domain used in registration
* @return domain, or "" if not set
*/
Q_INVOKABLE QString domain();
/**
* Return devices RND registration status
* @retval true device is registered
......@@ -98,6 +103,10 @@ class Ssu: public QObject {
* Set the release version string for either a release, or a RnD snapshot
*/
Q_INVOKABLE void setRelease(QString release, bool rnd=false);
/**
* Set the domain string (usually something like nemo, jolla, ..)
*/
Q_INVOKABLE void setDomain(QString domain);
/**
* Unregister a device. This will clean all registration data from a device,
* though will not touch the information on SSU server; the information there
......
......@@ -34,26 +34,26 @@
[all]
credentials=jolla
credentials-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/credentials.xml
register-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/register.xml
[release]
jolla=https://packages.example.com/releases/%(release)/jolla/%(arch)/
jolla-bad=https://packages.example.com/notused-bad/%(release)/bad/%(arch)/
mer-core=https://packages.example.com/%(release)/mer/%(arch)/%(debugSplit)/
adaptation-common-main=https://packages.example.com/releases/%(release)/nemo/adaptation-%(deviceFamily)-common/%(arch)/
adaptation=https://packages.example.com/releases/%(release)/nemo/adaptation-%(adaptation)/%(arch)/
nemo=https://packages.example.com/releases/%(release)/nemo/platform/%(arch)/
jolla=https://%(packagesDomain)/releases/%(release)/jolla/%(arch)/
jolla-bad=https://%(packagesDomain)/notused-bad/%(release)/bad/%(arch)/
mer-core=https://%(packagesDomain)/%(release)/mer/%(arch)/%(debugSplit)/
adaptation-common-main=https://%(packagesDomain)/releases/%(release)/nemo/adaptation-%(deviceFamily)-common/%(arch)/
adaptation=https://%(packagesDomain)/releases/%(release)/nemo/adaptation-%(adaptation)/%(arch)/
nemo=https://%(packagesDomain)/releases/%(release)/nemo/platform/%(arch)/
[rnd]
mer-core=https://packages.example.com/mer/%(release)/builds/%(arch)/%(debugSplit)/
adaptation-common-main=https://packages.example.com/nemo/%(release)/adaptation-%(adaptation)-common/%(arch)/
adaptation=https://packages.example.com/nemo/%(release)/adaptation-%(deviceFamily)/%(arch)/
nemo=https://packages.example.com/nemo/%(release)/platform/%(arch)/
non-oss-bad=https://dump.example.com/pj:/non-oss-bad%(flavour)/%(release)_%(arch)/
non-oss=https://dump.example.com/pj:/non-oss%(flavour)/%(release)_%(arch)/
oss-bad=https://dump.example.com/pj:/oss-bad%(flavour)/%(release)_%(arch)/
oss=https://dump.example.com/pj:/oss%(flavour)/%(release)_%(arch)/
mer-core=https://%(packagesDomain)/mer/%(release)/builds/%(arch)/%(debugSplit)/
adaptation-common-main=https://%(packagesDomain)/nemo/%(release)/adaptation-%(adaptation)-common/%(arch)/
adaptation=https://%(packagesDomain)/nemo/%(release)/adaptation-%(deviceFamily)/%(arch)/
nemo=https://%(packagesDomain)/nemo/%(release)/platform/%(arch)/
non-oss-bad=https://%(dumpDomain)/pj:/non-oss-bad%(flavour)/%(release)_%(arch)/
non-oss=https://%(dumpDomain)/pj:/non-oss%(flavour)/%(release)_%(arch)/
oss-bad=https://%(dumpDomain)/pj:/oss-bad%(flavour)/%(release)_%(arch)/
oss=https://%(dumpDomain)/pj:/oss%(flavour)/%(release)_%(arch)/
[devel-flavour]
flavour-pattern=
......@@ -63,3 +63,16 @@ flavour-pattern=:/release
[testing-flavour]
flavour-pattern=:/testing
[example-domain]
dumpDomain=dump.example.com
packagesDomain=packages.example.com
ssuRegDomain=ssu.example.com
ssuRegPath=ssu/device
# fallback if domain is not matched or not set
[default-domain]
dumpDomain=dump.testing.com
packagesDomain=packages.testing.com
ssuRegDomain=ssu.testing.com
ssuRegPath=ssu/device
......@@ -8,10 +8,8 @@ rndRelease=latest
release=
adaptation=
ca-certificate=
credentials-url=https://example.com/ssu/device/%1/credentials.xml
register-url=https://example.com/ssu/device/%1/register.xml
credentials-scope=example
[2]
release=latest
credentials-url-example=https://example.com
......@@ -6,8 +6,6 @@ rndRelease=latest
release=
adaptation=
ca-certificate=
credentials-url=https://example.com/ssu/device/%1/credentials.xml
register-url=https://example.com/ssu/device/%1/register.xml
credentials-scope=example
[repository-urls]
......
......@@ -60,6 +60,28 @@ void UrlResolverTest::checkRelease(){
ssu.setRelease("latest", true);
}
void UrlResolverTest::checkDomain(){
QString credentialsUrl;
QString registerUrl;
// domain not defined -> default
ssu.setDomain("");
credentialsUrl = ssu.repoUrl("credentials-url");
QCOMPARE(credentialsUrl, QString("https://ssu.testing.com/ssu/device/%1/credentials.xml"));
// domain defined but not matching block -> default
ssu.setDomain("nevermind");
credentialsUrl = ssu.repoUrl("credentials-url");
QCOMPARE(credentialsUrl, QString("https://ssu.testing.com/ssu/device/%1/credentials.xml"));
ssu.setDomain("example");
QCOMPARE(ssu.domain(), QString("example"));
credentialsUrl = ssu.repoUrl("credentials-url");
QCOMPARE(credentialsUrl, QString("https://ssu.example.com/ssu/device/%1/credentials.xml"));
registerUrl = ssu.repoUrl("register-url");
QCOMPARE(registerUrl, QString("https://ssu.example.com/ssu/device/%1/register.xml"));
}
void UrlResolverTest::checkCleanUrl(){
QHashIterator<QString, QString> i(rndRepos);
while (i.hasNext()){
......@@ -101,3 +123,5 @@ void UrlResolverTest::checkReleaseRepoUrls(){
QCOMPARE(url, i.value());
}
}
......@@ -22,6 +22,7 @@ class UrlResolverTest: public QObject {
void cleanupTestCase();
void checkFlavour();
void checkRelease();
void checkDomain();
void checkCleanUrl();
void simpleRepoUrlLookup();
void checkReleaseRepoUrls();
......
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