annotate libpurple/tests/test_jabber_digest_md5.c @ 32814:c94e2bfae121

Gadu-Gadu: synchronize internal libgadu with upstream - tiny sync. Refs #343
author tomkiewicz@cpw.pidgin.im
date Sun, 06 Nov 2011 13:34:58 +0000
parents e743507b3767
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31624
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 }