Sat, 01 May 2010 02:36:27 +0000
util tests: Add a test for all the lower-ASCII control characters excluding the
whitelisted 0x9, 0xA, and 0xD
|
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")); | |
|
28923
70f46ab46908
'=' and ',' are valid nodeprep characters
Paul Aurich <darkrain42@pidgin.im>
parents:
28713
diff
changeset
|
43 | fail_unless(jabber_nodeprep_validate("a=")); |
|
70f46ab46908
'=' and ',' are valid nodeprep characters
Paul Aurich <darkrain42@pidgin.im>
parents:
28713
diff
changeset
|
44 | fail_unless(jabber_nodeprep_validate("a,")); |
| 15155 | 45 | |
|
15950
0f01bb61c5d3
Fix compiler warnings and errors in tests resulting from using DEBUG_CFLAGS
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15435
diff
changeset
|
46 | longnode = g_strnfill(1023, 'a'); |
| 15155 | 47 | fail_unless(jabber_nodeprep_validate(longnode)); |
| 48 | 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
|
49 | |
|
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
50 | 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
|
51 | 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
|
52 | g_free(longnode); |
| 15155 | 53 | } |
| 54 | END_TEST | |
| 55 | ||
| 56 | START_TEST(test_nodeprep_validate_illegal_chars) | |
| 57 | { | |
| 58 | fail_if(jabber_nodeprep_validate("don't")); | |
| 59 | fail_if(jabber_nodeprep_validate("m@ke")); | |
| 60 | fail_if(jabber_nodeprep_validate("\"me\"")); | |
| 61 | fail_if(jabber_nodeprep_validate("&ngry")); | |
| 62 | fail_if(jabber_nodeprep_validate("c:")); | |
| 63 | fail_if(jabber_nodeprep_validate("a/b")); | |
| 64 | fail_if(jabber_nodeprep_validate("4>2")); | |
| 65 | fail_if(jabber_nodeprep_validate("4<7")); | |
| 66 | } | |
| 67 | END_TEST | |
| 68 | ||
| 69 | START_TEST(test_nodeprep_validate_too_long) | |
| 70 | { | |
| 71 | char *longnode = g_strnfill(1024, 'a'); | |
| 72 | fail_if(jabber_nodeprep_validate(longnode)); | |
| 73 | g_free(longnode); | |
| 74 | } | |
| 75 | END_TEST | |
| 76 | ||
|
27710
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
77 | #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
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | } |
|
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
82 | |
|
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
83 | #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
|
84 | 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
|
85 | 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
|
86 | 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
|
87 | } |
|
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
88 | |
|
27818
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
89 | #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
|
90 | JabberID *jid = jabber_id_new(str); \ |
|
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
91 | 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
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | jabber_id_free(jid); \ |
|
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
98 | } |
|
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
99 | |
|
27710
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
100 | 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
|
101 | { |
|
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"); |
|
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
103 | 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
|
104 | assert_valid_jid("gmail.com/Test@"); |
| 27712 | 105 | 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | 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
|
112 | 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
|
113 | 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | assert_valid_jid("mark.doliner@わいど.org"); |
|
3f93427031cd
XMPP allows for internationalized domain names.
Paul Aurich <darkrain42@pidgin.im>
parents:
27718
diff
changeset
|
118 | 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
|
119 | 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
|
120 | 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
|
121 | 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
|
122 | assert_valid_jid("paul@[2001:470:1f05:d58::2]/foo"); |
|
28923
70f46ab46908
'=' and ',' are valid nodeprep characters
Paul Aurich <darkrain42@pidgin.im>
parents:
28713
diff
changeset
|
123 | assert_valid_jid("pa=ul@10.0.42.230"); |
|
70f46ab46908
'=' and ',' are valid nodeprep characters
Paul Aurich <darkrain42@pidgin.im>
parents:
28713
diff
changeset
|
124 | assert_valid_jid("pa,ul@10.0.42.230"); |
|
27710
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
125 | |
| 27712 | 126 | 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
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | assert_invalid_jid("paul@まつ.おおかみ/\x01"); |
|
27818
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
140 | |
|
28713
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
141 | /* |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
142 | * RFC 3454 Section 6 reads, in part, |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
143 | * "If a string contains any RandALCat character, the |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
144 | * string MUST NOT contain any LCat character." |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
145 | * The character is U+066D (ARABIC FIVE POINTED STAR). |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
146 | */ |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
147 | assert_invalid_jid("foo@example.com/٭simplexe٭"); |
|
b68bad2389d3
Add another (IMHO unintuitive) JID test. Refs #10532.
Paul Aurich <darkrain42@pidgin.im>
parents:
28558
diff
changeset
|
148 | |
|
27818
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
149 | /* 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
|
150 | 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
|
151 | 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
|
152 | |
|
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
153 | /* 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
|
154 | |
|
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
155 | /* 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
|
156 | assert_jid_parts("ф", "darkrain42.org", "Ф@darkrain42.org"); |
|
28558
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
157 | |
|
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
158 | #ifdef USE_IDN |
|
27849
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
159 | /* |
|
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
160 | * 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
|
161 | * RFC3454 B.2. This first test *fails* when not using IDN because glib's |
|
28554
a4a6df1d2e53
Clarify the "improperly"; glib is doing what I'd expect strdown to do.
Paul Aurich <darkrain42@pidgin.im>
parents:
28535
diff
changeset
|
162 | * case-folding/utf8_strdown improperly (for XMPP) lowercases the character. |
|
28558
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
163 | * |
|
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
164 | * This is known, but not (very?) likely to actually cause a problem, so |
|
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
165 | * this test is commented out when using glib's functions. |
|
27849
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
166 | */ |
|
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
167 | 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
|
168 | assert_jid_parts("ꙥ", "darkrain42.org", "ꙥ@darkrain42.org"); |
|
28558
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
169 | #endif |
|
dd11e7078db9
Just comment out the failing tests when using glib; it's not likely anyone
Paul Aurich <darkrain42@pidgin.im>
parents:
28554
diff
changeset
|
170 | |
|
27849
7f7428cb8309
When GNU Libidn is available, use it for XMPP stringprep operations.
Paul Aurich <darkrain42@pidgin.im>
parents:
27818
diff
changeset
|
171 | /* U+04E9 to U+04E9 */ |
|
27818
d2d5d265001b
Ensure UTF-8 strdown is mostly working correctly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27728
diff
changeset
|
172 | 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
|
173 | } |
|
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
174 | 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
|
175 | |
|
28414
5093c1a49d5c
jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27849
diff
changeset
|
176 | 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
|
177 | { |
|
5093c1a49d5c
jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27849
diff
changeset
|
178 | 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
|
179 | 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
|
180 | 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
|
181 | } |
|
5093c1a49d5c
jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27849
diff
changeset
|
182 | END_TEST |
|
5093c1a49d5c
jabber: Use a better method for dealing with terminating slashes in JIDs.
Paul Aurich <darkrain42@pidgin.im>
parents:
27849
diff
changeset
|
183 | |
| 15155 | 184 | Suite * |
| 185 | jabber_jutil_suite(void) | |
| 186 | { | |
| 187 | Suite *s = suite_create("Jabber Utility Functions"); | |
| 188 | ||
| 189 | TCase *tc = tcase_create("Get Resource"); | |
| 190 | tcase_add_test(tc, test_get_resource); | |
| 191 | tcase_add_test(tc, test_get_resource_no_resource); | |
| 192 | suite_add_tcase(s, tc); | |
| 193 | ||
| 194 | tc = tcase_create("Get Bare JID"); | |
| 195 | tcase_add_test(tc, test_get_bare_jid); | |
| 196 | suite_add_tcase(s, tc); | |
| 197 | ||
|
27710
e4b25e3c28a2
Add tests for jabber_id_new(). Please add to this! JIDs with accented
Mark Doliner <markdoliner@pidgin.im>
parents:
15953
diff
changeset
|
198 | tc = tcase_create("JID validate"); |
| 15155 | 199 | tcase_add_test(tc, test_nodeprep_validate); |
| 200 | tcase_add_test(tc, test_nodeprep_validate_illegal_chars); | |
| 201 | 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
|
202 | 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
|
203 | tcase_add_test(tc, test_jabber_normalize); |
| 15155 | 204 | suite_add_tcase(s, tc); |
| 205 | ||
| 206 | return s; | |
| 207 | } |