Commit 8a44464f authored by sage's avatar sage

Merge pull request #48 from nemomobile/jb32346

Allow defining url domains to be used with specific credentials
parents 53a40e23 fff0d58d
......@@ -11,3 +11,8 @@ doc/latex
/rndssucli/ssuproxy.h
/.nodocs
ssucli/ssuproxy.h
*.o
RPMS/
installroot/
moc_*.cpp
qrc_*.cpp
......@@ -98,6 +98,7 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo){
SsuVariables::variable(&repoSettings,
domain() + "-domain",
storeAuthReposKey).toStringList();
if (storeAuthRepos.empty())
storeAuthRepos =
SsuVariables::variable(&repoSettings,
......@@ -107,6 +108,18 @@ QString Ssu::credentialsScope(QString repoName, bool rndRepo){
if (storeAuthRepos.contains(repoName))
return "store";
// If we defined explicitly what credentials to use with which secure domain
// use those.
QHash<QString, QString> secureDomainAuth;
SsuVariables::variableSection(&repoSettings, "secure-domain-auth", &secureDomainAuth);
QHashIterator<QString, QString> i(secureDomainAuth);
while (i.hasNext()) {
i.next();
if (repoUrl(repoName, rndRepo).contains(i.key()) && !i.value().isEmpty()) {
return i.value();
}
}
return settings->credentialsScope(repoName, rndRepo);
}
......
......@@ -7,6 +7,7 @@ SUBDIRS = \
ut_coreconfig \
ut_deviceinfo \
ut_repomanager \
ut_ssu \
ut_ssucli \
ut_sandbox \
ut_settings \
......
......@@ -18,6 +18,11 @@
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_repomanager</step>
</case>
</set>
<set name="ssu" description="Test to determine if ssu library works properly" feature="ssu">
<case name="ut_ssu" type="Functional" description="ssu library" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_ssu</step>
</case>
</set>
<set name="ssucli" description="Test to determine if ssu command line tool works properly" feature="ssucli">
<case name="ut_ssucli" type="Functional" description="ssu command line utility test" timeout="1000" subfeature="">
<step expected_result="0">/opt/tests/ssu/runtest.sh ut_ssucli</step>
......
/**
* @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 "ssutest.h"
int main(int argc, char **argv){
Sandbox sandbox(QString("%1/configroot").arg(LOCATE_DATA_PATH),
Sandbox::UseAsSkeleton, Sandbox::ThisProcess);
if (!sandbox.activate()){
qFatal("Failed to activate sandbox");
}
SsuTest ssuTest;
if (QTest::qExec(&ssuTest, argc, argv))
return 1;
return 0;
}
/**
* @file repomanagertest.cpp
* @copyright 2015 Jolla Ltd.
* @author Marko Saukko <marko.saukko@jolla.com>
* @date 2015
* @todo Add unit tests for other ssu lib functions.
*/
#include "ssutest.h"
#include <QtTest/QtTest>
#include "libssu/ssucoreconfig_p.h"
#include "libssu/ssurepomanager.h"
#include "libssu/ssu.h"
void SsuTest::initTestCase(){
}
void SsuTest::testCredentialsScope(){
// For store repo store is returned always no matter what
QCOMPARE(ssu.credentialsScope(QString("store")),QString("store"));
QCOMPARE(ssu.credentialsScope(QString("store-c-example")),QString("store"));
ssu.setDomain(QString("default"));
QCOMPARE(ssu.domain(),QString("default"));
QCOMPARE(ssu.credentialsScope(QString("store")),QString("store"));
QCOMPARE(ssu.credentialsScope(QString("apps")),QString("vendor"));
QCOMPARE(ssu.credentialsScope(QString("vendor")),QString("vendor"));
QCOMPARE(ssu.credentialsScope(QString("store"),true),QString("store"));
QCOMPARE(ssu.credentialsScope(QString("adaptation"),true),QString("vendor"));
QCOMPARE(ssu.credentialsScope(QString("oss"),true),QString("vendor"));
}
void SsuTest::testCredentialsScopeStoreAuthRepos() {
ssu.setDomain(QString("example"));
QCOMPARE(ssu.domain(),QString("example"));
QCOMPARE(ssu.credentialsScope(QString("store")),QString("store"));
// store-auth-repos=apps in example domain
QCOMPARE(ssu.credentialsScope(QString("apps")),QString("store"));
QCOMPARE(ssu.credentialsScope(QString("vendor")),QString("vendor"));
QCOMPARE(ssu.credentialsScope(QString("store"),true),QString("store"));
QCOMPARE(ssu.credentialsScope(QString("adaptation"),true),QString("vendor"));
QCOMPARE(ssu.credentialsScope(QString("oss"),true),QString("vendor"));
}
void SsuTest::testCredentialsScopeSecureDomainAuth(){
// [secure-domain-auth]
// packages.example2.com=example2
ssu.setDomain("example2");
QCOMPARE(ssu.domain(),QString("example2"));
QCOMPARE(ssu.credentialsScope(QString("store"),false),QString("store"));
QCOMPARE(ssu.credentialsScope(QString("apps"),false),QString("example2"));
QCOMPARE(ssu.credentialsScope(QString("vendor"),false),QString("example2"));
// adaptation uses packages.example2.com
QCOMPARE(ssu.credentialsScope(QString("adaptation"),true),QString("example2"));
// oss uses dump.example2.com, thus vendor
QCOMPARE(ssu.credentialsScope(QString("oss"),true),QString("vendor"));
}
/**
* @file repomanagertest.h
* @copyright 2015 Jolla Ltd.
* @author Marko Saukko <marko.saukko@jolla.com>
* @date 2015
*/
#ifndef _SSUTEST_H
#define _SSUTEST_H
#include <QObject>
#include <QStringList>
#include "libssu/ssu.h"
class SsuTest: public QObject {
Q_OBJECT
private slots:
void initTestCase();
void testCredentialsScope();
void testCredentialsScopeStoreAuthRepos();
void testCredentialsScopeSecureDomainAuth();
private:
Ssu ssu;
};
#endif
[all]
credentials=vendor
store=https://%(packagesDomain)/store/
[release]
vendor=https://%(packagesDomain)/releases/%(release)/vendor/%(arch)/
apps=https://%(packagesDomain)/releases/%(release)/vendor-apps/%(arch)/
[rnd]
mer-core=https://%(packagesDomain)/mer/%(release)/builds/%(arch)/%(debugSplit)/
adaptation=https://%(packagesDomain)/nemo/%(release)/adaptation-%(deviceFamily)/%(arch)/
nemo=https://%(packagesDomain)/nemo/%(release)/platform/%(arch)/
non-oss=https://%(dumpDomain)/pj:/non-oss%(flavour)/%(release)_%(arch)/
oss=https://%(dumpDomain)/pj:/oss%(flavour)/%(release)_%(arch)/
[devel-flavour]
flavour-pattern=
[release-flavour]
flavour-pattern=:/release
[testing-flavour]
flavour-pattern=:/testing
[example-domain]
dumpDomain=dump.example.com
packagesDomain=packages.example.com
store-auth-repos=apps
[example2-domain]
dumpDomain=dump.example2.com
packagesDomain=packages.example2.com
# fallback if domain is not matched or not set
[default-domain]
dumpDomain=dump.testing.com
packagesDomain=packages.testing.com
[default-repos]
release=vendor,apps
rnd=mer-core,adaptation,nemo,non-oss,oss
[secure-domain-auth]
packages.example2.com=example2
[General]
credentials-scope=vendor
TARGET = ut_ssu
include(../testapplication.pri)
include(ut_ssu_dependencies.pri)
HEADERS = \
ssutest.h \
SOURCES = \
main.cpp \
ssutest.cpp \
test_data_etc.files = \
testdata/ssu.ini \
test_data_usr_share.files = \
testdata/repos.ini \
include(../../libssu/libssu.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