summaryrefslogtreecommitdiff
path: root/tests/unit/plugins/irc/test-irc-join.cpp
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-16 21:03:22 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-16 21:03:22 +0200
commit1f21cdc0bd89a326fc7e682c5de0b433846a48de (patch)
treea4b8cca2728a5604fc9bd4968698e6b8acee389b /tests/unit/plugins/irc/test-irc-join.cpp
parente11ce668a231f6e5cb63960fe965e3c7b84c5895 (diff)
downloadweechat-1f21cdc0bd89a326fc7e682c5de0b433846a48de.zip
irc: update secure data when server autojoin option contains `${sec.data.xxx}` and option autojoin_dynamic is enabled (closes #1934)
Diffstat (limited to 'tests/unit/plugins/irc/test-irc-join.cpp')
-rw-r--r--tests/unit/plugins/irc/test-irc-join.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-join.cpp b/tests/unit/plugins/irc/test-irc-join.cpp
index 59c21c0f4..ed8aa4087 100644
--- a/tests/unit/plugins/irc/test-irc-join.cpp
+++ b/tests/unit/plugins/irc/test-irc-join.cpp
@@ -28,6 +28,8 @@ extern "C"
#include <string.h>
#include "src/core/wee-arraylist.h"
#include "src/core/wee-config-file.h"
+#include "src/core/wee-hashtable.h"
+#include "src/core/wee-secure.h"
#include "src/gui/gui-buffer.h"
#include "src/plugins/irc/irc-channel.h"
#include "src/plugins/irc/irc-join.h"
@@ -596,6 +598,7 @@ TEST(IrcJoin, SortChannels)
/*
* Tests functions:
+ * irc_join_set_autojoin_option
* irc_join_add_channel_to_autojoin
* irc_join_add_channels_to_autojoin
* irc_join_remove_channel_from_autojoin
@@ -756,6 +759,33 @@ TEST(IrcJoin, AddRemoveChannelsAutojoin)
"#xyz,#DEF,#jkl key_xyz",
CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ /* use of secure data in autojoin option */
+ hashtable_set (secure_hashtable_data, "autojoin", "#abc");
+ config_file_option_set (server->options[IRC_SERVER_OPTION_AUTOJOIN],
+ "${sec.data.autojoin}", 1);
+ irc_join_add_channels_to_autojoin (server, "#def key_def");
+ STRCMP_EQUAL(
+ "${sec.data.autojoin}",
+ CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ STRCMP_EQUAL(
+ "#def,#abc key_def",
+ (const char *)hashtable_get (secure_hashtable_data, "autojoin"));
+ irc_join_rename_channel_in_autojoin (server, "#abc", "#zzz");
+ STRCMP_EQUAL(
+ "${sec.data.autojoin}",
+ CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ STRCMP_EQUAL(
+ "#def,#zzz key_def",
+ (const char *)hashtable_get (secure_hashtable_data, "autojoin"));
+ irc_join_remove_channel_from_autojoin (server, "#def");
+ STRCMP_EQUAL(
+ "${sec.data.autojoin}",
+ CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ STRCMP_EQUAL(
+ "#zzz",
+ (const char *)hashtable_get (secure_hashtable_data, "autojoin"));
+ hashtable_remove (secure_hashtable_data, "autojoin");
+
irc_server_free (server);
}
@@ -783,6 +813,19 @@ TEST(IrcJoin, SaveChannelsToAutojoin)
"#test2,#test1 key2",
CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ /* use of secure data in autojoin option */
+ hashtable_set (secure_hashtable_data, "autojoin", "#abc");
+ config_file_option_set (server->options[IRC_SERVER_OPTION_AUTOJOIN],
+ "${sec.data.autojoin}", 1);
+ irc_join_save_channels_to_autojoin (server);
+ STRCMP_EQUAL(
+ "${sec.data.autojoin}",
+ CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ STRCMP_EQUAL(
+ "#test2,#test1 key2",
+ (const char *)hashtable_get (secure_hashtable_data, "autojoin"));
+ hashtable_remove (secure_hashtable_data, "autojoin");
+
gui_buffer_close (channel1->buffer);
gui_buffer_close (channel2->buffer);
@@ -813,5 +856,19 @@ TEST(IrcJoin, SortAutojoinChannels)
STRCMP_EQUAL("#xyz,#zzz,#ABC,#def,#ghi key_xyz,key_zzz",
CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ /* use of secure data in autojoin option */
+ hashtable_set (secure_hashtable_data,
+ "autojoin", "#zzz,#xyz,#ghi,#def,#ABC key_zzz,key_xyz");
+ config_file_option_set (server->options[IRC_SERVER_OPTION_AUTOJOIN],
+ "${sec.data.autojoin}", 1);
+ irc_join_sort_autojoin (server, IRC_JOIN_SORT_ALPHA);
+ STRCMP_EQUAL(
+ "${sec.data.autojoin}",
+ CONFIG_STRING(server->options[IRC_SERVER_OPTION_AUTOJOIN]));
+ STRCMP_EQUAL(
+ "#xyz,#zzz,#ABC,#def,#ghi key_xyz,key_zzz",
+ (const char *)hashtable_get (secure_hashtable_data, "autojoin"));
+ hashtable_remove (secure_hashtable_data, "autojoin");
+
irc_server_free (server);
}