Merge lp:~mardy/ubuntu-system-settings-online-accounts/click-plugins-fixes into lp:ubuntu-system-settings-online-accounts

Proposed by Alberto Mardegan
Status: Merged
Approved by: David Barth
Approved revision: 276
Merged at revision: 281
Proposed branch: lp:~mardy/ubuntu-system-settings-online-accounts/click-plugins-fixes
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 150 lines (+77/-2)
4 files modified
online-accounts-service/ui-proxy.cpp (+2/-1)
tests/online-accounts-service/data/com.ubuntu.test_confined.provider (+6/-0)
tests/online-accounts-service/tst_ui_proxy.cpp (+67/-0)
tests/online-accounts-service/tst_ui_proxy.pro (+2/-1)
To merge this branch: bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/click-plugins-fixes
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
David Barth (community) Approve
Review via email: mp+263079@code.launchpad.net

Commit message

Inject the APP_ID into the child process's environment.

This is needed so that the QML cache gets created in a directory which the account plugins can actually access.

Description of the change

Inject the APP_ID into the child process's environment.

This is needed so that the QML cache gets created in a directory which the account plugins can actually access.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
276. By Alberto Mardegan

Add unit test

Revision history for this message
David Barth (dbarth) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'online-accounts-service/ui-proxy.cpp'
--- online-accounts-service/ui-proxy.cpp 2015-04-23 12:27:42 +0000
+++ online-accounts-service/ui-proxy.cpp 2015-07-15 11:04:27 +0000
@@ -299,12 +299,13 @@
299 if (profile.isEmpty()) {299 if (profile.isEmpty()) {
300 profile = "unconfined";300 profile = "unconfined";
301 } else {301 } else {
302 QProcessEnvironment env = m_process.processEnvironment();
303 env.insert("APP_ID", profile);
302 /* Set TMPDIR to a location which the confined process can actually304 /* Set TMPDIR to a location which the confined process can actually
303 * use */305 * use */
304 QString tmpdir =306 QString tmpdir =
305 QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) +307 QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) +
306 "/" + profile.split('_')[0];308 "/" + profile.split('_')[0];
307 QProcessEnvironment env = m_process.processEnvironment();
308 env.insert("TMPDIR", tmpdir);309 env.insert("TMPDIR", tmpdir);
309 m_process.setProcessEnvironment(env);310 m_process.setProcessEnvironment(env);
310 }311 }
311312
=== added directory 'tests/online-accounts-service/data'
=== added file 'tests/online-accounts-service/data/com.ubuntu.test_confined.provider'
--- tests/online-accounts-service/data/com.ubuntu.test_confined.provider 1970-01-01 00:00:00 +0000
+++ tests/online-accounts-service/data/com.ubuntu.test_confined.provider 2015-07-15 11:04:27 +0000
@@ -0,0 +1,6 @@
1<?xml version="1.0" encoding="UTF-8" ?>
2<provider id="com.ubuntu.test_confined">
3 <name>Click provider</name>
4 <icon>general_myprovider</icon>
5 <profile>com.ubuntu.test_confined_0.2</profile>
6</provider>
07
=== modified file 'tests/online-accounts-service/tst_ui_proxy.cpp'
--- tests/online-accounts-service/tst_ui_proxy.cpp 2015-04-23 12:27:42 +0000
+++ tests/online-accounts-service/tst_ui_proxy.cpp 2015-07-15 11:04:27 +0000
@@ -56,6 +56,7 @@
56 QString programName() const { return m_program; }56 QString programName() const { return m_program; }
57 QStringList arguments() const { return m_arguments; }57 QStringList arguments() const { return m_arguments; }
58 void sendOperation(const QVariantMap &data);58 void sendOperation(const QVariantMap &data);
59 QProcessEnvironment environment() const { return m_process->processEnvironment(); }
5960
60private Q_SLOTS:61private Q_SLOTS:
61 void onDataReady(QByteArray &data);62 void onDataReady(QByteArray &data);
@@ -199,6 +200,7 @@
199 const QVariantMap &parameters);200 const QVariantMap &parameters);
200201
201private Q_SLOTS:202private Q_SLOTS:
203 void initTestCase();
202 void testInit();204 void testInit();
203 void testRequest_data();205 void testRequest_data();
204 void testRequest();206 void testRequest();
@@ -208,6 +210,8 @@
208 void testWrapper();210 void testWrapper();
209 void testTrustSessionError_data();211 void testTrustSessionError_data();
210 void testTrustSessionError();212 void testTrustSessionError();
213 void testConfinedPlugin_data();
214 void testConfinedPlugin();
211215
212private:216private:
213 QDBusConnection m_connection;217 QDBusConnection m_connection;
@@ -236,6 +240,16 @@
236 return request;240 return request;
237}241}
238242
243void UiProxyTest::initTestCase()
244{
245 qputenv("ACCOUNTS", "/tmp/");
246 qputenv("AG_APPLICATIONS", TEST_DATA_DIR);
247 qputenv("AG_SERVICES", TEST_DATA_DIR);
248 qputenv("AG_SERVICE_TYPES", TEST_DATA_DIR);
249 qputenv("AG_PROVIDERS", TEST_DATA_DIR);
250 qputenv("XDG_DATA_HOME", TEST_DATA_DIR);
251}
252
239void UiProxyTest::testInit()253void UiProxyTest::testInit()
240{254{
241 /* By passing pid = 0, we disable the prompt session code */255 /* By passing pid = 0, we disable the prompt session code */
@@ -516,6 +530,59 @@
516 delete proxy;530 delete proxy;
517531
518 qunsetenv(envVarKey.constData());532 qunsetenv(envVarKey.constData());
533 qunsetenv("QT_QPA_PLATFORM");
534}
535
536void UiProxyTest::testConfinedPlugin_data()
537{
538 QTest::addColumn<QString>("providerId");
539 QTest::addColumn<QString>("expectedProfile");
540 QTest::addColumn<QString>("expectedAppId");
541
542 QTest::newRow("unconfined") <<
543 QString() <<
544 "unconfined" <<
545 QString();
546
547 QTest::newRow("confined") <<
548 "com.ubuntu.test_confined" <<
549 "com.ubuntu.test_confined_0.2" <<
550 "com.ubuntu.test_confined_0.2";
551}
552
553void UiProxyTest::testConfinedPlugin()
554{
555 QFETCH(QString, providerId);
556 QFETCH(QString, expectedProfile);
557 QFETCH(QString, expectedAppId);
558
559 Request *request = createRequest(OAU_INTERFACE, "doSomething",
560 "unconfined", QVariantMap());
561 RequestPrivate *r = RequestPrivate::mocked(request);
562 r->setProviderId(providerId);
563
564 UiProxy *proxy = new UiProxy(0, this);
565 QVERIFY(proxy->init());
566
567 QSignalSpy finished(proxy, SIGNAL(finished()));
568 proxy->handleRequest(request);
569
570 QTRY_VERIFY(!remoteProcesses.isEmpty());
571 QCOMPARE(remoteProcesses.count(), 1);
572
573 RemoteProcess *process = remoteProcesses.values().first();
574 QVERIFY(process);
575
576 QStringList args = process->arguments();
577 int option = args.indexOf("--profile");
578 QVERIFY(option > 0);
579
580 QCOMPARE(args.at(option + 1), expectedProfile);
581
582 QProcessEnvironment env = process->environment();
583 QCOMPARE(env.value("APP_ID"), expectedAppId);
584
585 delete proxy;
519}586}
520587
521QTEST_MAIN(UiProxyTest);588QTEST_MAIN(UiProxyTest);
522589
=== modified file 'tests/online-accounts-service/tst_ui_proxy.pro'
--- tests/online-accounts-service/tst_ui_proxy.pro 2015-02-16 15:45:27 +0000
+++ tests/online-accounts-service/tst_ui_proxy.pro 2015-07-15 11:04:27 +0000
@@ -14,7 +14,8 @@
1414
15DEFINES += \15DEFINES += \
16 BUILDING_TESTS \16 BUILDING_TESTS \
17 INSTALL_BIN_DIR=\\\"$${INSTALL_PREFIX}/bin\\\"17 INSTALL_BIN_DIR=\\\"$${INSTALL_PREFIX}/bin\\\" \
18 TEST_DATA_DIR=\\\"$${PWD}/data\\\"
1819
19PKGCONFIG += \20PKGCONFIG += \
20 accounts-qt5 \21 accounts-qt5 \

Subscribers

People subscribed via source and target branches