diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-04-06 20:22:34 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-04-12 17:17:38 +0200 |
commit | 95b30f8da5be6065f1d83be0de6bb2dadbd226eb (patch) | |
tree | 94d5e2fdad8c8cb152601e7ae951e4811f7fac33 /tests/unit | |
parent | 8eb096b3ef1676064c8e6f5c43c8790e8bab6bfa (diff) | |
download | weechat-95b30f8da5be6065f1d83be0de6bb2dadbd226eb.zip |
irc: connect with TLS and port 6697 by default (issue #1903)
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/plugins/irc/test-irc-server.cpp | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/tests/unit/plugins/irc/test-irc-server.cpp b/tests/unit/plugins/irc/test-irc-server.cpp index f80f6cd66..4ba8a5056 100644 --- a/tests/unit/plugins/irc/test-irc-server.cpp +++ b/tests/unit/plugins/irc/test-irc-server.cpp @@ -177,12 +177,97 @@ TEST(IrcServer, GetNameWithoutPort) /* * Tests functions: + * irc_server_get_addresses_ports_tls * irc_server_set_addresses */ TEST(IrcServer, SetAddresses) { - /* TODO: write tests */ + struct t_irc_server *server; + char *str; + + POINTERS_EQUAL(NULL, irc_server_get_addresses_ports_tls (NULL)); + + server = irc_server_alloc ("server1"); + + config_file_option_set (server->options[IRC_SERVER_OPTION_TLS], "off", 1); + + LONGS_EQUAL(0, irc_server_set_addresses (NULL, NULL, 0)); + LONGS_EQUAL(0, irc_server_set_addresses (NULL, "irc.example.org", 0)); + + LONGS_EQUAL(1, irc_server_set_addresses (server, "fake:irc.fake.org", 0)); + LONGS_EQUAL(1, server->fake_server); + STRCMP_EQUAL("irc.fake.org", server->addresses_eval); + LONGS_EQUAL(1, server->addresses_count); + STRCMP_EQUAL("irc.fake.org", server->addresses_array[0]); + LONGS_EQUAL(6667, server->ports_array[0]); + LONGS_EQUAL(0, server->retry_array[0]); + + WEE_TEST_STR("irc.fake.org/6667 (TLS: disabled)", + irc_server_get_addresses_ports_tls (server)); + + LONGS_EQUAL(1, irc_server_set_addresses (server, "irc.example.org", 0)); + LONGS_EQUAL(0, server->fake_server); + STRCMP_EQUAL("irc.example.org", server->addresses_eval); + LONGS_EQUAL(1, server->addresses_count); + STRCMP_EQUAL("irc.example.org", server->addresses_array[0]); + LONGS_EQUAL(6667, server->ports_array[0]); + LONGS_EQUAL(0, server->retry_array[0]); + + WEE_TEST_STR("irc.example.org/6667 (TLS: disabled)", + irc_server_get_addresses_ports_tls (server)); + + LONGS_EQUAL(1, + irc_server_set_addresses ( + server, "irc.example.org,irc2.example.org/6666", 0)); + LONGS_EQUAL(0, server->fake_server); + STRCMP_EQUAL("irc.example.org,irc2.example.org/6666", server->addresses_eval); + LONGS_EQUAL(2, server->addresses_count); + STRCMP_EQUAL("irc.example.org", server->addresses_array[0]); + STRCMP_EQUAL("irc2.example.org", server->addresses_array[1]); + LONGS_EQUAL(6667, server->ports_array[0]); + LONGS_EQUAL(6666, server->ports_array[1]); + LONGS_EQUAL(0, server->retry_array[0]); + LONGS_EQUAL(0, server->retry_array[1]); + + WEE_TEST_STR("irc.example.org/6667, irc2.example.org/6666 (TLS: disabled)", + irc_server_get_addresses_ports_tls (server)); + + config_file_option_set (server->options[IRC_SERVER_OPTION_TLS], "on", 1); + + LONGS_EQUAL(1, + irc_server_set_addresses ( + server, "irc.example.org,irc2.example.org/7000", 1)); + LONGS_EQUAL(0, server->fake_server); + STRCMP_EQUAL("irc.example.org,irc2.example.org/7000", server->addresses_eval); + LONGS_EQUAL(2, server->addresses_count); + STRCMP_EQUAL("irc.example.org", server->addresses_array[0]); + STRCMP_EQUAL("irc2.example.org", server->addresses_array[1]); + LONGS_EQUAL(6697, server->ports_array[0]); + LONGS_EQUAL(7000, server->ports_array[1]); + LONGS_EQUAL(0, server->retry_array[0]); + LONGS_EQUAL(0, server->retry_array[1]); + + WEE_TEST_STR("irc.example.org/6697, irc2.example.org/7000 (TLS: enabled)", + irc_server_get_addresses_ports_tls (server)); + + LONGS_EQUAL(0, + irc_server_set_addresses ( + server, "irc.example.org,irc2.example.org/7000", 1)); + LONGS_EQUAL(0, server->fake_server); + STRCMP_EQUAL("irc.example.org,irc2.example.org/7000", server->addresses_eval); + LONGS_EQUAL(2, server->addresses_count); + STRCMP_EQUAL("irc.example.org", server->addresses_array[0]); + STRCMP_EQUAL("irc2.example.org", server->addresses_array[1]); + LONGS_EQUAL(6697, server->ports_array[0]); + LONGS_EQUAL(7000, server->ports_array[1]); + LONGS_EQUAL(0, server->retry_array[0]); + LONGS_EQUAL(0, server->retry_array[1]); + + WEE_TEST_STR("irc.example.org/6697, irc2.example.org/7000 (TLS: enabled)", + irc_server_get_addresses_ports_tls (server)); + + irc_server_free (server); } /* |