Merge lp:~mardy/ubuntu-system-settings-online-accounts/lp1376445 into lp:~online-accounts/ubuntu-system-settings-online-accounts/master

Proposed by Alberto Mardegan
Status: Merged
Merged at revision: 208
Proposed branch: lp:~mardy/ubuntu-system-settings-online-accounts/lp1376445
Merge into: lp:~online-accounts/ubuntu-system-settings-online-accounts/master
Diff against target: 120 lines (+52/-5)
2 files modified
plugins/OnlineAccountsPlugin/application-manager.cpp (+11/-1)
tests/plugin/tst_application_manager.cpp (+41/-4)
To merge this branch: bzr merge lp:~mardy/ubuntu-system-settings-online-accounts/lp1376445
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
Review via email: mp+240830@code.launchpad.net

Commit message

Handle requests from unconfined applications

When an unconfined process is requesting access for a specific application ID, the profile to be added to the ACL must be the one find in the .application file beloging to t
he given application ID, and not "unconfined.
Add a test case to catch regressions.

Description of the change

Handle requests from unconfined applications

When an unconfined process is requesting access for a specific application ID, the profile to be added to the ACL must be the one find in the .application file beloging to t
he given application ID, and not "unconfined.
Add a test case to catch regressions.

To post a comment you must log in.
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

seem comment inline

review: Needs Information
209. By Alberto Mardegan

Make sure we don't use an empty profile

Revision history for this message
Alberto Mardegan (mardy) wrote :

> seem comment inline

Good catch! I think it's now fixed, and I've added a comment explaining what we are doing there, and one more test for this case.

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

Looks good now

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/OnlineAccountsPlugin/application-manager.cpp'
2--- plugins/OnlineAccountsPlugin/application-manager.cpp 2014-10-06 09:33:22 +0000
3+++ plugins/OnlineAccountsPlugin/application-manager.cpp 2014-11-07 08:34:30 +0000
4@@ -158,7 +158,17 @@
5 app.insert(QStringLiteral("id"), applicationId);
6 app.insert(QStringLiteral("displayName"), application.displayName());
7 app.insert(QStringLiteral("icon"), application.iconName());
8- app.insert(QStringLiteral("profile"), profile);
9+ /* The applicationMatchesProfile() test above ensures that either the peer
10+ * is unconfined, or the profile in the .application file matches the one
11+ * we see from our peer.
12+ * In the first case, what we really want is the profile from the
13+ * .application file (if that's set), to cover the case where an unconfined
14+ * process is asking authorization on behalf of a confined app. */
15+ QString targetProfile = d->applicationProfile(application.name());
16+ if (targetProfile.isEmpty()) {
17+ targetProfile = profile;
18+ }
19+ app.insert(QStringLiteral("profile"), targetProfile);
20
21 /* List all the services supported by this application */
22 QVariantList serviceIds;
23
24=== modified file 'tests/plugin/tst_application_manager.cpp'
25--- tests/plugin/tst_application_manager.cpp 2014-10-06 09:33:22 +0000
26+++ tests/plugin/tst_application_manager.cpp 2014-11-07 08:34:30 +0000
27@@ -190,7 +190,8 @@
28 {
29 QTest::addColumn<QString>("applicationId");
30 QTest::addColumn<QString>("contents");
31- QTest::addColumn<QString>("profile");
32+ QTest::addColumn<QString>("inputProfile");
33+ QTest::addColumn<QString>("expectedProfile");
34 QTest::addColumn<QStringList>("services");
35
36 QTest::newRow("no-services") <<
37@@ -201,6 +202,7 @@
38 " <profile>com.ubuntu.test_MyApp_0.2</profile>\n"
39 "</application>" <<
40 "com.ubuntu.test_MyApp_0.2" <<
41+ "com.ubuntu.test_MyApp_0.2" <<
42 QStringList();
43
44 QTest::newRow("no-valid-services") <<
45@@ -214,6 +216,7 @@
46 " <profile>com.ubuntu.test_MyApp2_0.2</profile>\n"
47 "</application>" <<
48 "com.ubuntu.test_MyApp2_0.2" <<
49+ "com.ubuntu.test_MyApp2_0.2" <<
50 QStringList();
51
52 QTest::newRow("email-services") <<
53@@ -229,6 +232,7 @@
54 " <profile>com.ubuntu.test_MyApp3_0.2</profile>\n"
55 "</application>" <<
56 "com.ubuntu.test_MyApp3_0.2" <<
57+ "com.ubuntu.test_MyApp3_0.2" <<
58 (QStringList() << "cool-mail" << "bad-mail");
59
60 QTest::newRow("cool-services") <<
61@@ -247,7 +251,39 @@
62 " <profile>com.ubuntu.test_MyApp4_0.2</profile>\n"
63 "</application>" <<
64 "com.ubuntu.test_MyApp4_0.2" <<
65+ "com.ubuntu.test_MyApp4_0.2" <<
66 (QStringList() << "cool-mail" << "cool-sharing");
67+
68+ QTest::newRow("unconfined app") <<
69+ "com.ubuntu.test_UnconfinedApp" <<
70+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
71+ "<application id=\"com.ubuntu.test_UnconfinedApp\">\n"
72+ " <description>My application 5</description>\n"
73+ " <services>\n"
74+ " <service id=\"cool-mail\">\n"
75+ " <description>Send email</description>\n"
76+ " </service>\n"
77+ " </services>\n"
78+ " <profile>com.ubuntu.test_UnconfinedApp_0.2</profile>\n"
79+ "</application>" <<
80+ "unconfined" <<
81+ "com.ubuntu.test_UnconfinedApp_0.2" <<
82+ (QStringList() << "cool-mail");
83+
84+ QTest::newRow("unconfined app, no profile") <<
85+ "com.ubuntu.test_UnconfinedApp2" <<
86+ "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
87+ "<application id=\"com.ubuntu.test_UnconfinedApp2\">\n"
88+ " <description>My application 6</description>\n"
89+ " <services>\n"
90+ " <service id=\"cool-mail\">\n"
91+ " <description>Send email</description>\n"
92+ " </service>\n"
93+ " </services>\n"
94+ "</application>" <<
95+ "unconfined" <<
96+ "unconfined" <<
97+ (QStringList() << "cool-mail");
98 }
99
100 void ApplicationManagerTest::testApplicationInfo()
101@@ -256,16 +292,17 @@
102
103 QFETCH(QString, applicationId);
104 QFETCH(QString, contents);
105- QFETCH(QString, profile);
106+ QFETCH(QString, inputProfile);
107+ QFETCH(QString, expectedProfile);
108 QFETCH(QStringList, services);
109
110 writeAccountsFile(applicationId + ".application", contents);
111
112 ApplicationManager manager;
113
114- QVariantMap info = manager.applicationInfo(applicationId, profile);
115+ QVariantMap info = manager.applicationInfo(applicationId, inputProfile);
116 QCOMPARE(info.value("id").toString(), applicationId);
117- QCOMPARE(info.value("profile").toString(), profile);
118+ QCOMPARE(info.value("profile").toString(), expectedProfile);
119 QCOMPARE(info.value("services").toStringList().toSet(), services.toSet());
120 }
121

Subscribers

People subscribed via source and target branches