1 | #include <stdlib.h> |
---|
2 | #include <glib.h> |
---|
3 | #include <gmodule.h> |
---|
4 | #include <check.h> |
---|
5 | #include <string.h> |
---|
6 | #include "bitlbee.h" |
---|
7 | #include "crypting.h" |
---|
8 | #include "testsuite.h" |
---|
9 | |
---|
10 | START_TEST(test_check_pass_valid) |
---|
11 | fail_unless (checkpass ("foo", "acbd18db4cc2f85cedef654fccc4a4d8") == 0); |
---|
12 | fail_unless (checkpass ("invalidpass", "acbd18db4cc2f85cedef654fccc4a4d8") == -1); |
---|
13 | |
---|
14 | END_TEST |
---|
15 | |
---|
16 | START_TEST(test_hashpass) |
---|
17 | fail_unless (strcmp(hashpass("foo"), "acbd18db4cc2f85cedef654fccc4a4d8") == 0); |
---|
18 | END_TEST |
---|
19 | |
---|
20 | START_TEST(test_obfucrypt) |
---|
21 | char *raw = obfucrypt("some line", "bla"); |
---|
22 | fail_unless(strcmp(raw, "\xd5\xdb\xce\xc7\x8c\xcd\xcb\xda\xc6") == 0); |
---|
23 | END_TEST |
---|
24 | |
---|
25 | START_TEST(test_deobfucrypt) |
---|
26 | char *raw = deobfucrypt("\xd5\xdb\xce\xc7\x8c\xcd\xcb\xda\xc6", "bla"); |
---|
27 | fail_unless(strcmp(raw, "some line") == 0); |
---|
28 | END_TEST |
---|
29 | |
---|
30 | START_TEST(test_obfucrypt_bidirectional) |
---|
31 | char *plain = g_strdup("this is a line"); |
---|
32 | char *raw = obfucrypt(plain, "foo"); |
---|
33 | fail_unless(strcmp(plain, deobfucrypt(raw, "foo")) == 0); |
---|
34 | END_TEST |
---|
35 | |
---|
36 | Suite *crypting_suite (void) |
---|
37 | { |
---|
38 | Suite *s = suite_create("Crypting"); |
---|
39 | TCase *tc_core = tcase_create("Core"); |
---|
40 | suite_add_tcase (s, tc_core); |
---|
41 | tcase_add_test (tc_core, test_check_pass_valid); |
---|
42 | tcase_add_test (tc_core, test_hashpass); |
---|
43 | tcase_add_test (tc_core, test_obfucrypt); |
---|
44 | tcase_add_test (tc_core, test_deobfucrypt); |
---|
45 | tcase_add_test (tc_core, test_obfucrypt_bidirectional); |
---|
46 | return s; |
---|
47 | } |
---|