Mercurial > pidgin
annotate libpurple/tests/test_jabber_digest_md5.c @ 32043:b814c2878d12
merge of 'd74415beaf0f8e1ed4743514e1d90669676b8596'
and 'f21ba844464858c0ea853c940fd4433ce008cb07'
author | andrew.victor@mxit.com |
---|---|
date | Thu, 01 Sep 2011 18:26:08 +0000 |
parents | e743507b3767 |
children |
rev | line source |
---|---|
31176
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
1 #include <string.h> |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
2 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
3 #include "tests.h" |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
4 #include "../util.h" |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
5 #include "../protocols/jabber/auth_digest_md5.h" |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
6 #include "../protocols/jabber/jutil.h" |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
7 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
8 START_TEST(test_parsing) |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
9 { |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
10 GHashTable *table; |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
11 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
12 table = jabber_auth_digest_md5_parse("r=\"realm\",token= \" asdf\""); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
13 fail_if(g_hash_table_lookup(table, "r") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
14 assert_string_equal("realm", g_hash_table_lookup(table, "r")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
15 fail_if(g_hash_table_lookup(table, "token") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
16 assert_string_equal("asdf", g_hash_table_lookup(table, "token")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
17 g_hash_table_destroy(table); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
18 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
19 table = jabber_auth_digest_md5_parse("r=\"a\", token= \" asdf\""); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
20 fail_if(g_hash_table_lookup(table, "r") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
21 assert_string_equal("a", g_hash_table_lookup(table, "r")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
22 fail_if(g_hash_table_lookup(table, "token") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
23 assert_string_equal("asdf", g_hash_table_lookup(table, "token")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
24 g_hash_table_destroy(table); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
25 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
26 table = jabber_auth_digest_md5_parse("r=\"\", token= \" asdf\""); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
27 fail_if(g_hash_table_lookup(table, "r") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
28 assert_string_equal("", g_hash_table_lookup(table, "r")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
29 fail_if(g_hash_table_lookup(table, "token") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
30 assert_string_equal("asdf", g_hash_table_lookup(table, "token")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
31 g_hash_table_destroy(table); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
32 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
33 table = jabber_auth_digest_md5_parse("realm=\"somerealm\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",charset=utf-8,algorithm=md5-sess"); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
34 fail_if(g_hash_table_lookup(table, "realm") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
35 assert_string_equal("somerealm", g_hash_table_lookup(table, "realm")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
36 fail_if(g_hash_table_lookup(table, "nonce") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
37 assert_string_equal("OA6MG9tEQGm2hh", g_hash_table_lookup(table, "nonce")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
38 fail_if(g_hash_table_lookup(table, "qop") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
39 assert_string_equal("auth", g_hash_table_lookup(table, "qop")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
40 fail_if(g_hash_table_lookup(table, "charset") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
41 assert_string_equal("utf-8", g_hash_table_lookup(table, "charset")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
42 fail_if(g_hash_table_lookup(table, "algorithm") == NULL); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
43 assert_string_equal("md5-sess", g_hash_table_lookup(table, "algorithm")); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
44 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
45 g_hash_table_destroy(table); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
46 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
47 } |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
48 END_TEST |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
49 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
50 Suite * |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
51 jabber_digest_md5_suite(void) |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
52 { |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
53 Suite *s = suite_create("Jabber SASL DIGEST-MD5 functions"); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
54 |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
55 TCase *tc = tcase_create("Parsing Functionality"); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
56 tcase_add_test(tc, test_parsing); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
57 suite_add_tcase(s, tc); |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
58 return s; |
e743507b3767
jabber: Test harness for DIGEST-MD5 parsing function.
Paul Aurich <paul@darkrain42.org>
parents:
diff
changeset
|
59 } |