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