Merge lp:~indicator-applet-developers/indicator-network/secret-agent into lp:indicator-network/13.10

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 296
Merged at revision: 291
Proposed branch: lp:~indicator-applet-developers/indicator-network/secret-agent
Merge into: lp:indicator-network/13.10
Diff against target: 934 lines (+499/-42)
18 files modified
CMakeLists.txt (+3/-0)
cmake/FindValgrind.cmake (+7/-0)
data/indicator-secret-agent.conf.in (+1/-4)
data/org.freedesktop.Notifications.xml (+47/-0)
debian/changelog (+7/-0)
debian/control (+1/-0)
secret-agent/CMakeLists.txt (+18/-0)
secret-agent/DBusTypes.h (+1/-2)
secret-agent/SecretAgent.cpp (+19/-8)
secret-agent/SecretAgent.h (+15/-4)
secret-agent/SecretRequest.cpp (+57/-8)
secret-agent/SecretRequest.h (+8/-2)
secret-agent/gtk/PasswordMenu.cpp (+134/-0)
secret-agent/gtk/PasswordMenu.h (+45/-0)
secret-agent/main.cpp (+2/-1)
tests/CMakeLists.txt (+1/-0)
tests/TestSecretAgent.cpp (+119/-13)
tests/data/valgrind.suppression (+14/-0)
To merge this branch: bzr merge lp:~indicator-applet-developers/indicator-network/secret-agent
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ted Gould (community) Approve
Michał Sawicz Needs Fixing
Pete Woods (community) Abstain
Review via email: mp+182898@code.launchpad.net

Commit message

Support unity8's system dialogues

Description of the change

Support unity8's system dialogues

To post a comment you must log in.
Revision history for this message
Pete Woods (pete-woods) wrote :

Do not merge yet. This is dependent on MacSlow's branches for Unity and the notification backend:

lp:~macslow/unity-notifications/extended-snap-decisions
lp:~macslow/unity8/extended-snap-decisions

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Hmm I tried building this locally in sbuild and got two test failures:

[==========] 8 tests from 5 test cases ran. (9618 ms total)
[ PASSED ] 6 tests.
[ FAILED ] 2 tests, listed below:
[ FAILED ] WpaPsk/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0, where GetParam() = 12-byte object <78-
D7 DD-00 D0-D4 DD-00 C0-69 DE-00>
[ FAILED ] None/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0, where GetParam() = 12-byte object <A0-D7
 DD-00 00-D7 DD-00 50-6C DE-00>

 2 FAILED TESTS

Any idea?

Revision history for this message
Pete Woods (pete-woods) wrote :

Just going to check it out myself.

On Mon, Sep 30, 2013 at 10:59 PM, Michał Sawicz <<email address hidden>
> wrote:

> Hmm I tried building this locally in sbuild and got two test failures:
>
> [==========] 8 tests from 5 test cases ran. (9618 ms total)
> [ PASSED ] 6 tests.
> [ FAILED ] 2 tests, listed below:
> [ FAILED ] WpaPsk/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0,
> where GetParam() = 12-byte object <78-
> D7 DD-00 D0-D4 DD-00 C0-69 DE-00>
> [ FAILED ] None/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0,
> where GetParam() = 12-byte object <A0-D7
> DD-00 00-D7 DD-00 50-6C DE-00>
>
> 2 FAILED TESTS
>
> Any idea?
> --
>
> https://code.launchpad.net/~indicator-applet-developers/indicator-network/secret-agent/+merge/182898
> You proposed
> lp:~indicator-applet-developers/indicator-network/secret-agent for merging.
>

Revision history for this message
Pete Woods (pete-woods) wrote :

Is this on the desktop, or on the device? Is it inside bzr bd, or running
the tests manually?

Revision history for this message
Michał Sawicz (saviq) wrote :

On a second try:

│[ FAILED ] 3 tests, listed below:
│Errors while running CTest
│[ FAILED ] WpaPsk/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0, where GetParam() = 12-byte object <78-
│F7 8B-00 D0-F4 8B-00 C0-89 8C-00>
│[ FAILED ] WpaNone/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0, where GetParam() = 12-byte object <50
│-F7 8B-00 D0-F4 8B-00 D0-47 8C-00>
│[ FAILED ] None/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0, where GetParam() = 12-byte object <A0-F7
│ 8B-00 00-F7 8B-00 50-8C 8C-00>

Racy tests?

Revision history for this message
Pete Woods (pete-woods) wrote :

> On a second try:
>
> │[ FAILED ] 3 tests, listed below:
> │Errors while running CTest
> │[ FAILED ] WpaPsk/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0,
> where GetParam() = 12-byte object <78-
> │F7 8B-00 D0-F4 8B-00 C0-89 8C-00>
> │[ FAILED ] WpaNone/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0,
> where GetParam() = 12-byte object <50
> │-F7 8B-00 D0-F4 8B-00 D0-47 8C-00>
> │[ FAILED ] None/TestSecretAgentGetSecrets.ProvidesPasswordForWpaPsk/0,
> where GetParam() = 12-byte object <A0-F7
> │ 8B-00 00-F7 8B-00 50-8C 8C-00>
>
> Racy tests?

Okay, I've pushed a fix to this (I hope). I've moved the (only) sleep to before the UnityMenuModel is destructed. This is literally the only sleep in the whole test suite. I knew it would come back to bite me.

The problem is that I need to wait until the GLib dbus connection in a UnityMenuMenu finishes dispatching all its messages. Unfortunately there's no signal I can wait for or property I can poll to ascertain when the connection is flushed. Probably the UnityMenuModel should do a connection flush in its destructor.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :
review: Approve
Revision history for this message
Pete Woods (pete-woods) wrote :

> Yeah, that's working!
>
> Some comments on unity8's merge:
>
> https://code.launchpad.net/~macslow/unity8/extended-snap-decisions-
> part1/+merge/187312

:D

Glad it works for you. Do we need to coordinate a unity8 MR to happen at the same time as this one that removes the network manager agent from there?

Revision history for this message
Michał Sawicz (saviq) wrote :

On 01.10.2013 21:11, Pete Woods wrote:
> Glad it works for you. Do we need to coordinate a unity8 MR to happen at the same time as this one that removes the network manager agent from there?

