Remove useless comparison
[pidgin-git.git] / libpurple / tests / test_jabber_digest_md5.c
bloba426b9a2a5515852c15f3404a4fec06ef2015250
1 #include <string.h>
3 #include "tests.h"
4 #include "../util.h"
5 #include "../protocols/jabber/auth_digest_md5.h"
6 #include "../protocols/jabber/jutil.h"
8 START_TEST(test_parsing)
10 GHashTable *table;
12 table = jabber_auth_digest_md5_parse("r=\"realm\",token= \" asdf\"");
13 fail_if(g_hash_table_lookup(table, "r") == NULL);
14 assert_string_equal("realm", g_hash_table_lookup(table, "r"));
15 fail_if(g_hash_table_lookup(table, "token") == NULL);
16 assert_string_equal("asdf", g_hash_table_lookup(table, "token"));
17 g_hash_table_destroy(table);
19 table = jabber_auth_digest_md5_parse("r=\"a\", token= \" asdf\"");
20 fail_if(g_hash_table_lookup(table, "r") == NULL);
21 assert_string_equal("a", g_hash_table_lookup(table, "r"));
22 fail_if(g_hash_table_lookup(table, "token") == NULL);
23 assert_string_equal("asdf", g_hash_table_lookup(table, "token"));
24 g_hash_table_destroy(table);
26 table = jabber_auth_digest_md5_parse("r=\"\", token= \" asdf\"");
27 fail_if(g_hash_table_lookup(table, "r") == NULL);
28 assert_string_equal("", g_hash_table_lookup(table, "r"));
29 fail_if(g_hash_table_lookup(table, "token") == NULL);
30 assert_string_equal("asdf", g_hash_table_lookup(table, "token"));
31 g_hash_table_destroy(table);
33 table = jabber_auth_digest_md5_parse("realm=\"somerealm\",nonce=\"OA6MG9tEQGm2hh\",qop=\"auth\",charset=utf-8,algorithm=md5-sess");
34 fail_if(g_hash_table_lookup(table, "realm") == NULL);
35 assert_string_equal("somerealm", g_hash_table_lookup(table, "realm"));
36 fail_if(g_hash_table_lookup(table, "nonce") == NULL);
37 assert_string_equal("OA6MG9tEQGm2hh", g_hash_table_lookup(table, "nonce"));
38 fail_if(g_hash_table_lookup(table, "qop") == NULL);
39 assert_string_equal("auth", g_hash_table_lookup(table, "qop"));
40 fail_if(g_hash_table_lookup(table, "charset") == NULL);
41 assert_string_equal("utf-8", g_hash_table_lookup(table, "charset"));
42 fail_if(g_hash_table_lookup(table, "algorithm") == NULL);
43 assert_string_equal("md5-sess", g_hash_table_lookup(table, "algorithm"));
45 g_hash_table_destroy(table);
48 END_TEST
50 Suite *
51 jabber_digest_md5_suite(void)
53 Suite *s = suite_create("Jabber SASL DIGEST-MD5 functions");
55 TCase *tc = tcase_create("Parsing Functionality");
56 tcase_add_test(tc, test_parsing);
57 suite_add_tcase(s, tc);
58 return s;