annotate libpurple/tests/test_jabber_jutil.c @ 28491:916a4d2aa0b6

Fix another warning.
author maiku@pidgin.im
date Sun, 30 Aug 2009 03:56:32 +0000
parents 22c65c1090a8
children 4cb882afbd6f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15889
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15374
diff changeset
1 #include <string.h>
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15374
diff changeset
2
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 #include "tests.h"
15892
5bd5af818afe Update #includes to match changes in jabber
Stu Tomlinson <stu@nosnilmot.com>
parents: 15889
diff changeset
4 #include "../account.h"
5bd5af818afe Update #includes to match changes in jabber
Stu Tomlinson <stu@nosnilmot.com>
parents: 15889
diff changeset
5 #include "../conversation.h"
5bd5af818afe Update #includes to match changes in jabber
Stu Tomlinson <stu@nosnilmot.com>
parents: 15889
diff changeset
6 #include "../xmlnode.h"
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 #include "../protocols/jabber/jutil.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 START_TEST(test_get_resource)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 assert_string_equal_free("baz", jabber_get_resource("foo@bar/baz"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 assert_string_equal_free("baz", jabber_get_resource("bar/baz"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 assert_string_equal_free("baz/bat", jabber_get_resource("foo@bar/baz/bat"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 assert_string_equal_free("baz/bat", jabber_get_resource("bar/baz/bat"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 END_TEST
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 START_TEST(test_get_resource_no_resource)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 fail_unless(NULL == jabber_get_resource("foo@bar"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 fail_unless(NULL == jabber_get_resource("bar"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 END_TEST
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 START_TEST(test_get_bare_jid)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 assert_string_equal_free("foo@bar", jabber_get_bare_jid("foo@bar"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 assert_string_equal_free("foo@bar", jabber_get_bare_jid("foo@bar/baz"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 assert_string_equal_free("bar", jabber_get_bare_jid("bar"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 assert_string_equal_free("bar", jabber_get_bare_jid("bar/baz"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 END_TEST
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 START_TEST(test_nodeprep_validate)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 {
15889
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15374
diff changeset
37 char *longnode;
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15374
diff changeset
38
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 fail_unless(jabber_nodeprep_validate(NULL));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 fail_unless(jabber_nodeprep_validate("foo"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 fail_unless(jabber_nodeprep_validate("%d"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 fail_unless(jabber_nodeprep_validate("y\\z"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
15889
6577b292e7b4 Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <stu@nosnilmot.com>
parents: 15374
diff changeset
44 longnode = g_strnfill(1023, 'a');
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 fail_unless(jabber_nodeprep_validate(longnode));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 g_free(longnode);
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
47
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
48 longnode = g_strnfill(1024, 'a');
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
49 fail_if(jabber_nodeprep_validate(longnode));
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
50 g_free(longnode);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 END_TEST
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 START_TEST(test_nodeprep_validate_illegal_chars)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 fail_if(jabber_nodeprep_validate("don't"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 fail_if(jabber_nodeprep_validate("m@ke"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 fail_if(jabber_nodeprep_validate("\"me\""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 fail_if(jabber_nodeprep_validate("&ngry"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 fail_if(jabber_nodeprep_validate("c:"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 fail_if(jabber_nodeprep_validate("a/b"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 fail_if(jabber_nodeprep_validate("4>2"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 fail_if(jabber_nodeprep_validate("4<7"));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 END_TEST
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 START_TEST(test_nodeprep_validate_too_long)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 char *longnode = g_strnfill(1024, 'a');
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 fail_if(jabber_nodeprep_validate(longnode));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 g_free(longnode);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 END_TEST
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
75 #define assert_valid_jid(str) { \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
76 JabberID *jid = jabber_id_new(str); \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
77 fail_if(jid == NULL, "JID '%s' is valid but jabber_id_new() rejected it", str); \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
78 jabber_id_free(jid); \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
79 }
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
80
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
81 #define assert_invalid_jid(str) { \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
82 JabberID *jid = jabber_id_new(str); \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
83 fail_if(jid != NULL, "JID '%s' is invalid but jabber_id_new() allowed it", str); \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
84 jabber_id_free(jid); \
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
85 }
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
86
27636
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
87 #define assert_jid_parts(expect_node, expect_domain, str) { \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
88 JabberID *jid = jabber_id_new(str); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
89 fail_if(jid == NULL, "JID '%s' is valid but jabber_id_new() rejected it", str); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
90 fail_if(jid->node == NULL, "JID '%s' is valid but jabber_id_new() didn't return a node", str); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
91 fail_if(jid->domain == NULL, "JID '%s' is valid but jabber_id_new() didn't return a domain", str); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
92 fail_if(jid->resource != NULL, "JID '%s' doesn't contain a resource", str); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
93 assert_string_equal(expect_node, jid->node); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
94 assert_string_equal(expect_domain, jid->domain); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
95 jabber_id_free(jid); \
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
96 }
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
97
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
98 START_TEST(test_jabber_id_new)
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
99 {
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
100 assert_valid_jid("gmail.com");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
101 assert_valid_jid("gmail.com/Test");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
102 assert_valid_jid("gmail.com/Test@");
27529
c6fea4ae68b3 Two more JID tests.
Paul Aurich <paul@darkrain42.org>
parents: 27528
diff changeset
103 assert_valid_jid("gmail.com/@");
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
104 assert_valid_jid("gmail.com/Test@alkjaweflkj");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
105 assert_valid_jid("mark.doliner@gmail.com");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
106 assert_valid_jid("mark.doliner@gmail.com/Test12345");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
107 assert_valid_jid("mark.doliner@gmail.com/Test@12345");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
108 assert_valid_jid("mark.doliner@gmail.com/Te/st@12@//345");
27533
3599729ce9ce More tests, some with an international flavor. I have no idea what that
Mark Doliner <mark@kingant.net>
parents: 27529
diff changeset
109 assert_valid_jid("わいど@conference.jabber.org");
3599729ce9ce More tests, some with an international flavor. I have no idea what that
Mark Doliner <mark@kingant.net>
parents: 27529
diff changeset
110 assert_valid_jid("まりるーむ@conference.jabber.org");
3599729ce9ce More tests, some with an international flavor. I have no idea what that
Mark Doliner <mark@kingant.net>
parents: 27529
diff changeset
111 assert_valid_jid("mark.doliner@gmail.com/まりるーむ");
27535
91fefa830798 Whoops, some of these were asserting valid but should have been
Mark Doliner <mark@kingant.net>
parents: 27533
diff changeset
112 assert_valid_jid("mark.doliner@gmail/stuff.org");
27539
167d7c3a4f7b XMPP allows for internationalized domain names.
Paul Aurich <paul@darkrain42.org>
parents: 27535
diff changeset
113 assert_valid_jid("stuart@nödåtXäYZ.se");
167d7c3a4f7b XMPP allows for internationalized domain names.
Paul Aurich <paul@darkrain42.org>
parents: 27535
diff changeset
114 assert_valid_jid("stuart@nödåtXäYZ.se/まりるーむ");
167d7c3a4f7b XMPP allows for internationalized domain names.
Paul Aurich <paul@darkrain42.org>
parents: 27535
diff changeset
115 assert_valid_jid("mark.doliner@わいど.org");
167d7c3a4f7b XMPP allows for internationalized domain names.
Paul Aurich <paul@darkrain42.org>
parents: 27535
diff changeset
116 assert_valid_jid("nick@まつ.おおかみ.net");
27540
da3d0159333d XMPP domains can also be IPv4 or IPv6 addresses
Paul Aurich <paul@darkrain42.org>
parents: 27539
diff changeset
117 assert_valid_jid("paul@10.0.42.230/s");
da3d0159333d XMPP domains can also be IPv4 or IPv6 addresses
Paul Aurich <paul@darkrain42.org>
parents: 27539
diff changeset
118 assert_valid_jid("paul@[::1]"); /* IPv6 */
da3d0159333d XMPP domains can also be IPv4 or IPv6 addresses
Paul Aurich <paul@darkrain42.org>
parents: 27539
diff changeset
119 assert_valid_jid("paul@[2001:470:1f05:d58::2]");
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
120 assert_valid_jid("paul@[2001:470:1f05:d58::2]/foo");
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
121
27529
c6fea4ae68b3 Two more JID tests.
Paul Aurich <paul@darkrain42.org>
parents: 27528
diff changeset
122 assert_invalid_jid("@gmail.com");
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
123 assert_invalid_jid("@@gmail.com");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
124 assert_invalid_jid("mark.doliner@@gmail.com/Test12345");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
125 assert_invalid_jid("mark@doliner@gmail.com/Test12345");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
126 assert_invalid_jid("@gmail.com/Test@12345");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
127 assert_invalid_jid("/Test@12345");
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
128 assert_invalid_jid("mark.doliner@");
27528
2131abd387f9 I thought of another invalid JID. I'm changing jabber_id_new() so that all
Mark Doliner <mark@kingant.net>
parents: 27527
diff changeset
129 assert_invalid_jid("mark.doliner/");
27535
91fefa830798 Whoops, some of these were asserting valid but should have been
Mark Doliner <mark@kingant.net>
parents: 27533
diff changeset
130 assert_invalid_jid("mark.doliner@gmail_stuff.org");
91fefa830798 Whoops, some of these were asserting valid but should have been
Mark Doliner <mark@kingant.net>
parents: 27533
diff changeset
131 assert_invalid_jid("mark.doliner@gmail[stuff.org");
91fefa830798 Whoops, some of these were asserting valid but should have been
Mark Doliner <mark@kingant.net>
parents: 27533
diff changeset
132 assert_invalid_jid("mark.doliner@gmail\\stuff.org");
27546
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
133 assert_invalid_jid("paul@[::1]124");
e90fa379fcec Validate IPv6 identifiers in the domain portion of a JID.
Paul Aurich <paul@darkrain42.org>
parents: 27540
diff changeset
134 assert_invalid_jid("paul@2[::1]124/as");
27636
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
135
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
136 /* Ensure that jabber_id_new is properly lowercasing node and domains */
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
137 assert_jid_parts("paul", "darkrain42.org", "PaUL@darkrain42.org");
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
138 assert_jid_parts("paul", "darkrain42.org", "paul@DaRkRaIn42.org");
27674
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
139
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
140 /* These case-mapping tests culled from examining RFC3454 B.2 */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
141
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
142 /* Cyrillic capital EF (U+0424) maps to lowercase EF (U+0444) */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
143 assert_jid_parts("ф", "darkrain42.org", "Ф@darkrain42.org");
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
144 /*
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
145 * These character (U+A664 and U+A665) are not mapped to anything in
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
146 * RFC3454 B.2. This first test *fails* when not using IDN because glib's
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
147 * case-folding/utf8_strdown improperly lowercases the character.
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
148 */
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
149 assert_jid_parts("Ꙥ", "darkrain42.org", "Ꙥ@darkrain42.org");
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
150 assert_jid_parts("ꙥ", "darkrain42.org", "ꙥ@darkrain42.org");
e5fdfff98aa9 When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <paul@darkrain42.org>
parents: 27636
diff changeset
151 /* U+04E9 to U+04E9 */
27636
090dc513552f Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <paul@darkrain42.org>
parents: 27546
diff changeset
152 assert_jid_parts("paul", "өarkrain42.org", "paul@Өarkrain42.org");
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
153 }
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
154 END_TEST
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
155
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
156 START_TEST(test_jabber_normalize)
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
157 {
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
158 assert_string_equal("paul@darkrain42.org", jabber_normalize(NULL, "PaUL@DaRkRain42.org"));
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
159 assert_string_equal("paul@darkrain42.org", jabber_normalize(NULL, "PaUL@DaRkRain42.org/"));
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
160 assert_string_equal("paul@darkrain42.org", jabber_normalize(NULL, "PaUL@DaRkRain42.org/resource"));
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
161 }
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
162 END_TEST
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
163
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 Suite *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 jabber_jutil_suite(void)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 Suite *s = suite_create("Jabber Utility Functions");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 TCase *tc = tcase_create("Get Resource");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 tcase_add_test(tc, test_get_resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 tcase_add_test(tc, test_get_resource_no_resource);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 suite_add_tcase(s, tc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 tc = tcase_create("Get Bare JID");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 tcase_add_test(tc, test_get_bare_jid);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 suite_add_tcase(s, tc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
178 tc = tcase_create("JID validate");
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 tcase_add_test(tc, test_nodeprep_validate);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 tcase_add_test(tc, test_nodeprep_validate_illegal_chars);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 tcase_add_test(tc, test_nodeprep_validate_too_long);
27527
962ce369fc35 Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <mark@kingant.net>
parents: 15892
diff changeset
182 tcase_add_test(tc, test_jabber_id_new);
28482
22c65c1090a8 jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <paul@darkrain42.org>
parents: 27674
diff changeset
183 tcase_add_test(tc, test_jabber_normalize);
15374
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 suite_add_tcase(s, tc);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 return s;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 }