Merge lp:~mardy/signon-apparmor-extension/apparmor-1489489 into lp:signon-apparmor-extension
- apparmor-1489489
- Merge into trunk
Proposed by
Alberto Mardegan
Status: | Merged |
---|---|
Approved by: | Alberto Mardegan |
Approved revision: | 31 |
Merged at revision: | 25 |
Proposed branch: | lp:~mardy/signon-apparmor-extension/apparmor-1489489 |
Merge into: | lp:signon-apparmor-extension |
Diff against target: |
446 lines (+183/-41) 11 files modified
.qmake.conf (+2/-0) common-project-config.pri (+6/-2) debian/control (+4/-3) src/access-control-manager.cpp (+18/-9) src/access-control-manager.h (+3/-0) tests/dbus_apparmor.py (+50/-0) tests/fake_dbus.h (+52/-0) tests/mock/apparmor.cpp (+0/-11) tests/mock/mock.pro (+2/-3) tests/tst_extension.cpp (+38/-11) tests/tst_extension.pro (+8/-2) |
To merge this branch: | bzr merge lp:~mardy/signon-apparmor-extension/apparmor-1489489 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexandre Abreu (community) | Approve | ||
Review via email: mp+306316@code.launchpad.net |
Commit message
Use GetConnectionCr
Description of the change
Use GetConnectionCr
To post a comment you must log in.
- 28. By Alberto Mardegan
-
Rename mock file
- 29. By Alberto Mardegan
-
Update apparmor dep version
- 30. By Alberto Mardegan
-
Enable C++11
Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote : | # |
review:
Needs Information
Revision history for this message
Alberto Mardegan (mardy) : | # |
- 31. By Alberto Mardegan
-
Address review comments
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file '.qmake.conf' | |||
2 | --- .qmake.conf 1970-01-01 00:00:00 +0000 | |||
3 | +++ .qmake.conf 2016-10-04 07:11:40 +0000 | |||
4 | @@ -0,0 +1,2 @@ | |||
5 | 1 | TOP_SRC_DIR = $$PWD | ||
6 | 2 | TOP_BUILD_DIR = $$shadowed($$PWD) | ||
7 | 0 | 3 | ||
8 | === modified file 'common-project-config.pri' | |||
9 | --- common-project-config.pri 2013-08-23 14:35:22 +0000 | |||
10 | +++ common-project-config.pri 2016-10-04 07:11:40 +0000 | |||
11 | @@ -2,12 +2,16 @@ | |||
12 | 2 | # Common configuration for all projects. | 2 | # Common configuration for all projects. |
13 | 3 | #----------------------------------------------------------------------------- | 3 | #----------------------------------------------------------------------------- |
14 | 4 | 4 | ||
15 | 5 | CONFIG += c++11 | ||
16 | 6 | |||
17 | 5 | # we don't like warnings... | 7 | # we don't like warnings... |
18 | 6 | QMAKE_CXXFLAGS += -Werror | 8 | QMAKE_CXXFLAGS += -Werror |
19 | 7 | # Disable RTTI | 9 | # Disable RTTI |
20 | 8 | QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti | 10 | QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti |
21 | 9 | 11 | ||
24 | 10 | TOP_SRC_DIR = $$PWD | 12 | !defined(TOP_SRC_DIR, var) { |
25 | 11 | TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) | 13 | TOP_SRC_DIR = $$PWD |
26 | 14 | TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) | ||
27 | 15 | } | ||
28 | 12 | 16 | ||
29 | 13 | include(coverage.pri) | 17 | include(coverage.pri) |
30 | 14 | 18 | ||
31 | === modified file 'debian/control' | |||
32 | --- debian/control 2014-05-15 17:28:41 +0000 | |||
33 | +++ debian/control 2016-10-04 07:11:40 +0000 | |||
34 | @@ -1,10 +1,11 @@ | |||
35 | 1 | Source: signon-apparmor-extension | 1 | Source: signon-apparmor-extension |
36 | 2 | Priority: optional | 2 | Priority: optional |
37 | 3 | Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com> | 3 | Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com> |
41 | 4 | Build-Depends: dbus-test-runner, | 4 | Build-Depends: debhelper (>= 9), |
42 | 5 | debhelper (>= 9), | 5 | libapparmor-dev (>= 2.9.1-0ubuntu9.1), |
40 | 6 | libapparmor-dev, | ||
43 | 7 | libdbus-1-dev, | 6 | libdbus-1-dev, |
44 | 7 | libqtdbusmock1-dev, | ||
45 | 8 | libqtdbustest1-dev, | ||
46 | 8 | pkg-config, | 9 | pkg-config, |
47 | 9 | qt5-default, | 10 | qt5-default, |
48 | 10 | qt5-qmake, | 11 | qt5-qmake, |
49 | 11 | 12 | ||
50 | === modified file 'src/access-control-manager.cpp' | |||
51 | --- src/access-control-manager.cpp 2016-06-07 08:05:54 +0000 | |||
52 | +++ src/access-control-manager.cpp 2016-10-04 07:11:40 +0000 | |||
53 | @@ -22,7 +22,9 @@ | |||
54 | 22 | #include "access-control-manager.h" | 22 | #include "access-control-manager.h" |
55 | 23 | 23 | ||
56 | 24 | #include <QDBusConnection> | 24 | #include <QDBusConnection> |
57 | 25 | #include <QDBusError> | ||
58 | 25 | #include <QDBusMessage> | 26 | #include <QDBusMessage> |
59 | 27 | #include <QDBusReply> | ||
60 | 26 | #include <QDebug> | 28 | #include <QDebug> |
61 | 27 | #include <QStringList> | 29 | #include <QStringList> |
62 | 28 | #include <sys/apparmor.h> | 30 | #include <sys/apparmor.h> |
63 | @@ -38,7 +40,9 @@ | |||
64 | 38 | } | 40 | } |
65 | 39 | 41 | ||
66 | 40 | AccessControlManager::AccessControlManager(QObject *parent): | 42 | AccessControlManager::AccessControlManager(QObject *parent): |
68 | 41 | SignOn::AbstractAccessControlManager(parent) | 43 | SignOn::AbstractAccessControlManager(parent), |
69 | 44 | m_dbusService(qEnvironmentVariableIsSet("SIGNON_APPARMOR_TEST") ? | ||
70 | 45 | "fake.freedesktop.DBus" : "org.freedesktop.DBus") | ||
71 | 42 | { | 46 | { |
72 | 43 | } | 47 | } |
73 | 44 | 48 | ||
74 | @@ -85,21 +89,26 @@ | |||
75 | 85 | appId = "unconfined"; | 89 | appId = "unconfined"; |
76 | 86 | } else { | 90 | } else { |
77 | 87 | QDBusMessage msg = | 91 | QDBusMessage msg = |
79 | 88 | QDBusMessage::createMethodCall("org.freedesktop.DBus", | 92 | QDBusMessage::createMethodCall(m_dbusService, |
80 | 89 | "/org/freedesktop/DBus", | 93 | "/org/freedesktop/DBus", |
81 | 90 | "org.freedesktop.DBus", | 94 | "org.freedesktop.DBus", |
83 | 91 | "GetConnectionAppArmorSecurityContext"); | 95 | "GetConnectionCredentials"); |
84 | 92 | QVariantList args; | 96 | QVariantList args; |
85 | 93 | args << uniqueConnectionId; | 97 | args << uniqueConnectionId; |
86 | 94 | msg.setArguments(args); | 98 | msg.setArguments(args); |
91 | 95 | QDBusMessage reply = | 99 | QDBusReply<QVariantMap> reply = QDBusConnection::sessionBus().call(msg, QDBus::Block); |
92 | 96 | QDBusConnection::sessionBus().call(msg, QDBus::Block); | 100 | if (reply.isValid()) { |
93 | 97 | if (reply.type() == QDBusMessage::ReplyMessage) { | 101 | QVariantMap map = reply.value(); |
94 | 98 | appId = reply.arguments().value(0, QString()).toString(); | 102 | QByteArray context = map.value("LinuxSecurityLabel").toByteArray(); |
95 | 103 | if (!context.isEmpty()) { | ||
96 | 104 | aa_splitcon(context.data(), NULL); | ||
97 | 105 | appId = QString::fromUtf8(context); | ||
98 | 106 | } | ||
99 | 99 | qDebug() << "App ID:" << appId; | 107 | qDebug() << "App ID:" << appId; |
100 | 100 | } else { | 108 | } else { |
103 | 101 | qWarning() << "Error getting app ID:" << reply.errorName() << | 109 | QDBusError error = reply.error(); |
104 | 102 | reply.errorMessage(); | 110 | qWarning() << "Error getting app ID:" << error.name() << |
105 | 111 | error.message(); | ||
106 | 103 | } | 112 | } |
107 | 104 | } | 113 | } |
108 | 105 | return appId; | 114 | return appId; |
109 | 106 | 115 | ||
110 | === modified file 'src/access-control-manager.h' | |||
111 | --- src/access-control-manager.h 2014-01-31 15:39:01 +0000 | |||
112 | +++ src/access-control-manager.h 2016-10-04 07:11:40 +0000 | |||
113 | @@ -54,6 +54,9 @@ | |||
114 | 54 | 54 | ||
115 | 55 | private: | 55 | private: |
116 | 56 | QString stripVersion(const QString &appId) const; | 56 | QString stripVersion(const QString &appId) const; |
117 | 57 | |||
118 | 58 | private: | ||
119 | 59 | QString m_dbusService; | ||
120 | 57 | }; | 60 | }; |
121 | 58 | 61 | ||
122 | 59 | #endif // SIGNON_APPARMOR_ACCESS_CONTROL_MANAGER_H | 62 | #endif // SIGNON_APPARMOR_ACCESS_CONTROL_MANAGER_H |
123 | 60 | 63 | ||
124 | === added file 'tests/dbus_apparmor.py' | |||
125 | --- tests/dbus_apparmor.py 1970-01-01 00:00:00 +0000 | |||
126 | +++ tests/dbus_apparmor.py 2016-10-04 07:11:40 +0000 | |||
127 | @@ -0,0 +1,50 @@ | |||
128 | 1 | '''dbus mock template | ||
129 | 2 | |||
130 | 3 | This creates the expected methods and properties of the | ||
131 | 4 | org.freedesktop.DBus service. | ||
132 | 5 | ''' | ||
133 | 6 | |||
134 | 7 | # This program is free software; you can redistribute it and/or modify it under | ||
135 | 8 | # the terms of the GNU Lesser General Public License as published by the Free | ||
136 | 9 | # Software Foundation; either version 3 of the License, or (at your option) any | ||
137 | 10 | # later version. See http://www.gnu.org/copyleft/lgpl.html for the full text | ||
138 | 11 | # of the license. | ||
139 | 12 | |||
140 | 13 | __author__ = 'Alberto Mardegan' | ||
141 | 14 | __email__ = 'alberto.mardegan@canonical.com' | ||
142 | 15 | __copyright__ = '(c) 2016 Canonical Ltd.' | ||
143 | 16 | __license__ = 'LGPL 3+' | ||
144 | 17 | |||
145 | 18 | import dbus | ||
146 | 19 | import time | ||
147 | 20 | |||
148 | 21 | from dbusmock import MOCK_IFACE | ||
149 | 22 | import dbusmock | ||
150 | 23 | |||
151 | 24 | BUS_NAME = 'fake.freedesktop.DBus' | ||
152 | 25 | MAIN_OBJ = '/org/freedesktop/DBus' | ||
153 | 26 | MAIN_IFACE = 'org.freedesktop.DBus' | ||
154 | 27 | SYSTEM_BUS = False | ||
155 | 28 | |||
156 | 29 | ERROR_PREFIX = 'org.freedesktop.DBus.Error.' | ||
157 | 30 | ERROR_NAME_HAS_NO_OWNER = ERROR_PREFIX + 'NameHasNoOwner' | ||
158 | 31 | |||
159 | 32 | def get_credentials(self, service): | ||
160 | 33 | if service not in self.credentials: | ||
161 | 34 | raise dbus.exceptions.DBusException('Service not found', | ||
162 | 35 | name=ERROR_NAME_HAS_NO_OWNER) | ||
163 | 36 | return self.credentials[service] | ||
164 | 37 | |||
165 | 38 | |||
166 | 39 | def load(mock, parameters): | ||
167 | 40 | mock.get_credentials = get_credentials | ||
168 | 41 | mock.AddMethods(MAIN_IFACE, [ | ||
169 | 42 | ('GetConnectionCredentials', 's', 'a{sv}', 'ret = self.get_credentials(self, args[0])'), | ||
170 | 43 | ]) | ||
171 | 44 | |||
172 | 45 | mock.credentials = {} | ||
173 | 46 | |||
174 | 47 | |||
175 | 48 | @dbus.service.method(MOCK_IFACE, in_signature='sa{sv}', out_signature='') | ||
176 | 49 | def SetCredentials(self, service, credentials): | ||
177 | 50 | self.credentials[service] = credentials | ||
178 | 0 | 51 | ||
179 | === added file 'tests/fake_dbus.h' | |||
180 | --- tests/fake_dbus.h 1970-01-01 00:00:00 +0000 | |||
181 | +++ tests/fake_dbus.h 2016-10-04 07:11:40 +0000 | |||
182 | @@ -0,0 +1,52 @@ | |||
183 | 1 | /* | ||
184 | 2 | * This file is part of signon-apparmor-extension | ||
185 | 3 | * | ||
186 | 4 | * Copyright (C) 2016 Canonical Ltd. | ||
187 | 5 | * | ||
188 | 6 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | ||
189 | 7 | * | ||
190 | 8 | * This program is free software: you can redistribute it and/or modify it | ||
191 | 9 | * under the terms of the GNU Lesser General Public License version 3, as | ||
192 | 10 | * published by the Free Software Foundation. | ||
193 | 11 | * | ||
194 | 12 | * This program is distributed in the hope that it will be useful, but | ||
195 | 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
196 | 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
197 | 15 | * PURPOSE. See the GNU Lesser General Public License for more details. | ||
198 | 16 | * | ||
199 | 17 | * You should have received a copy of the GNU Lesser General Public License | ||
200 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
201 | 19 | */ | ||
202 | 20 | |||
203 | 21 | #ifndef AP_FAKE_DBUS_H | ||
204 | 22 | #define AP_FAKE_DBUS_H | ||
205 | 23 | |||
206 | 24 | #include <QVariantMap> | ||
207 | 25 | #include <libqtdbusmock/DBusMock.h> | ||
208 | 26 | |||
209 | 27 | class FakeDBus | ||
210 | 28 | { | ||
211 | 29 | public: | ||
212 | 30 | FakeDBus(QtDBusMock::DBusMock *mock): m_mock(mock) { | ||
213 | 31 | m_mock->registerTemplate("fake.freedesktop.DBus", | ||
214 | 32 | DBUS_MOCK_TEMPLATE, | ||
215 | 33 | QDBusConnection::SessionBus); | ||
216 | 34 | } | ||
217 | 35 | |||
218 | 36 | void setCredentials(const QString &service, const QVariantMap &credentials) { | ||
219 | 37 | mockedDBusService().call("SetCredentials", service, credentials); | ||
220 | 38 | } | ||
221 | 39 | |||
222 | 40 | private: | ||
223 | 41 | OrgFreedesktopDBusMockInterface &mockedDBusService() { | ||
224 | 42 | return m_mock->mockInterface("fake.freedesktop.DBus", | ||
225 | 43 | "/org/freedesktop/DBus", | ||
226 | 44 | "org.freedesktop.DBus", | ||
227 | 45 | QDBusConnection::SessionBus); | ||
228 | 46 | } | ||
229 | 47 | |||
230 | 48 | private: | ||
231 | 49 | QtDBusMock::DBusMock *m_mock; | ||
232 | 50 | }; | ||
233 | 51 | |||
234 | 52 | #endif // AP_FAKE_DBUS_H | ||
235 | 0 | 53 | ||
236 | === modified file 'tests/mock/apparmor.cpp' | |||
237 | --- tests/mock/apparmor.cpp 2014-02-03 08:35:47 +0000 | |||
238 | +++ tests/mock/apparmor.cpp 2016-10-04 07:11:40 +0000 | |||
239 | @@ -20,8 +20,6 @@ | |||
240 | 20 | */ | 20 | */ |
241 | 21 | 21 | ||
242 | 22 | #include <QByteArray> | 22 | #include <QByteArray> |
243 | 23 | #include <QDBusConnection> | ||
244 | 24 | #include <QDBusMessage> | ||
245 | 25 | #include <QDebug> | 23 | #include <QDebug> |
246 | 26 | #include <sys/apparmor.h> | 24 | #include <sys/apparmor.h> |
247 | 27 | 25 | ||
248 | @@ -40,12 +38,3 @@ | |||
249 | 40 | *con = strdup(mockedProfile().constData()); | 38 | *con = strdup(mockedProfile().constData()); |
250 | 41 | return 0; | 39 | return 0; |
251 | 42 | } | 40 | } |
252 | 43 | |||
253 | 44 | QDBusMessage QDBusConnection::call(const QDBusMessage &message, | ||
254 | 45 | QDBus::CallMode mode, | ||
255 | 46 | int timeout) const | ||
256 | 47 | { | ||
257 | 48 | Q_UNUSED(mode); | ||
258 | 49 | Q_UNUSED(timeout); | ||
259 | 50 | return message.createReply(QVariantList() << mockedProfile().constData()); | ||
260 | 51 | } | ||
261 | 52 | 41 | ||
262 | === modified file 'tests/mock/mock.pro' | |||
263 | --- tests/mock/mock.pro 2013-09-04 06:55:40 +0000 | |||
264 | +++ tests/mock/mock.pro 2016-10-04 07:11:40 +0000 | |||
265 | @@ -1,6 +1,6 @@ | |||
266 | 1 | include(../../common-project-config.pri) | 1 | include(../../common-project-config.pri) |
267 | 2 | 2 | ||
269 | 3 | TARGET = apparmor | 3 | TARGET = fakeapparmor |
270 | 4 | TEMPLATE = lib | 4 | TEMPLATE = lib |
271 | 5 | 5 | ||
272 | 6 | CONFIG += \ | 6 | CONFIG += \ |
273 | @@ -9,8 +9,7 @@ | |||
274 | 9 | qt | 9 | qt |
275 | 10 | 10 | ||
276 | 11 | QT += \ | 11 | QT += \ |
279 | 12 | core \ | 12 | core |
278 | 13 | dbus | ||
280 | 14 | 13 | ||
281 | 15 | PKGCONFIG += \ | 14 | PKGCONFIG += \ |
282 | 16 | libapparmor | 15 | libapparmor |
283 | 17 | 16 | ||
284 | === modified file 'tests/tst_extension.cpp' | |||
285 | --- tests/tst_extension.cpp 2015-01-28 15:30:34 +0000 | |||
286 | +++ tests/tst_extension.cpp 2016-10-04 07:11:40 +0000 | |||
287 | @@ -1,5 +1,5 @@ | |||
288 | 1 | /* | 1 | /* |
290 | 2 | * Copyright (C) 2013 Canonical Ltd. | 2 | * Copyright (C) 2016 Canonical Ltd. |
291 | 3 | * | 3 | * |
292 | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> | 4 | * Contact: Alberto Mardegan <alberto.mardegan@canonical.com> |
293 | 5 | * | 5 | * |
294 | @@ -19,6 +19,8 @@ | |||
295 | 19 | * along with this library. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this library. If not, see <http://www.gnu.org/licenses/>. |
296 | 20 | */ | 20 | */ |
297 | 21 | 21 | ||
298 | 22 | #include "fake_dbus.h" | ||
299 | 23 | |||
300 | 22 | #include <QDBusConnection> | 24 | #include <QDBusConnection> |
301 | 23 | #include <QDBusMessage> | 25 | #include <QDBusMessage> |
302 | 24 | #include <QDBusServer> | 26 | #include <QDBusServer> |
303 | @@ -28,8 +30,13 @@ | |||
304 | 28 | 30 | ||
305 | 29 | #include <SignOn/AbstractAccessControlManager> | 31 | #include <SignOn/AbstractAccessControlManager> |
306 | 30 | 32 | ||
307 | 33 | #include <libqtdbusmock/DBusMock.h> | ||
308 | 34 | |||
309 | 35 | |||
310 | 31 | #define P2P_SOCKET "unix:path=/tmp/tst_extension_%1" | 36 | #define P2P_SOCKET "unix:path=/tmp/tst_extension_%1" |
311 | 32 | 37 | ||
312 | 38 | using namespace QtDBusMock; | ||
313 | 39 | |||
314 | 33 | static void setMockedProfile(const char *profile) | 40 | static void setMockedProfile(const char *profile) |
315 | 34 | { | 41 | { |
316 | 35 | if (profile) { | 42 | if (profile) { |
317 | @@ -47,6 +54,13 @@ | |||
318 | 47 | { | 54 | { |
319 | 48 | Q_OBJECT | 55 | Q_OBJECT |
320 | 49 | 56 | ||
321 | 57 | struct SetupEnvironment { | ||
322 | 58 | /* The test is run with a LD_PRELOAD in order to mock aa_getpeercon(); | ||
323 | 59 | * but we don't want this to propagate to our children: dbus-daemon in | ||
324 | 60 | * particular won't like it. */ | ||
325 | 61 | SetupEnvironment() { qunsetenv("LD_PRELOAD"); } | ||
326 | 62 | }; | ||
327 | 63 | |||
328 | 50 | public: | 64 | public: |
329 | 51 | ExtensionTest(); | 65 | ExtensionTest(); |
330 | 52 | 66 | ||
331 | @@ -62,18 +76,29 @@ | |||
332 | 62 | 76 | ||
333 | 63 | private: | 77 | private: |
334 | 64 | SignOn::AbstractAccessControlManager *m_acm; | 78 | SignOn::AbstractAccessControlManager *m_acm; |
335 | 79 | SetupEnvironment m_env; | ||
336 | 80 | QtDBusTest::DBusTestRunner m_dbus; | ||
337 | 81 | QtDBusMock::DBusMock m_mock; | ||
338 | 82 | FakeDBus m_fakeDBus; | ||
339 | 65 | QDBusConnection m_busConnection; | 83 | QDBusConnection m_busConnection; |
340 | 66 | QDBusConnection m_p2pConnection; | 84 | QDBusConnection m_p2pConnection; |
341 | 67 | }; | 85 | }; |
342 | 68 | 86 | ||
343 | 69 | ExtensionTest::ExtensionTest(): | 87 | ExtensionTest::ExtensionTest(): |
345 | 70 | m_busConnection(QDBusConnection::sessionBus()), | 88 | m_mock(m_dbus), |
346 | 89 | m_fakeDBus(&m_mock), | ||
347 | 90 | m_busConnection(m_dbus.sessionConnection()), | ||
348 | 71 | m_p2pConnection(QStringLiteral("uninitialized")) | 91 | m_p2pConnection(QStringLiteral("uninitialized")) |
349 | 72 | { | 92 | { |
350 | 93 | DBusMock::registerMetaTypes(); | ||
351 | 73 | } | 94 | } |
352 | 74 | 95 | ||
353 | 75 | void ExtensionTest::initTestCase() | 96 | void ExtensionTest::initTestCase() |
354 | 76 | { | 97 | { |
355 | 98 | m_dbus.startServices(); | ||
356 | 99 | |||
357 | 100 | qputenv("SIGNON_APPARMOR_TEST", "1"); | ||
358 | 101 | |||
359 | 77 | QPluginLoader pluginLoader(PLUGIN_PATH); | 102 | QPluginLoader pluginLoader(PLUGIN_PATH); |
360 | 78 | QObject *plugin = pluginLoader.instance(); | 103 | QObject *plugin = pluginLoader.instance(); |
361 | 79 | QVERIFY(plugin != 0); | 104 | QVERIFY(plugin != 0); |
362 | @@ -104,15 +129,15 @@ | |||
363 | 104 | 129 | ||
364 | 105 | void ExtensionTest::test_appId() | 130 | void ExtensionTest::test_appId() |
365 | 106 | { | 131 | { |
367 | 107 | QSKIP("Disable because of QTBUG-36475"); | 132 | m_fakeDBus.setCredentials(m_busConnection.baseService(), { |
368 | 133 | { "LinuxSecurityLabel", QByteArray("unconfined") }, | ||
369 | 134 | }); | ||
370 | 108 | 135 | ||
371 | 109 | /* forge a QDBusMessage */ | 136 | /* forge a QDBusMessage */ |
372 | 110 | QDBusMessage msg = | 137 | QDBusMessage msg = |
373 | 111 | QDBusMessage::createMethodCall(m_busConnection.baseService(), | 138 | QDBusMessage::createMethodCall(m_busConnection.baseService(), |
374 | 112 | "/", "my.interface", "hi"); | 139 | "/", "my.interface", "hi"); |
375 | 113 | QString appId = m_acm->appIdOfPeer(m_busConnection, msg); | 140 | QString appId = m_acm->appIdOfPeer(m_busConnection, msg); |
376 | 114 | /* At the moment, AppArmor doesn't implement the | ||
377 | 115 | * GetConnectionAppArmorSecurityContext method, so expect an error. */ | ||
378 | 116 | QCOMPARE(appId, QStringLiteral("unconfined")); | 141 | QCOMPARE(appId, QStringLiteral("unconfined")); |
379 | 117 | } | 142 | } |
380 | 118 | 143 | ||
381 | @@ -127,6 +152,9 @@ | |||
382 | 127 | 152 | ||
383 | 128 | void ExtensionTest::test_click_version() | 153 | void ExtensionTest::test_click_version() |
384 | 129 | { | 154 | { |
385 | 155 | m_fakeDBus.setCredentials(":0.1", { | ||
386 | 156 | { "LinuxSecurityLabel", QByteArray("com.ubuntu.myapp_myapp_0.2 (enforce)") }, | ||
387 | 157 | }); | ||
388 | 130 | /* forge a QDBusMessage */ | 158 | /* forge a QDBusMessage */ |
389 | 131 | setMockedProfile("com.ubuntu.myapp_myapp_0.2"); | 159 | setMockedProfile("com.ubuntu.myapp_myapp_0.2"); |
390 | 132 | QDBusMessage msg = | 160 | QDBusMessage msg = |
391 | @@ -148,23 +176,22 @@ | |||
392 | 148 | 176 | ||
393 | 149 | void ExtensionTest::test_access() | 177 | void ExtensionTest::test_access() |
394 | 150 | { | 178 | { |
397 | 151 | QSKIP("Disable because of QTBUG-36475"); | 179 | m_fakeDBus.setCredentials(m_busConnection.baseService(), { |
398 | 152 | 180 | }); | |
399 | 153 | /* forge a QDBusMessage */ | 181 | /* forge a QDBusMessage */ |
400 | 154 | QDBusMessage msg = | 182 | QDBusMessage msg = |
401 | 155 | QDBusMessage::createMethodCall(m_busConnection.baseService(), | 183 | QDBusMessage::createMethodCall(m_busConnection.baseService(), |
402 | 156 | "/", "my.interface", "hi"); | 184 | "/", "my.interface", "hi"); |
403 | 157 | bool allowed = m_acm->isPeerAllowedToAccess(m_busConnection, msg, | 185 | bool allowed = m_acm->isPeerAllowedToAccess(m_busConnection, msg, |
404 | 158 | "anyContext"); | 186 | "anyContext"); |
405 | 159 | /* At the moment, AppArmor doesn't implement the | ||
406 | 160 | * GetConnectionAppArmorSecurityContext method, so expect an error. */ | ||
407 | 161 | QVERIFY(!allowed); | 187 | QVERIFY(!allowed); |
408 | 162 | } | 188 | } |
409 | 163 | 189 | ||
410 | 164 | void ExtensionTest::test_accessWildcard() | 190 | void ExtensionTest::test_accessWildcard() |
411 | 165 | { | 191 | { |
414 | 166 | QSKIP("Disable because of QTBUG-36475"); | 192 | m_fakeDBus.setCredentials(":0.1", { |
415 | 167 | 193 | { "LinuxSecurityLabel", QByteArray("com.ubuntu.myapp_myapp_0.2 (enforce)") }, | |
416 | 194 | }); | ||
417 | 168 | /* forge a QDBusMessage */ | 195 | /* forge a QDBusMessage */ |
418 | 169 | QDBusMessage msg = | 196 | QDBusMessage msg = |
419 | 170 | QDBusMessage::createMethodCall(m_busConnection.baseService(), | 197 | QDBusMessage::createMethodCall(m_busConnection.baseService(), |
420 | 171 | 198 | ||
421 | === modified file 'tests/tst_extension.pro' | |||
422 | --- tests/tst_extension.pro 2013-09-04 06:55:40 +0000 | |||
423 | +++ tests/tst_extension.pro 2016-10-04 07:11:40 +0000 | |||
424 | @@ -14,15 +14,21 @@ | |||
425 | 14 | QT -= gui | 14 | QT -= gui |
426 | 15 | 15 | ||
427 | 16 | PKGCONFIG += \ | 16 | PKGCONFIG += \ |
429 | 17 | SignOnExtension | 17 | SignOnExtension \ |
430 | 18 | libqtdbusmock-1 \ | ||
431 | 19 | libqtdbustest-1 | ||
432 | 18 | 20 | ||
433 | 19 | DEFINES += \ | 21 | DEFINES += \ |
434 | 22 | DBUS_MOCK_TEMPLATE=\\\"$${PWD}/dbus_apparmor.py\\\" \ | ||
435 | 20 | PLUGIN_PATH=\\\"../src/libsignon-apparmor-ac.so\\\" | 23 | PLUGIN_PATH=\\\"../src/libsignon-apparmor-ac.so\\\" |
436 | 21 | 24 | ||
437 | 22 | SOURCES = \ | 25 | SOURCES = \ |
438 | 23 | tst_extension.cpp | 26 | tst_extension.cpp |
439 | 24 | 27 | ||
441 | 25 | check.commands = "LD_PRELOAD=mock/libapparmor.so dbus-test-runner -t ./$${TARGET}" | 28 | HEADERS += \ |
442 | 29 | fake_dbus.h | ||
443 | 30 | |||
444 | 31 | check.commands = "LD_PRELOAD=mock/libfakeapparmor.so ./$${TARGET}" | ||
445 | 26 | check.depends = $${TARGET} | 32 | check.depends = $${TARGET} |
446 | 27 | QMAKE_EXTRA_TARGETS += check | 33 | QMAKE_EXTRA_TARGETS += check |
447 | 28 | 34 |
a few comments and questions