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

Proposed by Alberto Mardegan on 2015-06-26
Status: Merged
Approved by: David Barth on 2015-07-15
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 continuous-integration Approve on 2015-07-15
David Barth (community) 2015-06-26 Approve on 2015-07-15
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.
276. By Alberto Mardegan on 2015-07-15

Add unit test

David Barth (dbarth) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'online-accounts-service/ui-proxy.cpp'
2--- online-accounts-service/ui-proxy.cpp 2015-04-23 12:27:42 +0000
3+++ online-accounts-service/ui-proxy.cpp 2015-07-15 11:04:27 +0000
4@@ -299,12 +299,13 @@
5 if (profile.isEmpty()) {
6 profile = "unconfined";
7 } else {
8+ QProcessEnvironment env = m_process.processEnvironment();
9+ env.insert("APP_ID", profile);
10 /* Set TMPDIR to a location which the confined process can actually
11 * use */
12 QString tmpdir =
13 QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) +
14 "/" + profile.split('_')[0];
15- QProcessEnvironment env = m_process.processEnvironment();
16 env.insert("TMPDIR", tmpdir);
17 m_process.setProcessEnvironment(env);
18 }
19
20=== added directory 'tests/online-accounts-service/data'
21=== added file 'tests/online-accounts-service/data/com.ubuntu.test_confined.provider'
22--- tests/online-accounts-service/data/com.ubuntu.test_confined.provider 1970-01-01 00:00:00 +0000
23+++ tests/online-accounts-service/data/com.ubuntu.test_confined.provider 2015-07-15 11:04:27 +0000
24@@ -0,0 +1,6 @@
25+<?xml version="1.0" encoding="UTF-8" ?>
26+<provider id="com.ubuntu.test_confined">
27+ <name>Click provider</name>
28+ <icon>general_myprovider</icon>
29+ <profile>com.ubuntu.test_confined_0.2</profile>
30+</provider>
31
32=== modified file 'tests/online-accounts-service/tst_ui_proxy.cpp'
33--- tests/online-accounts-service/tst_ui_proxy.cpp 2015-04-23 12:27:42 +0000
34+++ tests/online-accounts-service/tst_ui_proxy.cpp 2015-07-15 11:04:27 +0000
35@@ -56,6 +56,7 @@
36 QString programName() const { return m_program; }
37 QStringList arguments() const { return m_arguments; }
38 void sendOperation(const QVariantMap &data);
39+ QProcessEnvironment environment() const { return m_process->processEnvironment(); }
40
41 private Q_SLOTS:
42 void onDataReady(QByteArray &data);
43@@ -199,6 +200,7 @@
44 const QVariantMap &parameters);
45
46 private Q_SLOTS:
47+ void initTestCase();
48 void testInit();
49 void testRequest_data();
50 void testRequest();
51@@ -208,6 +210,8 @@
52 void testWrapper();
53 void testTrustSessionError_data();
54 void testTrustSessionError();
55+ void testConfinedPlugin_data();
56+ void testConfinedPlugin();
57
58 private:
59 QDBusConnection m_connection;
60@@ -236,6 +240,16 @@
61 return request;
62 }
63
64+void UiProxyTest::initTestCase()
65+{
66+ qputenv("ACCOUNTS", "/tmp/");
67+ qputenv("AG_APPLICATIONS", TEST_DATA_DIR);
68+ qputenv("AG_SERVICES", TEST_DATA_DIR);
69+ qputenv("AG_SERVICE_TYPES", TEST_DATA_DIR);
70+ qputenv("AG_PROVIDERS", TEST_DATA_DIR);
71+ qputenv("XDG_DATA_HOME", TEST_DATA_DIR);
72+}
73+
74 void UiProxyTest::testInit()
75 {
76 /* By passing pid = 0, we disable the prompt session code */
77@@ -516,6 +530,59 @@
78 delete proxy;
79
80 qunsetenv(envVarKey.constData());
81+ qunsetenv("QT_QPA_PLATFORM");
82+}
83+
84+void UiProxyTest::testConfinedPlugin_data()
85+{
86+ QTest::addColumn<QString>("providerId");
87+ QTest::addColumn<QString>("expectedProfile");
88+ QTest::addColumn<QString>("expectedAppId");
89+
90+ QTest::newRow("unconfined") <<
91+ QString() <<
92+ "unconfined" <<
93+ QString();
94+
95+ QTest::newRow("confined") <<
96+ "com.ubuntu.test_confined" <<
97+ "com.ubuntu.test_confined_0.2" <<
98+ "com.ubuntu.test_confined_0.2";
99+}
100+
101+void UiProxyTest::testConfinedPlugin()
102+{
103+ QFETCH(QString, providerId);
104+ QFETCH(QString, expectedProfile);
105+ QFETCH(QString, expectedAppId);
106+
107+ Request *request = createRequest(OAU_INTERFACE, "doSomething",
108+ "unconfined", QVariantMap());
109+ RequestPrivate *r = RequestPrivate::mocked(request);
110+ r->setProviderId(providerId);
111+
112+ UiProxy *proxy = new UiProxy(0, this);
113+ QVERIFY(proxy->init());
114+
115+ QSignalSpy finished(proxy, SIGNAL(finished()));
116+ proxy->handleRequest(request);
117+
118+ QTRY_VERIFY(!remoteProcesses.isEmpty());
119+ QCOMPARE(remoteProcesses.count(), 1);
120+
121+ RemoteProcess *process = remoteProcesses.values().first();
122+ QVERIFY(process);
123+
124+ QStringList args = process->arguments();
125+ int option = args.indexOf("--profile");
126+ QVERIFY(option > 0);
127+
128+ QCOMPARE(args.at(option + 1), expectedProfile);
129+
130+ QProcessEnvironment env = process->environment();
131+ QCOMPARE(env.value("APP_ID"), expectedAppId);
132+
133+ delete proxy;
134 }
135
136 QTEST_MAIN(UiProxyTest);
137
138=== modified file 'tests/online-accounts-service/tst_ui_proxy.pro'
139--- tests/online-accounts-service/tst_ui_proxy.pro 2015-02-16 15:45:27 +0000
140+++ tests/online-accounts-service/tst_ui_proxy.pro 2015-07-15 11:04:27 +0000
141@@ -14,7 +14,8 @@
142
143 DEFINES += \
144 BUILDING_TESTS \
145- INSTALL_BIN_DIR=\\\"$${INSTALL_PREFIX}/bin\\\"
146+ INSTALL_BIN_DIR=\\\"$${INSTALL_PREFIX}/bin\\\" \
147+ TEST_DATA_DIR=\\\"$${PWD}/data\\\"
148
149 PKGCONFIG += \
150 accounts-qt5 \

Subscribers

People subscribed via source and target branches