summaryrefslogtreecommitdiff
path: root/src/test.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-02-25 18:35:30 +0100
committerFlorent Le Coz <louiz@louiz.org>2015-02-25 18:35:30 +0100
commit2df0ebf2dfed1dcbf80c92bff8361e2a04581bec (patch)
tree899b26c9166f921dc4f6d7cb5f661ca4a1cec8b9 /src/test.cpp
parent1c43c3af4cbefcd482f4145ee3d7553631a7485d (diff)
downloadbiboumi-2df0ebf2dfed1dcbf80c92bff8361e2a04581bec.tar.gz
biboumi-2df0ebf2dfed1dcbf80c92bff8361e2a04581bec.tar.bz2
biboumi-2df0ebf2dfed1dcbf80c92bff8361e2a04581bec.tar.xz
biboumi-2df0ebf2dfed1dcbf80c92bff8361e2a04581bec.zip
Add support for a fixed_irc_server configuration
This option lets the administrator choose a specific IRC server, and only that server can be used with this biboumi instance. In this mode, JIDs to use are changed like this: - #chan%irc.example.com@biboumi.example.com -> #chan@biboumi.example.com - user!irc.example.com@biboumi.example.com -> user!@biboumi.example.com - #chan%irc.example.com@biboumi.example.com/Nick -> #chan@biboumi.example.com/Nick - %irc.example.com@biboumi.example.com -> no equivalent - irc.example.com@biboumi.example.com -> no equivalent
Diffstat (limited to 'src/test.cpp')
-rw-r--r--src/test.cpp126
1 files changed, 94 insertions, 32 deletions
diff --git a/src/test.cpp b/src/test.cpp
index a4371b2..9fa2c99 100644
--- a/src/test.cpp
+++ b/src/test.cpp
@@ -303,38 +303,100 @@ int main()
/**
* IID parsing
*/
- std::cout << color << "Testing IID parsing…" << reset << std::endl;
- Iid iid1("foo!irc.example.org");
- std::cout << std::to_string(iid1) << std::endl;
- assert(std::to_string(iid1) == "foo!irc.example.org");
- assert(iid1.get_local() == "foo");
- assert(iid1.get_server() == "irc.example.org");
- assert(!iid1.is_channel);
- assert(iid1.is_user);
-
- Iid iid2("#test%irc.example.org");
- std::cout << std::to_string(iid2) << std::endl;
- assert(std::to_string(iid2) == "#test%irc.example.org");
- assert(iid2.get_local() == "#test");
- assert(iid2.get_server() == "irc.example.org");
- assert(iid2.is_channel);
- assert(!iid2.is_user);
-
- Iid iid3("%irc.example.org");
- std::cout << std::to_string(iid3) << std::endl;
- assert(std::to_string(iid3) == "%irc.example.org");
- assert(iid3.get_local() == "");
- assert(iid3.get_server() == "irc.example.org");
- assert(iid3.is_channel);
- assert(!iid3.is_user);
-
- Iid iid4("irc.example.org");
- std::cout << std::to_string(iid4) << std::endl;
- assert(std::to_string(iid4) == "irc.example.org");
- assert(iid4.get_local() == "");
- assert(iid4.get_server() == "irc.example.org");
- assert(!iid4.is_channel);
- assert(!iid4.is_user);
+ {
+ std::cout << color << "Testing IID parsing…" << reset << std::endl;
+ Iid iid1("foo!irc.example.org");
+ std::cout << std::to_string(iid1) << std::endl;
+ assert(std::to_string(iid1) == "foo!irc.example.org");
+ assert(iid1.get_local() == "foo");
+ assert(iid1.get_server() == "irc.example.org");
+ assert(!iid1.is_channel);
+ assert(iid1.is_user);
+
+ Iid iid2("#test%irc.example.org");
+ std::cout << std::to_string(iid2) << std::endl;
+ assert(std::to_string(iid2) == "#test%irc.example.org");
+ assert(iid2.get_local() == "#test");
+ assert(iid2.get_server() == "irc.example.org");
+ assert(iid2.is_channel);
+ assert(!iid2.is_user);
+
+ Iid iid3("%irc.example.org");
+ std::cout << std::to_string(iid3) << std::endl;
+ assert(std::to_string(iid3) == "%irc.example.org");
+ assert(iid3.get_local() == "");
+ assert(iid3.get_server() == "irc.example.org");
+ assert(iid3.is_channel);
+ assert(!iid3.is_user);
+
+ Iid iid4("irc.example.org");
+ std::cout << std::to_string(iid4) << std::endl;
+ assert(std::to_string(iid4) == "irc.example.org");
+ assert(iid4.get_local() == "");
+ assert(iid4.get_server() == "irc.example.org");
+ assert(!iid4.is_channel);
+ assert(!iid4.is_user);
+
+ Iid iid5("nick!");
+ std::cout << std::to_string(iid5) << std::endl;
+ assert(std::to_string(iid5) == "nick!");
+ assert(iid5.get_local() == "nick");
+ assert(iid5.get_server() == "");
+ assert(!iid5.is_channel);
+ assert(iid5.is_user);
+
+ Iid iid6("##channel%");
+ std::cout << std::to_string(iid6) << std::endl;
+ assert(std::to_string(iid6) == "##channel%");
+ assert(iid6.get_local() == "##channel");
+ assert(iid6.get_server() == "");
+ assert(iid6.is_channel);
+ assert(!iid6.is_user);
+ }
+
+ {
+ std::cout << color << "Testing IID parsing with a fixed server configured…" << reset << std::endl;
+ // Now do the same tests, but with a configured fixed_irc_server
+ Config::set("fixed_irc_server", "fixed.example.com", false);
+
+ Iid iid1("foo!irc.example.org");
+ std::cout << std::to_string(iid1) << std::endl;
+ assert(std::to_string(iid1) == "foo!");
+ assert(iid1.get_local() == "foo");
+ assert(iid1.get_server() == "fixed.example.com");
+ assert(!iid1.is_channel);
+ assert(iid1.is_user);
+
+ Iid iid2("#test%irc.example.org");
+ std::cout << std::to_string(iid2) << std::endl;
+ assert(std::to_string(iid2) == "#test");
+ assert(iid2.get_local() == "#test");
+ assert(iid2.get_server() == "fixed.example.com");
+ assert(iid2.is_channel);
+ assert(!iid2.is_user);
+
+ // Note that it is impossible to adress the XMPP server directly, or to
+ // use the virtual channel, in that mode
+
+ // Iid iid3("%irc.example.org");
+ // Iid iid4("irc.example.org");
+
+ Iid iid5("nick!");
+ std::cout << std::to_string(iid5) << std::endl;
+ assert(std::to_string(iid5) == "nick!");
+ assert(iid5.get_local() == "nick");
+ assert(iid5.get_server() == "fixed.example.com");
+ assert(!iid5.is_channel);
+ assert(iid5.is_user);
+
+ Iid iid6("##channel%");
+ std::cout << std::to_string(iid6) << std::endl;
+ assert(std::to_string(iid6) == "##channel");
+ assert(iid6.get_local() == "##channel");
+ assert(iid6.get_server() == "fixed.example.com");
+ assert(iid6.is_channel);
+ assert(!iid6.is_user);
+ }
return 0;
}