Skip to content
Permalink
Browse files
Add unit tests for credentials scope.
Signed-off-by: Marko Saukko <marko.saukko@jolla.com>
  • Loading branch information
saukko committed Sep 19, 2015
1 parent 4451a8e commit fff0d58d690cd2b9a306708470c123bc4a511bc5
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 0 deletions.
@@ -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>
@@ -0,0 +1,26 @@
/**
* @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;
}
@@ -0,0 +1,67 @@
/**
* @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"));
}

@@ -0,0 +1,28 @@
/**
* @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
@@ -0,0 +1,45 @@
[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

@@ -0,0 +1,3 @@
[General]
credentials-scope=vendor

@@ -0,0 +1,17 @@
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 \

@@ -0,0 +1 @@
include(../../libssu/libssu.pri)

0 comments on commit fff0d58

Please sign in to comment.