diff --git a/modules/clientnotify.cpp b/modules/clientnotify.cpp index 218e91bd..bb1560be 100644 --- a/modules/clientnotify.cpp +++ b/modules/clientnotify.cpp @@ -91,9 +91,9 @@ class CClientNotifyMod : public CModule { CString sRemoteIP = GetClient()->GetRemoteIP(); CString sRemoteClientID = GetClient()->GetIdentifier(); - CString& sClientNameMessage = sRemoteIP; - if (m_bNotifyOnNewClientID and sRemoteClientID != "") { - sClientNameMessage = sRemoteClientID; + CString sClientNameMessage{sRemoteIP}; + if (m_bNotifyOnNewClientID && sRemoteClientID != "") { + sClientNameMessage += " / " + sRemoteClientID; } auto sendLoginNotification = [&]() { diff --git a/test/integration/tests/modules.cpp b/test/integration/tests/modules.cpp index 7da1f159..3c19824b 100644 --- a/test/integration/tests/modules.cpp +++ b/test/integration/tests/modules.cpp @@ -20,6 +20,7 @@ #include "znctest.h" using testing::HasSubstr; +using testing::Not; namespace znc_inttest { namespace { @@ -61,9 +62,9 @@ TEST_F(ZNCTest, ClientNotifyModule) { client.Write("znc loadmod clientnotify"); client.ReadUntil("Loaded module"); - auto check_not_sent = [](Socket& client, QString wrongAnswer){ - auto result = client.ReadRemainder(); - EXPECT_FALSE(result.contains(wrongAnswer.toUtf8())) << "Got an answer even though we didnt want one with the given configuration"; + auto check_not_sent = [](Socket& client, std::string wrongAnswer){ + auto result = QString{client.ReadRemainder()}.toStdString(); + EXPECT_THAT(result, Not(HasSubstr((wrongAnswer)))) << "Got an answer from the ClientNotifyModule even though we didnt want one with the given configuration"; }; auto client2 = LoginClient(); @@ -82,20 +83,20 @@ TEST_F(ZNCTest, ClientNotifyModule) { client.Write("PRIVMSG *clientnotify :NewNotifyOn clientid"); auto client5 = LoginClient("identifier123"); - client.ReadUntil(":Another client (identifier123) authenticated as your user. Use the 'ListClients' command to see all 5 clients."); + client.ReadUntil(":Another client (127.0.0.1 / identifier123) authenticated as your user. Use the 'ListClients' command to see all 5 clients."); auto client6 = LoginClient("identifier123"); - check_not_sent(client, ":Another client (identifier123) authenticated as your user. Use the 'ListClients' command to see all 6 clients."); + check_not_sent(client, ":Another client (127.0.0.1 / identifier123) authenticated as your user. Use the 'ListClients' command to see all 6 clients."); auto client7 = LoginClient("not_identifier123"); - client.ReadUntil(":Another client (not_identifier123) authenticated as your user. Use the 'ListClients' command to see all 7 clients."); + client.ReadUntil(":Another client (127.0.0.1 / not_identifier123) authenticated as your user. Use the 'ListClients' command to see all 7 clients."); // choose to notify from both clientids and new IPs client.Write("PRIVMSG *clientnotify :NewNotifyOn both"); auto client8 = LoginClient(); - check_not_sent(client, ":Another client (127.0.0.1) authenticated as your user. Use the 'ListClients' command to see all 8 clients."); + check_not_sent(client, ":Another client (127.0.0.1 / identifier123) authenticated as your user. Use the 'ListClients' command to see all 8 clients."); auto client9 = LoginClient("definitely_not_identifier123"); - client.ReadUntil(":Another client (definitely_not_identifier123) authenticated as your user. Use the 'ListClients' command to see all 9 clients."); + client.ReadUntil(":Another client (127.0.0.1 / definitely_not_identifier123) authenticated as your user. Use the 'ListClients' command to see all 9 clients."); } TEST_F(ZNCTest, ShellModule) {