lomiri.lomiri-indicator-network: 1.1.0 -> 1.1.1 (#412649)

authored by Cosima Neidahl and committed by GitHub 7b803c35 657a9316

+5 -252
-240
pkgs/desktops/lomiri/services/lomiri-indicator-network/1001-test-secret-agent-Make-GetServerInformation-not-leak-into-tests.patch
··· 1 - From 9c2a6a6349f705017e3c8a34daa4ba1805586498 Mon Sep 17 00:00:00 2001 2 - From: OPNA2608 <opna2608@protonmail.com> 3 - Date: Thu, 30 Jan 2025 14:53:02 +0100 4 - Subject: [PATCH] tests/unit/secret-agent/test-secret-agent: Make sure signal 5 - emitted on agent startup doesn't leak into tests 6 - 7 - --- 8 - tests/unit/secret-agent/test-secret-agent.cpp | 116 ++++++++++-------- 9 - 1 file changed, 67 insertions(+), 49 deletions(-) 10 - 11 - diff --git a/tests/unit/secret-agent/test-secret-agent.cpp b/tests/unit/secret-agent/test-secret-agent.cpp 12 - index 1f1cd7e9..9c72e251 100644 13 - --- a/tests/unit/secret-agent/test-secret-agent.cpp 14 - +++ b/tests/unit/secret-agent/test-secret-agent.cpp 15 - @@ -29,6 +29,16 @@ 16 - #include <lomiri/gmenuharness/MatchUtils.h> 17 - #include <lomiri/gmenuharness/MenuMatcher.h> 18 - 19 - +#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ 20 - +{\ 21 - + while (signalSpy.size() < signalsExpected)\ 22 - + {\ 23 - + ASSERT_TRUE(signalSpy.wait()) << "Waiting for " << signalsExpected << " signals, got " << signalSpy.size();\ 24 - + }\ 25 - + ASSERT_EQ(signalsExpected, signalSpy.size()) << "Waiting for " << signalsExpected << " signals, got " << signalSpy.size();\ 26 - +} 27 - + 28 - + 29 - using namespace std; 30 - using namespace testing; 31 - using namespace QtDBusTest; 32 - @@ -49,21 +59,6 @@ protected: 33 - dbusMock.registerTemplate(NM_DBUS_SERVICE, NETWORK_MANAGER_TEMPLATE_PATH, {}, QDBusConnection::SystemBus); 34 - dbusTestRunner.startServices(); 35 - 36 - - QProcessEnvironment env(QProcessEnvironment::systemEnvironment()); 37 - - env.insert("SECRET_AGENT_DEBUG_PASSWORD", "1"); 38 - - secretAgent.setProcessEnvironment(env); 39 - - secretAgent.setReadChannel(QProcess::StandardOutput); 40 - - secretAgent.setProcessChannelMode(QProcess::ForwardedErrorChannel); 41 - - secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address"); 42 - - secretAgent.waitForStarted(); 43 - - secretAgent.waitForReadyRead(); 44 - - agentBus = secretAgent.readAll().trimmed(); 45 - - 46 - - agentInterface.reset( 47 - - new OrgFreedesktopNetworkManagerSecretAgentInterface(agentBus, 48 - - NM_DBUS_PATH_SECRET_AGENT, dbusTestRunner.systemConnection())); 49 - - 50 - - 51 - notificationsInterface.reset( 52 - new OrgFreedesktopDBusMockInterface( 53 - "org.freedesktop.Notifications", 54 - @@ -72,8 +67,11 @@ protected: 55 - } 56 - 57 - virtual ~TestSecretAgentCommon() { 58 - - secretAgent.terminate(); 59 - - secretAgent.waitForFinished(); 60 - + if (secretAgent.state() != QProcess::NotRunning) 61 - + { 62 - + secretAgent.terminate(); 63 - + secretAgent.waitForFinished(); 64 - + } 65 - } 66 - 67 - QVariantDictMap connection(const QString &keyManagement) { 68 - @@ -111,6 +109,32 @@ protected: 69 - return connection; 70 - } 71 - 72 - + void setupSecretAgent (void) { 73 - + QSignalSpy notificationSpy(notificationsInterface.data(), 74 - + SIGNAL(MethodCalled(const QString &, const QVariantList &))); 75 - + 76 - + QProcessEnvironment env(QProcessEnvironment::systemEnvironment()); 77 - + env.insert("SECRET_AGENT_DEBUG_PASSWORD", "1"); 78 - + secretAgent.setProcessEnvironment(env); 79 - + secretAgent.setReadChannel(QProcess::StandardOutput); 80 - + secretAgent.setProcessChannelMode(QProcess::ForwardedErrorChannel); 81 - + secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address"); 82 - + secretAgent.waitForStarted(); 83 - + secretAgent.waitForReadyRead(); 84 - + 85 - + agentBus = secretAgent.readAll().trimmed(); 86 - + 87 - + agentInterface.reset( 88 - + new OrgFreedesktopNetworkManagerSecretAgentInterface(agentBus, 89 - + NM_DBUS_PATH_SECRET_AGENT, dbusTestRunner.systemConnection())); 90 - + 91 - + WAIT_FOR_SIGNALS(notificationSpy, 1); 92 - + { 93 - + const QVariantList &call(notificationSpy.at(0)); 94 - + EXPECT_EQ(call.at(0), "GetServerInformation"); 95 - + } 96 - + } 97 - + 98 - DBusTestRunner dbusTestRunner; 99 - 100 - DBusMock dbusMock; 101 - @@ -163,22 +187,21 @@ static void transform(QVariantList &list) { 102 - } 103 - 104 - TEST_P(TestSecretAgentGetSecrets, ProvidesPasswordForWpaPsk) { 105 - + setupSecretAgent(); 106 - + 107 - + QSignalSpy notificationSpy(notificationsInterface.data(), 108 - + SIGNAL(MethodCalled(const QString &, const QVariantList &))); 109 - + 110 - QDBusPendingReply<QVariantDictMap> reply( 111 - agentInterface->GetSecrets(connection(GetParam().keyManagement), 112 - QDBusObjectPath("/connection/foo"), 113 - SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(), 114 - 5)); 115 - 116 - - QSignalSpy notificationSpy(notificationsInterface.data(), 117 - - SIGNAL(MethodCalled(const QString &, const QVariantList &))); 118 - - if (notificationSpy.empty()) 119 - - { 120 - - ASSERT_TRUE(notificationSpy.wait()); 121 - - } 122 - + WAIT_FOR_SIGNALS(notificationSpy, 1); 123 - 124 - - ASSERT_EQ(1, notificationSpy.size()); 125 - const QVariantList &call(notificationSpy.at(0)); 126 - - EXPECT_EQ("Notify", call.at(0).toString().toStdString()); 127 - + EXPECT_EQ("Notify", call.at(0)); 128 - 129 - QVariantList args(call.at(1).toList()); 130 - transform(args); 131 - @@ -254,6 +277,7 @@ class TestSecretAgent: public TestSecretAgentCommon, public Test { 132 - }; 133 - 134 - TEST_F(TestSecretAgent, GetSecretsWithNone) { 135 - + setupSecretAgent(); 136 - 137 - QDBusPendingReply<QVariantDictMap> reply( 138 - agentInterface->GetSecrets( 139 - @@ -272,6 +296,8 @@ TEST_F(TestSecretAgent, GetSecretsWithNone) { 140 - /* Tests that if we request secrets and then cancel the request 141 - that we close the notification */ 142 - TEST_F(TestSecretAgent, CancelGetSecrets) { 143 - + setupSecretAgent(); 144 - + 145 - QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); 146 - 147 - agentInterface->GetSecrets( 148 - @@ -280,23 +306,19 @@ TEST_F(TestSecretAgent, CancelGetSecrets) { 149 - SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(), 150 - 5); 151 - 152 - - notificationSpy.wait(); 153 - - 154 - - ASSERT_EQ(1, notificationSpy.size()); 155 - - const QVariantList &call(notificationSpy.at(0)); 156 - - EXPECT_EQ("Notify", call.at(0).toString().toStdString()); 157 - + WAIT_FOR_SIGNALS(notificationSpy, 1); 158 - + { 159 - + const QVariantList &call(notificationSpy.at(0)); 160 - + EXPECT_EQ("Notify", call.at(0)); 161 - + } 162 - 163 - notificationSpy.clear(); 164 - 165 - agentInterface->CancelGetSecrets(QDBusObjectPath("/connection/foo"), 166 - SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME); 167 - 168 - - if (notificationSpy.empty()) 169 - - { 170 - - ASSERT_TRUE(notificationSpy.wait()); 171 - - } 172 - + WAIT_FOR_SIGNALS(notificationSpy, 1); 173 - 174 - - ASSERT_EQ(1, notificationSpy.size()); 175 - const QVariantList &closecall(notificationSpy.at(0)); 176 - EXPECT_EQ("CloseNotification", closecall.at(0).toString().toStdString()); 177 - } 178 - @@ -304,6 +326,8 @@ TEST_F(TestSecretAgent, CancelGetSecrets) { 179 - /* Ensures that if we request secrets twice we close the notification 180 - for the first request */ 181 - TEST_F(TestSecretAgent, MultiSecrets) { 182 - + setupSecretAgent(); 183 - + 184 - QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); 185 - 186 - agentInterface->GetSecrets( 187 - @@ -312,15 +336,12 @@ TEST_F(TestSecretAgent, MultiSecrets) { 188 - SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(), 189 - 5); 190 - 191 - - if (notificationSpy.empty()) 192 - + WAIT_FOR_SIGNALS(notificationSpy, 1); 193 - { 194 - - ASSERT_TRUE(notificationSpy.wait()); 195 - + const QVariantList &call(notificationSpy.at(0)); 196 - + EXPECT_EQ("Notify", call.at(0)); 197 - } 198 - 199 - - ASSERT_EQ(1, notificationSpy.size()); 200 - - const QVariantList &call(notificationSpy.at(0)); 201 - - EXPECT_EQ("Notify", call.at(0).toString().toStdString()); 202 - - 203 - notificationSpy.clear(); 204 - 205 - agentInterface->GetSecrets( 206 - @@ -329,14 +350,7 @@ TEST_F(TestSecretAgent, MultiSecrets) { 207 - SecretAgent::NM_WIRELESS_SECURITY_SETTING_NAME, QStringList(), 208 - 5); 209 - 210 - - if (notificationSpy.empty()) 211 - - { 212 - - ASSERT_TRUE(notificationSpy.wait()); 213 - - } 214 - - if (notificationSpy.size() == 1) 215 - - { 216 - - ASSERT_TRUE(notificationSpy.wait()); 217 - - } 218 - + WAIT_FOR_SIGNALS(notificationSpy, 2); 219 - 220 - ASSERT_EQ(2, notificationSpy.size()); 221 - const QVariantList &closecall(notificationSpy.at(1)); 222 - @@ -347,11 +361,15 @@ TEST_F(TestSecretAgent, MultiSecrets) { 223 - } 224 - 225 - TEST_F(TestSecretAgent, SaveSecrets) { 226 - + setupSecretAgent(); 227 - + 228 - agentInterface->SaveSecrets(QVariantDictMap(), 229 - QDBusObjectPath("/connection/foo")).waitForFinished(); 230 - } 231 - 232 - TEST_F(TestSecretAgent, DeleteSecrets) { 233 - + setupSecretAgent(); 234 - + 235 - agentInterface->DeleteSecrets(QVariantDictMap(), 236 - QDBusObjectPath("/connection/foo")).waitForFinished(); 237 - } 238 - -- 239 - 2.47.1 240 -
···
+5 -12
pkgs/desktops/lomiri/services/lomiri-indicator-network/default.nix
··· 33 34 stdenv.mkDerivation (finalAttrs: { 35 pname = "lomiri-indicator-network"; 36 - version = "1.1.0"; 37 38 src = fetchFromGitLab { 39 owner = "ubports"; 40 repo = "development/core/lomiri-indicator-network"; 41 tag = finalAttrs.version; 42 - hash = "sha256-pN5M5VKRyo6csmI/vrmp/bonnap3oEdPuHAUJ1PjdOs="; 43 }; 44 45 outputs = [ ··· 48 "doc" 49 ]; 50 51 - patches = [ 52 - ./1001-test-secret-agent-Make-GetServerInformation-not-leak-into-tests.patch 53 - ]; 54 - 55 postPatch = '' 56 # Override original prefixes 57 substituteInPlace data/CMakeLists.txt \ 58 --replace-fail 'pkg_get_variable(DBUS_SESSION_BUS_SERVICES_DIR dbus-1 session_bus_services_dir)' 'pkg_get_variable(DBUS_SESSION_BUS_SERVICES_DIR dbus-1 session_bus_services_dir DEFINE_VARIABLES datadir=''${CMAKE_INSTALL_FULL_SYSCONFDIR})' \ 59 --replace-fail 'pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)' 'pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir DEFINE_VARIABLES prefix=''${CMAKE_INSTALL_PREFIX})' 60 - 61 - # Fix typo 62 - # Remove when https://gitlab.com/ubports/development/core/lomiri-indicator-network/-/merge_requests/131 merged & in release 63 - substituteInPlace src/indicator/nmofono/wwan/modem.cpp \ 64 - --replace-fail 'if (m_isManaged = managed)' 'if (m_isManaged == managed)' 65 ''; 66 67 strictDeps = true; ··· 134 meta = { 135 description = "Ayatana indiator exporting the network settings menu through D-Bus"; 136 homepage = "https://gitlab.com/ubports/development/core/lomiri-indicator-network"; 137 - changelog = "https://gitlab.com/ubports/development/core/lomiri-indicator-network/-/blob/${finalAttrs.version}/ChangeLog"; 138 license = lib.licenses.gpl3Only; 139 teams = [ lib.teams.lomiri ]; 140 platforms = lib.platforms.linux;
··· 33 34 stdenv.mkDerivation (finalAttrs: { 35 pname = "lomiri-indicator-network"; 36 + version = "1.1.1"; 37 38 src = fetchFromGitLab { 39 owner = "ubports"; 40 repo = "development/core/lomiri-indicator-network"; 41 tag = finalAttrs.version; 42 + hash = "sha256-R5W1MmT+H9i8NXrzOv2xaVu8TKPCRCAAswwM/tflkQ0="; 43 }; 44 45 outputs = [ ··· 48 "doc" 49 ]; 50 51 postPatch = '' 52 # Override original prefixes 53 substituteInPlace data/CMakeLists.txt \ 54 --replace-fail 'pkg_get_variable(DBUS_SESSION_BUS_SERVICES_DIR dbus-1 session_bus_services_dir)' 'pkg_get_variable(DBUS_SESSION_BUS_SERVICES_DIR dbus-1 session_bus_services_dir DEFINE_VARIABLES datadir=''${CMAKE_INSTALL_FULL_SYSCONFDIR})' \ 55 --replace-fail 'pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir)' 'pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir DEFINE_VARIABLES prefix=''${CMAKE_INSTALL_PREFIX})' 56 ''; 57 58 strictDeps = true; ··· 125 meta = { 126 description = "Ayatana indiator exporting the network settings menu through D-Bus"; 127 homepage = "https://gitlab.com/ubports/development/core/lomiri-indicator-network"; 128 + changelog = "https://gitlab.com/ubports/development/core/lomiri-indicator-network/-/blob/${ 129 + if (!builtins.isNull finalAttrs.src.tag) then finalAttrs.src.tag else finalAttrs.src.rev 130 + }/ChangeLog"; 131 license = lib.licenses.gpl3Only; 132 teams = [ lib.teams.lomiri ]; 133 platforms = lib.platforms.linux;