Let's get everything to support the extended SDs to land in unity8 and
unity-notifications. What would be the implications of having two agents
for the transition period?

I've a branch up to remove it from unity8¹, so assuming we merge
everything and have one ASK for unity8 and indicator-network, we can
probably coordinate that.

¹ https://code.launchpad.net/~saviq/unity8/drop-network-agents/+merge/188700
--
Michał (Saviq) Sawicz <email address hidden>
Canonical Services Ltd.

Revision history for this message
Pete Woods (pete-woods) wrote :

The problem is that the agents fight each other, and only one of them gets
to be the agent. Actually, it might be okay if they are both there, but
only one of them would work at once (whichever started first). We'd want to
check this first , obviously.

Revision history for this message
Michał Sawicz (saviq) wrote :

Question... how will this behave on the desktop? If at all?

review: Needs Information
Revision history for this message
Pete Woods (pete-woods) wrote :

> Question... how will this behave on the desktop? If at all?

It's not present on the desktop images.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

With all new unity8, unity-notifications and indicator-network from http://people.canonical.com/~msawicz/ext-snaps/ it works!

review: Approve (functional)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

130 + unity8 >= 7.82,

Should be (>= 7.82).

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Woot! Excited about this landing.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) wrote :

Stupid Jenkins failure "host key verification failed".

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-10-01 19:55:26 +0000
+++ CMakeLists.txt 2013-10-03 13:04:10 +0000
@@ -63,6 +63,9 @@
63pkg_check_modules(QMENUMODEL REQUIRED qmenumodel REQUIRED)63pkg_check_modules(QMENUMODEL REQUIRED qmenumodel REQUIRED)
64include_directories(${QMENUMODEL_INCLUDE_DIRS})64include_directories(${QMENUMODEL_INCLUDE_DIRS})
6565
66pkg_check_modules(GIO REQUIRED gio-2.0>=${GLIB_REQUIRED_VERSION})
67include_directories(${GIO_INCLUDE_DIRS})
68
66set(CMAKE_AUTOMOC ON)69set(CMAKE_AUTOMOC ON)
67set(CMAKE_INCLUDE_CURRENT_DIR ON)70set(CMAKE_INCLUDE_CURRENT_DIR ON)
6871
6972
=== modified file 'cmake/FindValgrind.cmake'
--- cmake/FindValgrind.cmake 2013-08-27 14:54:25 +0000
+++ cmake/FindValgrind.cmake 2013-10-03 13:04:10 +0000
@@ -14,7 +14,10 @@
14 set(VALGRIND_PROGRAM_OPTIONS14 set(VALGRIND_PROGRAM_OPTIONS
15 "--suppressions=${CMAKE_SOURCE_DIR}/tests/data/valgrind.suppression"15 "--suppressions=${CMAKE_SOURCE_DIR}/tests/data/valgrind.suppression"
16 "--error-exitcode=1"16 "--error-exitcode=1"
17 "--trace-children=yes"
18 "--trace-children-skip=*/python*,python*"
17 "--leak-check=full"19 "--leak-check=full"
20 "--leak-resolution=high"
18 "--gen-suppressions=all"21 "--gen-suppressions=all"
19 "--quiet"22 "--quiet"
20 )23 )
@@ -28,6 +31,10 @@
28function(add_valgrind_test NAME EXECUTABLE)31function(add_valgrind_test NAME EXECUTABLE)
29 if(ENABLE_MEMCHECK_OPTION)32 if(ENABLE_MEMCHECK_OPTION)
30 add_test(${NAME} ${VALGRIND_PROGRAM} ${VALGRIND_PROGRAM_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}")33 add_test(${NAME} ${VALGRIND_PROGRAM} ${VALGRIND_PROGRAM_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}")
34 set_tests_properties(
35 ${NAME}
36 PROPERTIES ENVIRONMENT "G_SLICE=always-malloc G_DEBUG=gc-friendly"
37 )
31 else()38 else()
32 add_test(${NAME} ${EXECUTABLE})39 add_test(${NAME} ${EXECUTABLE})
33 endif()40 endif()
3441
=== modified file 'data/indicator-secret-agent.conf.in'
--- data/indicator-secret-agent.conf.in 2013-08-29 17:03:33 +0000
+++ data/indicator-secret-agent.conf.in 2013-10-03 13:04:10 +0000
@@ -1,9 +1,6 @@
1description "Secret agent to repsond to Network Manager password requests"1description "Secret agent to repsond to Network Manager password requests"
22
3# Currently conflicts with the secret agent in Unity83start on starting indicator-network
4# so we're disabling until we can migrate fully.
5# start on starting indicator-network
6
7stop on stopping indicator-network4stop on stopping indicator-network
85
9respawn6respawn
107
=== added file 'data/org.freedesktop.Notifications.xml'
--- data/org.freedesktop.Notifications.xml 1970-01-01 00:00:00 +0000
+++ data/org.freedesktop.Notifications.xml 2013-10-03 13:04:10 +0000
@@ -0,0 +1,47 @@
1<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
2"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
3<node>
4 <interface name="org.freedesktop.Notifications">
5 <signal name="NotificationClosed">
6 <arg name="id" type="u" direction="out"/>
7 <arg name="reason" type="u" direction="out"/>
8 </signal>
9 <signal name="ActionInvoked">
10 <arg name="id" type="u" direction="out"/>
11 <arg name="action_key" type="s" direction="out"/>
12 </signal>
13 <signal name="dataChanged">
14 <arg name="id" type="u" direction="out"/>
15 </signal>
16 <method name="CloseNotification">
17 <arg name="id" type="u" direction="in"/>
18 </method>
19 <method name="GetServerInformation">
20 <arg name="name" type="s" direction="out"/>
21 <arg name="vendor" type="s" direction="out"/>
22 <arg name="version" type="s" direction="out"/>
23 <arg name="specVersion" type="s" direction="out"/>
24 </method>
25 <method name="GetCapabilities">
26 <arg type="as" direction="out"/>
27 </method>
28 <method name="Notify">
29 <arg type="u" direction="out"/>
30 <arg name="app_name" type="s" direction="in"/>
31 <arg name="replaces_id" type="u" direction="in"/>
32 <arg name="app_icon" type="s" direction="in"/>
33 <arg name="summary" type="s" direction="in"/>
34 <arg name="body" type="s" direction="in"/>
35 <arg name="actions" type="as" direction="in"/>
36 <arg name="hints" type="a{sv}" direction="in"/>
37 <annotation name="org.qtproject.QtDBus.QtTypeName.In6" value="QVariantMap"/>
38 <arg name="expire_timeout" type="i" direction="in"/>
39 </method>
40 <method name="onDataChanged">
41 <arg name="id" type="u" direction="in"/>
42 </method>
43 <method name="onCompleted">
44 <arg name="id" type="u" direction="in"/>
45 </method>
46 </interface>
47</node>
048
=== modified file 'debian/changelog'
--- debian/changelog 2013-09-18 06:24:29 +0000
+++ debian/changelog 2013-10-03 13:04:10 +0000
@@ -1,3 +1,10 @@
1indicator-network (0.5.1) UNRELEASED; urgency=low
2
3 * Add network manager secret agent.
4 * Interfaces with unity8's extended snap decisions.
5
6 -- Pete Woods <pete.woods@canonical.com> Thu, 03 Oct 2013 13:53:39 +0100
7
1indicator-network (0.5.0+13.10.20130918-0ubuntu1) saucy; urgency=low8indicator-network (0.5.0+13.10.20130918-0ubuntu1) saucy; urgency=low
29
3 [ Ted Gould ]10 [ Ted Gould ]
411
=== modified file 'debian/control'
--- debian/control 2013-09-30 19:01:52 +0000
+++ debian/control 2013-10-03 13:04:10 +0000
@@ -34,6 +34,7 @@
34 ${shlibs:Depends},34 ${shlibs:Depends},
35# For apport hook35# For apport hook
36 python3-xdg,36 python3-xdg,
37 unity8 (>= 7.82),
37Conflicts: chewie,38Conflicts: chewie,
38 indicators-client-plugin-network,39 indicators-client-plugin-network,
39Description: Systems settings menu service - Network indicator40Description: Systems settings menu service - Network indicator
4041
=== modified file 'secret-agent/CMakeLists.txt'
--- secret-agent/CMakeLists.txt 2013-08-27 14:54:25 +0000
+++ secret-agent/CMakeLists.txt 2013-10-03 13:04:10 +0000
@@ -4,6 +4,7 @@
4 SecretAgent.cpp4 SecretAgent.cpp
5 SecretAgentAdaptor.cpp5 SecretAgentAdaptor.cpp
6 SecretRequest.cpp6 SecretRequest.cpp
7 gtk/PasswordMenu.cpp
7)8)
89
9qt5_add_dbus_adaptor(10qt5_add_dbus_adaptor(
@@ -20,6 +21,18 @@
20 AgentManagerInterface21 AgentManagerInterface
21)22)
2223
24set_source_files_properties(
25 "${DATA_DIR}/org.freedesktop.Notifications.xml"
26 PROPERTIES
27 INCLUDE "DBusTypes.h"
28)
29
30qt5_add_dbus_interface(
31 INDICATOR_SECRET_AGENT_SOURCES
32 "${DATA_DIR}/org.freedesktop.Notifications.xml"
33 NotificationsInterface
34)
35
23add_library(36add_library(
24 indicator-secret-agent37 indicator-secret-agent
25 STATIC38 STATIC
@@ -32,6 +45,11 @@
32 DBus45 DBus
33)46)
3447
48target_link_libraries(
49 indicator-secret-agent
50 ${GIO_LIBRARIES}
51)
52
35add_executable(53add_executable(
36 indicator-secret-agent-bin54 indicator-secret-agent-bin
37 main.cpp55 main.cpp
3856
=== modified file 'secret-agent/DBusTypes.h'
--- secret-agent/DBusTypes.h 2013-08-27 14:54:25 +0000
+++ secret-agent/DBusTypes.h 2013-10-03 13:04:10 +0000
@@ -19,7 +19,7 @@
19#ifndef DBUSTYPES_H_19#ifndef DBUSTYPES_H_
20#define DBUSTYPES_H_20#define DBUSTYPES_H_
2121
22#include <QtDBus>22#include <QDBusMetaType>
23#include <QMap>23#include <QMap>
2424
25typedef QMap<QString, QVariantMap> QVariantDictMap;25typedef QMap<QString, QVariantMap> QVariantDictMap;
@@ -29,7 +29,6 @@
29public:29public:
30 static void registerMetaTypes() {30 static void registerMetaTypes() {
31 qRegisterMetaType<QVariantDictMap>("QVariantDictMap");31 qRegisterMetaType<QVariantDictMap>("QVariantDictMap");
32
33 qDBusRegisterMetaType<QVariantDictMap>();32 qDBusRegisterMetaType<QVariantDictMap>();
34 }33 }
35};34};
3635
=== modified file 'secret-agent/SecretAgent.cpp'
--- secret-agent/SecretAgent.cpp 2013-08-27 14:54:25 +0000
+++ secret-agent/SecretAgent.cpp 2013-10-03 13:04:10 +0000
@@ -27,9 +27,12 @@
27using namespace std;27using namespace std;
28using namespace org::freedesktop::NetworkManager;28using namespace org::freedesktop::NetworkManager;
2929
30const QString SecretAgent::CONNECTION_SETTING_NAME("connection");
30const QString SecretAgent::WIRELESS_SECURITY_SETTING_NAME(31const QString SecretAgent::WIRELESS_SECURITY_SETTING_NAME(
31 "802-11-wireless-security");32 "802-11-wireless-security");
3233
34const QString SecretAgent::CONNECTION_ID("id");
35
33const QString SecretAgent::WIRELESS_SECURITY_PSK("psk");36const QString SecretAgent::WIRELESS_SECURITY_PSK("psk");
34const QString SecretAgent::WIRELESS_SECURITY_WEP_KEY0("wep-key0");37const QString SecretAgent::WIRELESS_SECURITY_WEP_KEY0("wep-key0");
3538
@@ -39,11 +42,15 @@
39const QString SecretAgent::KEY_MGMT_WPA_PSK("wpa-psk");42const QString SecretAgent::KEY_MGMT_WPA_PSK("wpa-psk");
40const QString SecretAgent::KEY_MGMT_NONE("none");43const QString SecretAgent::KEY_MGMT_NONE("none");
4144
42SecretAgent::SecretAgent(const QDBusConnection &connection, QObject *parent) :45SecretAgent::SecretAgent(const QDBusConnection &systemConnection,
43 QObject(parent), m_adaptor(new SecretAgentAdaptor(this)), m_connection(46 const QDBusConnection &sessionConnection, QObject *parent) :
44 connection), m_agentManager(NM_DBUS_SERVICE,47 QObject(parent), m_adaptor(new SecretAgentAdaptor(this)), m_systemConnection(
45 NM_DBUS_PATH_AGENT_MANAGER, m_connection), m_requestCounter(0) {48 systemConnection), m_sessionConnection(sessionConnection), m_agentManager(
46 if (!m_connection.registerObject(NM_DBUS_PATH_SECRET_AGENT, this)) {49 NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), m_notifications(
50 "org.freedesktop.Notifications",
51 "/org/freedesktop/Notifications", m_sessionConnection), m_requestCounter(
52 0) {
53 if (!m_systemConnection.registerObject(NM_DBUS_PATH_SECRET_AGENT, this)) {
47 throw logic_error(54 throw logic_error(
48 _("Unable to register user secret agent object on DBus"));55 _("Unable to register user secret agent object on DBus"));
49 }56 }
@@ -53,7 +60,7 @@
5360
54SecretAgent::~SecretAgent() {61SecretAgent::~SecretAgent() {
55 m_agentManager.Unregister().waitForFinished();62 m_agentManager.Unregister().waitForFinished();
56 m_connection.unregisterObject(NM_DBUS_PATH_SECRET_AGENT);63 m_systemConnection.unregisterObject(NM_DBUS_PATH_SECRET_AGENT);
57}64}
5865
59/**66/**
@@ -101,7 +108,7 @@
101 setDelayedReply(true);108 setDelayedReply(true);
102109
103 if (flags == 0) {110 if (flags == 0) {
104 m_connection.send(111 m_systemConnection.send(
105 message().createErrorReply(QDBusError::InternalError,112 message().createErrorReply(QDBusError::InternalError,
106 "No password found for this connection."));113 "No password found for this connection."));
107 } else {114 } else {
@@ -117,7 +124,7 @@
117}124}
118125
119void SecretAgent::FinishGetSecrets(SecretRequest &request) {126void SecretAgent::FinishGetSecrets(SecretRequest &request) {
120 m_connection.send(127 m_systemConnection.send(
121 request.message().createReply(128 request.message().createReply(
122 QVariant::fromValue(request.connection())));129 QVariant::fromValue(request.connection())));
123 m_requests.remove(request.requestId());130 m_requests.remove(request.requestId());
@@ -134,3 +141,7 @@
134void SecretAgent::SaveSecrets(const QVariantDictMap &connection,141void SecretAgent::SaveSecrets(const QVariantDictMap &connection,
135 const QDBusObjectPath &connectionPath) {142 const QDBusObjectPath &connectionPath) {
136}143}
144
145org::freedesktop::Notifications & SecretAgent::notifications() {
146 return m_notifications;
147}
137148
=== modified file 'secret-agent/SecretAgent.h'
--- secret-agent/SecretAgent.h 2013-08-27 14:54:25 +0000
+++ secret-agent/SecretAgent.h 2013-10-03 13:04:10 +0000
@@ -21,12 +21,13 @@
2121
22#include <QScopedPointer>22#include <QScopedPointer>
23#include <QDBusConnection>23#include <QDBusConnection>
24#include <QtDBus>24#include <QDBusContext>
25#include <QMap>25#include <QMap>
2626
27#include <DBusTypes.h>27#include <DBusTypes.h>
28#include <SecretRequest.h>28#include <SecretRequest.h>
29#include <AgentManagerInterface.h>29#include <AgentManagerInterface.h>
30#include <NotificationsInterface.h>
3031
31class SecretAgentAdaptor;32class SecretAgentAdaptor;
3233
@@ -34,8 +35,11 @@
34Q_OBJECT35Q_OBJECT
3536
36public:37public:
38 static const QString CONNECTION_SETTING_NAME;
37 static const QString WIRELESS_SECURITY_SETTING_NAME;39 static const QString WIRELESS_SECURITY_SETTING_NAME;
3840
41 static const QString CONNECTION_ID;
42
39 static const QString WIRELESS_SECURITY_PSK;43 static const QString WIRELESS_SECURITY_PSK;
40 static const QString WIRELESS_SECURITY_WEP_KEY0;44 static const QString WIRELESS_SECURITY_WEP_KEY0;
4145
@@ -45,8 +49,8 @@
45 static const QString KEY_MGMT_WPA_PSK;49 static const QString KEY_MGMT_WPA_PSK;
46 static const QString KEY_MGMT_NONE;50 static const QString KEY_MGMT_NONE;
4751
48 explicit SecretAgent(const QDBusConnection &connection,52 explicit SecretAgent(const QDBusConnection &systemConnection,
49 QObject *parent = 0);53 const QDBusConnection &sessionConnection, QObject *parent = 0);
5054
51 virtual ~SecretAgent();55 virtual ~SecretAgent();
5256
@@ -66,16 +70,23 @@
66 void SaveSecrets(const QVariantDictMap &connection,70 void SaveSecrets(const QVariantDictMap &connection,
67 const QDBusObjectPath &connectionPath);71 const QDBusObjectPath &connectionPath);
6872
73 org::freedesktop::Notifications & notifications();
74
69protected:75protected:
70 QScopedPointer<SecretAgentAdaptor> m_adaptor;76 QScopedPointer<SecretAgentAdaptor> m_adaptor;
7177
72 QDBusConnection m_connection;78 QDBusConnection m_systemConnection;
79
80 QDBusConnection m_sessionConnection;
7381
74 org::freedesktop::NetworkManager::AgentManager m_agentManager;82 org::freedesktop::NetworkManager::AgentManager m_agentManager;
7583
84 org::freedesktop::Notifications m_notifications;
85
76 QMap<unsigned long long, SecretRequestPtr> m_requests;86 QMap<unsigned long long, SecretRequestPtr> m_requests;
7787
78 unsigned long long m_requestCounter;88 unsigned long long m_requestCounter;
89
79};90};
8091
81#endif /* SECRETAGENT_H_ */92#endif /* SECRETAGENT_H_ */
8293
=== modified file 'secret-agent/SecretRequest.cpp'
--- secret-agent/SecretRequest.cpp 2013-08-27 14:54:25 +0000
+++ secret-agent/SecretRequest.cpp 2013-10-03 13:04:10 +0000
@@ -16,8 +16,9 @@
16 * Author: Pete Woods <pete.woods@canonical.com>16 * Author: Pete Woods <pete.woods@canonical.com>
17 */17 */
1818
19#include "SecretRequest.h"19#include <SecretRequest.h>
20#include "SecretAgent.h"20#include <SecretAgent.h>
21#include <Localisation.h>
2122
22SecretRequest::SecretRequest(unsigned int requestId, SecretAgent &secretAgent,23SecretRequest::SecretRequest(unsigned int requestId, SecretAgent &secretAgent,
23 const QVariantDictMap &connection,24 const QVariantDictMap &connection,
@@ -26,17 +27,65 @@
26 QObject *parent) :27 QObject *parent) :
27 QObject(parent), m_requestId(requestId), m_secretAgent(secretAgent), m_connection(28 QObject(parent), m_requestId(requestId), m_secretAgent(secretAgent), m_connection(
28 connection), m_connectionPath(connectionPath), m_settingName(29 connection), m_connectionPath(connectionPath), m_settingName(
29 settingName), m_hints(hints), m_flags(flags), m_message(message) {30 settingName), m_hints(hints), m_flags(flags), m_message(
3031 message), m_menu(requestId) {
31 QTimer::singleShot(0, this, SLOT(FinishRequest()));32
33 connect(&m_secretAgent.notifications(),
34 SIGNAL(ActionInvoked(uint, const QString &)), this,
35 SLOT(actionInvoked(uint, const QString &)));
36
37 // indicate to the notification-daemon, that we want to use snap-decisions
38 QVariantMap notificationHints;
39 notificationHints["x-canonical-snap-decisions"] = "true";
40 notificationHints["x-canonical-private-button-tint"] = "true";
41
42 QVariantMap menuModelActions;
43 menuModelActions["notifications"] = m_menu.actionPath();
44
45 QVariantMap menuModelPaths;
46 menuModelPaths["busName"] = m_menu.busName();
47 menuModelPaths["menuPath"] = m_menu.menuPath();
48 menuModelPaths["actions"] = menuModelActions;
49
50 notificationHints["x-canonical-private-menu-model"] = menuModelPaths;
51
52 const QVariantMap &conn = m_connection[SecretAgent::CONNECTION_SETTING_NAME];
53
54 auto wirelessSecurity = m_connection.find(m_settingName);
55 QString keyMgmt(
56 wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString());
57
58 QString title(_("Connect to \"%1\""));
59
60 QString subject;
61 if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE
62 || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) {
63 subject = _("WPA");
64 } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) {
65 subject = _("WEP");
66 }
67
68 m_notificationId = m_secretAgent.notifications().Notify("indicator-network",
69 0, "wifi-full-secure",
70 title.arg(conn[SecretAgent::CONNECTION_ID].toString()), subject,
71 QStringList() << "connect_id" << _("Connect") << "cancel_id"
72 << _("Cancel"), notificationHints, 0);
32}73}
3374
34SecretRequest::~SecretRequest() {75SecretRequest::~SecretRequest() {
35}76}
3677
37void SecretRequest::FinishRequest() {78void SecretRequest::actionInvoked(uint id, const QString &actionKey) {
38 //FIXME: Hard-coded - use system dialogue call to populate it79 // Ignore other requests' notifications
39 QString key("hard-coded-password");80 if (id != m_notificationId) {
81 return;
82 }
83
84 QString key("");
85
86 if (actionKey == "connect_id") {
87 key = m_menu.password();
88 }
4089
41 auto wirelessSecurity = m_connection.find(m_settingName);90 auto wirelessSecurity = m_connection.find(m_settingName);
42 QString keyMgmt(91 QString keyMgmt(
4392
=== modified file 'secret-agent/SecretRequest.h'
--- secret-agent/SecretRequest.h 2013-08-27 14:54:25 +0000
+++ secret-agent/SecretRequest.h 2013-10-03 13:04:10 +0000
@@ -20,8 +20,10 @@
20#define SECRETREQUEST_H_20#define SECRETREQUEST_H_
2121
22#include <DBusTypes.h>22#include <DBusTypes.h>
23#include <gtk/PasswordMenu.h>
2324
24#include <QtDBus>25#include <QDBusMessage>
26#include <QDBusObjectPath>
25#include <QSharedPointer>27#include <QSharedPointer>
2628
27class SecretRequest;29class SecretRequest;
@@ -41,7 +43,7 @@
41 virtual ~SecretRequest();43 virtual ~SecretRequest();
4244
43public Q_SLOTS:45public Q_SLOTS:
44 void FinishRequest();46 void actionInvoked(uint id, const QString &actionKey);
4547
46public:48public:
47 unsigned int requestId() const;49 unsigned int requestId() const;
@@ -53,6 +55,8 @@
53protected:55protected:
54 const unsigned int m_requestId;56 const unsigned int m_requestId;
5557
58 unsigned int m_notificationId;
59
56 SecretAgent &m_secretAgent;60 SecretAgent &m_secretAgent;
5761
58 QVariantDictMap m_connection;62 QVariantDictMap m_connection;
@@ -66,6 +70,8 @@
66 uint m_flags;70 uint m_flags;
6771
68 QDBusMessage m_message;72 QDBusMessage m_message;
73
74 PasswordMenu m_menu;
69};75};
7076
71#endif /* SECRETREQUEST_H_ */77#endif /* SECRETREQUEST_H_ */
7278
=== added directory 'secret-agent/gtk'
=== added file 'secret-agent/gtk/PasswordMenu.cpp'
--- secret-agent/gtk/PasswordMenu.cpp 1970-01-01 00:00:00 +0000
+++ secret-agent/gtk/PasswordMenu.cpp 2013-10-03 13:04:10 +0000
@@ -0,0 +1,134 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19#include <gtk/PasswordMenu.h>
20#include <gio/gio.h>
21
22#include <QString>
23#include <QDebug>
24
25static const QString PASSWORD_ACTION_PATH("/action/%1");
26static const QString PASSWORD_MENU_PATH("/menu/%1");
27
28class PasswordMenuPriv {
29public:
30 PasswordMenuPriv() :
31 m_connection(g_bus_get_sync(G_BUS_TYPE_SESSION, NULL,
32 NULL)), m_exportedActionGroupId(0), m_exportedMenuModelId(0) {
33 }
34
35 ~PasswordMenuPriv() {
36 g_object_unref(m_connection);
37 }
38
39 static void passwordChangedCallback(GAction *passwordAction,
40 GVariant *variant, gpointer userData) {
41 PasswordMenuPriv *self(reinterpret_cast<PasswordMenuPriv*>(userData));
42 self->passwordChanged(variant);
43 }
44
45 void passwordChanged(GVariant *variant) {
46 m_password = QString::fromUtf8(g_variant_get_string(variant, 0));
47 if (qEnvironmentVariableIsSet("SECRET_AGENT_DEBUG_PASSWORD")) {
48 qDebug() << "Password received";
49 }
50 }
51
52 GDBusConnection *m_connection;
53
54 QString m_busName;
55
56 QString m_actionPath;
57
58 QString m_menuPath;
59
60 unsigned int m_exportedActionGroupId;
61
62 unsigned int m_exportedMenuModelId;
63
64 QString m_password;
65
66};
67
68PasswordMenu::PasswordMenu(unsigned int requestId) :
69 p(new PasswordMenuPriv()) {
70 p->m_busName = QString::fromUtf8(
71 g_dbus_connection_get_unique_name(p->m_connection));
72
73 p->m_actionPath = PASSWORD_ACTION_PATH.arg(requestId);
74 p->m_menuPath = PASSWORD_MENU_PATH.arg(requestId);
75
76 // menu
77 GMenu *menu(g_menu_new());
78
79 GMenuItem *passwordItem(g_menu_item_new("", "notifications.password"));
80 g_menu_item_set_attribute_value(passwordItem, "x-canonical-type",
81 g_variant_new_string("com.canonical.snapdecision.textfield"));
82 g_menu_item_set_attribute_value(passwordItem, "x-echo-mode-password",
83 g_variant_new_boolean(true));
84
85 g_menu_append_item(menu, passwordItem);
86
87 // actions
88 GActionGroup *actions(G_ACTION_GROUP(g_simple_action_group_new()));
89 GAction *passwordAction(G_ACTION(
90 g_simple_action_new_stateful("password", G_VARIANT_TYPE_STRING,
91 g_variant_new_string(""))));
92
93 g_signal_connect(G_OBJECT(passwordAction), "change-state",
94 G_CALLBACK(PasswordMenuPriv::passwordChangedCallback),
95 reinterpret_cast<gpointer>(p.data()));
96
97 g_action_map_add_action(G_ACTION_MAP(actions), passwordAction);
98
99 p->m_exportedActionGroupId = g_dbus_connection_export_action_group(
100 p->m_connection, p->m_actionPath.toUtf8().data(), actions, NULL);
101
102 p->m_exportedMenuModelId = g_dbus_connection_export_menu_model(
103 p->m_connection, p->m_menuPath.toUtf8().data(),
104 G_MENU_MODEL(menu), NULL);
105
106 g_object_unref(menu);
107 g_object_unref(passwordItem);
108
109 g_object_unref(actions);
110 g_object_unref(passwordAction);
111}
112
113PasswordMenu::~PasswordMenu() {
114 g_dbus_connection_unexport_action_group(p->m_connection,
115 p->m_exportedActionGroupId);
116 g_dbus_connection_unexport_menu_model(p->m_connection,
117 p->m_exportedMenuModelId);
118}
119
120const QString & PasswordMenu::busName() const {
121 return p->m_busName;
122}
123
124const QString & PasswordMenu::password() const {
125 return p->m_password;
126}
127
128const QString & PasswordMenu::actionPath() const {
129 return p->m_actionPath;
130}
131
132const QString & PasswordMenu::menuPath() const {
133 return p->m_menuPath;
134}
0135
=== added file 'secret-agent/gtk/PasswordMenu.h'
--- secret-agent/gtk/PasswordMenu.h 1970-01-01 00:00:00 +0000
+++ secret-agent/gtk/PasswordMenu.h 2013-10-03 13:04:10 +0000
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Pete Woods <pete.woods@canonical.com>
17 */
18
19#ifndef PASSWORDMENU_H_
20#define PASSWORDMENU_H_
21
22#include <QString>
23#include <QScopedPointer>
24
25class PasswordMenuPriv;
26
27class PasswordMenu {
28public:
29 PasswordMenu(unsigned int requestId);
30
31 virtual ~PasswordMenu();
32
33 const QString & busName() const;
34
35 const QString & password() const;
36
37 const QString & actionPath() const;
38
39 const QString & menuPath() const;
40
41protected:
42 QScopedPointer<PasswordMenuPriv> p;
43};
44
45#endif /* PASSWORDMENU_H_ */
046
=== modified file 'secret-agent/main.cpp'
--- secret-agent/main.cpp 2013-08-27 14:54:25 +0000
+++ secret-agent/main.cpp 2013-10-03 13:04:10 +0000
@@ -43,7 +43,8 @@
43 signal(SIGINT, &exitQt);43 signal(SIGINT, &exitQt);
44 signal(SIGTERM, &exitQt);44 signal(SIGTERM, &exitQt);
4545
46 SecretAgent secretAgent(QDBusConnection::systemBus());46 SecretAgent secretAgent(QDBusConnection::systemBus(),
47 QDBusConnection::sessionBus());
4748
48 if (argc == 2 && QString("--print-address") == argv[1]) {49 if (argc == 2 && QString("--print-address") == argv[1]) {
49 cout << QDBusConnection::systemBus().baseService().toStdString()50 cout << QDBusConnection::systemBus().baseService().toStdString()
5051
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2013-08-27 15:18:46 +0000
+++ tests/CMakeLists.txt 2013-10-03 13:04:10 +0000
@@ -51,6 +51,7 @@
51 indicator-secret-agent51 indicator-secret-agent
52 ${QTDBUSMOCK_LIBRARIES}52 ${QTDBUSMOCK_LIBRARIES}
53 ${QTDBUSTEST_LIBRARIES}53 ${QTDBUSTEST_LIBRARIES}
54 ${QMENUMODEL_LIBRARIES}
54 ${GTEST_LIBRARIES}55 ${GTEST_LIBRARIES}
55 ${GMOCK_LIBRARIES}56 ${GMOCK_LIBRARIES}
56)57)
5758
=== modified file 'tests/TestSecretAgent.cpp'
--- tests/TestSecretAgent.cpp 2013-08-27 14:54:25 +0000
+++ tests/TestSecretAgent.cpp 2013-10-03 13:04:10 +0000
@@ -16,12 +16,14 @@
16 * Author: Pete Woods <pete.woods@canonical.com>16 * Author: Pete Woods <pete.woods@canonical.com>
17 */17 */
1818
19#include <libqtdbustest/DBusTestRunner.h>
20#include <libqtdbusmock/DBusMock.h>
21#include <SecretAgent.h>19#include <SecretAgent.h>
22#include <SecretAgentInterface.h>20#include <SecretAgentInterface.h>
23#include <NetworkManager.h>21#include <NetworkManager.h>
2422
23#include <libqtdbustest/DBusTestRunner.h>
24#include <libqtdbusmock/DBusMock.h>
25#include <qmenumodel/unitymenumodel.h>
26#include <QSignalSpy>
25#include <gmock/gmock.h>27#include <gmock/gmock.h>
26#include <gtest/gtest.h>28#include <gtest/gtest.h>
2729
@@ -37,18 +39,32 @@
37 TestSecretAgentCommon() :39 TestSecretAgentCommon() :
38 dbusMock(dbusTestRunner) {40 dbusMock(dbusTestRunner) {
3941
42 dbusMock.registerCustomMock("org.freedesktop.Notifications",
43 "/org/freedesktop/Notifications",
44 OrgFreedesktopNotificationsInterface::staticInterfaceName(),
45 QDBusConnection::SessionBus);
46
40 dbusMock.registerNetworkManager();47 dbusMock.registerNetworkManager();
41 dbusTestRunner.startServices();48 dbusTestRunner.startServices();
4249
50 QProcessEnvironment env(QProcessEnvironment::systemEnvironment());
51 env.insert("SECRET_AGENT_DEBUG_PASSWORD", "1");
52 secretAgent.setProcessEnvironment(env);
53 secretAgent.setProcessChannelMode(QProcess::MergedChannels);
43 secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address");54 secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address");
44 secretAgent.waitForStarted();55 secretAgent.waitForStarted();
45 secretAgent.waitForReadyRead();56 secretAgent.waitForReadyRead();
46 agentBus = secretAgent.readAll().trimmed();57 agentBus = secretAgent.readAll().trimmed();
4758
48 interface.reset(59 agentInterface.reset(
49 new OrgFreedesktopNetworkManagerSecretAgentInterface(agentBus,60 new OrgFreedesktopNetworkManagerSecretAgentInterface(agentBus,
50 NM_DBUS_PATH_SECRET_AGENT,61 NM_DBUS_PATH_SECRET_AGENT, dbusTestRunner.systemConnection()));
51 dbusTestRunner.systemConnection()));62
63 notificationsInterface.reset(
64 new OrgFreedesktopDBusMockInterface(
65 "org.freedesktop.Notifications",
66 "/org/freedesktop/Notifications",
67 dbusTestRunner.sessionConnection()));
52 }68 }
5369
54 virtual ~TestSecretAgentCommon() {70 virtual ~TestSecretAgentCommon() {
@@ -61,9 +77,13 @@
61 wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] =77 wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] =
62 keyManagement;78 keyManagement;
6379
80 QVariantMap conn;
81 conn[SecretAgent::CONNECTION_ID] = "the ssid";
82
64 QVariantDictMap connection;83 QVariantDictMap connection;
65 connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =84 connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =
66 wirelessSecurity;85 wirelessSecurity;
86 connection[SecretAgent::CONNECTION_SETTING_NAME] = conn;
6787
68 return connection;88 return connection;
69 }89 }
@@ -76,9 +96,13 @@
76 keyManagement;96 keyManagement;
77 wirelessSecurity[keyName] = password;97 wirelessSecurity[keyName] = password;
7898
99 QVariantMap conn;
100 conn[SecretAgent::CONNECTION_ID] = "the ssid";
101
79 QVariantDictMap connection;102 QVariantDictMap connection;
80 connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =103 connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] =
81 wirelessSecurity;104 wirelessSecurity;
105 connection[SecretAgent::CONNECTION_SETTING_NAME] = conn;
82106
83 return connection;107 return connection;
84 }108 }
@@ -91,7 +115,9 @@
91115
92 QString agentBus;116 QString agentBus;
93117
94 QScopedPointer<OrgFreedesktopNetworkManagerSecretAgentInterface> interface;118 QScopedPointer<OrgFreedesktopNetworkManagerSecretAgentInterface> agentInterface;
119
120 QScopedPointer<OrgFreedesktopDBusMockInterface> notificationsInterface;
95};121};
96122
97struct TestSecretAgentParams {123struct TestSecretAgentParams {
@@ -106,16 +132,95 @@
106 public TestWithParam<TestSecretAgentParams> {132 public TestWithParam<TestSecretAgentParams> {
107};133};
108134
135static void transform(QVariantMap &map);
136
137static void transform(QVariant &variant) {
138 if (variant.canConvert<QDBusArgument>()) {
139 QDBusArgument value(variant.value<QDBusArgument>());
140 if (value.currentType() == QDBusArgument::MapType) {
141 QVariantMap map;
142 value >> map;
143 transform(map);
144 variant = map;
145 }
146 }
147}
148
149static void transform(QVariantMap &map) {
150 for (auto it(map.begin()); it != map.end(); ++it) {
151 transform(*it);
152 }
153}
154
155static void transform(QVariantList &list) {
156 for (auto it(list.begin()); it != list.end(); ++it) {
157 transform(*it);
158 }
159}
160
109TEST_P(TestSecretAgentGetSecrets, ProvidesPasswordForWpaPsk) {161TEST_P(TestSecretAgentGetSecrets, ProvidesPasswordForWpaPsk) {
110 QVariantDictMap reply(162 notificationsInterface->AddMethod(
111 interface->GetSecrets(connection(GetParam().keyManagement),163 OrgFreedesktopNotificationsInterface::staticInterfaceName(),
164 "Notify", "susssasa{sv}i", "u", "ret = 1").waitForFinished();
165
166 QDBusPendingReply<QVariantDictMap> reply(
167 agentInterface->GetSecrets(connection(GetParam().keyManagement),
112 QDBusObjectPath("/connection/foo"),168 QDBusObjectPath("/connection/foo"),
113 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),169 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
114 5));170 5));
115171
172 QSignalSpy notificationSpy(notificationsInterface.data(),
173 SIGNAL(MethodCalled(const QString &, const QVariantList &)));
174 notificationSpy.wait();
175
176 ASSERT_EQ(1, notificationSpy.size());
177 const QVariantList &call(notificationSpy.at(0));
178 ASSERT_EQ("Notify", call.at(0));
179
180 QVariantList args(call.at(1).toList());
181 transform(args);
182
183 ASSERT_EQ(8, args.size());
184 EXPECT_EQ("indicator-network", args.at(0));
185 EXPECT_EQ("Connect to \"the ssid\"", args.at(3).toString().toStdString());
186
187 QVariantMap hints(args.at(6).toMap());
188 QVariantMap menuInfo(hints["x-canonical-private-menu-model"].toMap());
189
190 QString busName(menuInfo["busName"].toString());
191 QString menuPath(menuInfo["menuPath"].toString());
192 QVariantMap actions(menuInfo["actions"].toMap());
193
194 {
195 UnityMenuModel menuModel;
196
197 QSignalSpy menuSpy(&menuModel,
198 SIGNAL(rowsInserted(const QModelIndex&, int, int)));
199
200 menuModel.setBusName(busName.toUtf8());
201 menuModel.setMenuObjectPath(menuPath.toUtf8());
202 menuModel.setActions(actions);
203
204 menuSpy.wait();
205
206 menuModel.changeState(0, "hard-coded-password");
207
208 // It seems like UnityMenuModel or the GLib
209 // DBus connection needs some grace time to
210 // finish dispatching.
211 secretAgent.waitForReadyRead();
212 ASSERT_EQ("Password received", secretAgent.readAll().trimmed());
213 }
214
215 notificationsInterface->EmitSignal(
216 OrgFreedesktopNotificationsInterface::staticInterfaceName(),
217 "ActionInvoked", "us", QVariantList() << 1 << "connect_id");
218
219 QVariantDictMap result(reply);
220
116 EXPECT_EQ(221 EXPECT_EQ(
117 expected(GetParam().keyManagement, GetParam().passwordKey,222 expected(GetParam().keyManagement, GetParam().passwordKey,
118 GetParam().password), reply);223 GetParam().password), result);
119}224}
120225
121INSTANTIATE_TEST_CASE_P(WpaPsk, TestSecretAgentGetSecrets,226INSTANTIATE_TEST_CASE_P(WpaPsk, TestSecretAgentGetSecrets,
@@ -137,7 +242,8 @@
137242
138TEST_F(TestSecretAgent, GetSecretsWithNone) {243TEST_F(TestSecretAgent, GetSecretsWithNone) {
139 QDBusPendingReply<QVariantDictMap> reply(244 QDBusPendingReply<QVariantDictMap> reply(
140 interface->GetSecrets(connection(SecretAgent::KEY_MGMT_WPA_PSK),245 agentInterface->GetSecrets(
246 connection(SecretAgent::KEY_MGMT_WPA_PSK),
141 QDBusObjectPath("/connection/foo"),247 QDBusObjectPath("/connection/foo"),
142 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),248 SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(),
143 0));249 0));
@@ -150,17 +256,17 @@
150}256}
151257
152TEST_F(TestSecretAgent, CancelGetSecrets) {258TEST_F(TestSecretAgent, CancelGetSecrets) {
153 interface->CancelGetSecrets(QDBusObjectPath("/connection/foo"),259 agentInterface->CancelGetSecrets(QDBusObjectPath("/connection/foo"),
154 SecretAgent::WIRELESS_SECURITY_SETTING_NAME).waitForFinished();260 SecretAgent::WIRELESS_SECURITY_SETTING_NAME).waitForFinished();
155}261}
156262
157TEST_F(TestSecretAgent, SaveSecrets) {263TEST_F(TestSecretAgent, SaveSecrets) {
158 interface->SaveSecrets(QVariantDictMap(),264 agentInterface->SaveSecrets(QVariantDictMap(),
159 QDBusObjectPath("/connection/foo")).waitForFinished();265 QDBusObjectPath("/connection/foo")).waitForFinished();
160}266}
161267
162TEST_F(TestSecretAgent, DeleteSecrets) {268TEST_F(TestSecretAgent, DeleteSecrets) {
163 interface->DeleteSecrets(QVariantDictMap(),269 agentInterface->DeleteSecrets(QVariantDictMap(),
164 QDBusObjectPath("/connection/foo")).waitForFinished();270 QDBusObjectPath("/connection/foo")).waitForFinished();
165}271}
166272
167273
=== modified file 'tests/data/valgrind.suppression'
--- tests/data/valgrind.suppression 2013-08-27 14:54:25 +0000
+++ tests/data/valgrind.suppression 2013-10-03 13:04:10 +0000
@@ -27,6 +27,20 @@
27}27}
2828
29###############################29###############################
30# DBus
31###############################
32
33{
34 <insert_a_suppression_name_here>
35 Memcheck:Param
36 epoll_ctl(event)
37 fun:epoll_ctl
38 obj:/bin/dbus-daemon
39 ...
40 fun:(below main)
41}
42
43###############################
30# GObject rules44# GObject rules
31###############################45###############################
3246

Subscribers

People subscribed via source and target branches

to all changes: