ssutest.cpp 2.46 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/**
 * @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"

17 18
void SsuTest::initTestCase()
{
19 20
}

21 22 23 24 25
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"));
26

27 28
    ssu.setDomain(QString("default"));
    QCOMPARE(ssu.domain(), QString("default"));
29

30 31 32
    QCOMPARE(ssu.credentialsScope(QString("store")), QString("store"));
    QCOMPARE(ssu.credentialsScope(QString("apps")), QString("vendor"));
    QCOMPARE(ssu.credentialsScope(QString("vendor")), QString("vendor"));
33

34 35 36
    QCOMPARE(ssu.credentialsScope(QString("store"), true), QString("store"));
    QCOMPARE(ssu.credentialsScope(QString("adaptation"), true), QString("vendor"));
    QCOMPARE(ssu.credentialsScope(QString("oss"), true), QString("vendor"));
37 38
}

39 40 41 42
void SsuTest::testCredentialsScopeStoreAuthRepos()
{
    ssu.setDomain(QString("example"));
    QCOMPARE(ssu.domain(), QString("example"));
43

44 45 46 47
    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"));
48

49 50 51
    QCOMPARE(ssu.credentialsScope(QString("store"), true), QString("store"));
    QCOMPARE(ssu.credentialsScope(QString("adaptation"), true), QString("vendor"));
    QCOMPARE(ssu.credentialsScope(QString("oss"), true), QString("vendor"));
52 53
}

54 55 56 57
void SsuTest::testCredentialsScopeSecureDomainAuth()
{
    //  [secure-domain-auth]
    //  packages.example2.com=example2
58

59 60
    ssu.setDomain("example2");
    QCOMPARE(ssu.domain(), QString("example2"));
61

62 63 64
    QCOMPARE(ssu.credentialsScope(QString("store"), false), QString("store"));
    QCOMPARE(ssu.credentialsScope(QString("apps"), false), QString("example2"));
    QCOMPARE(ssu.credentialsScope(QString("vendor"), false), QString("example2"));
65

66 67 68 69
    // 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"));
70 71
}