source: tests/check_crypting.c @ 0cab388

Last change on this file since 0cab388 was 8c073a6, checked in by Jelmer Vernooij <jelmer@…>, at 2007-01-21T21:38:50Z

Add testsuite for crypting.

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[8c073a6]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
10START_TEST(test_check_pass_valid)
11        fail_unless (checkpass ("foo", "acbd18db4cc2f85cedef654fccc4a4d8") == 0);
12        fail_unless (checkpass ("invalidpass", "acbd18db4cc2f85cedef654fccc4a4d8") == -1);
13
14END_TEST
15
16START_TEST(test_hashpass)
17        fail_unless (strcmp(hashpass("foo"), "acbd18db4cc2f85cedef654fccc4a4d8") == 0);
18END_TEST
19
20START_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);
23END_TEST
24
25START_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);
28END_TEST
29
30START_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);
34END_TEST
35
36Suite *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}
Note: See TracBrowser for help on using the repository browser.