diff options
author | neel <neel@FreeBSD.org> | 2012-11-13 07:39:05 +0000 |
---|---|---|
committer | neel <neel@FreeBSD.org> | 2012-11-13 07:39:05 +0000 |
commit | 1a164db277254c1198a5923050a4e403737937c3 (patch) | |
tree | 96b9ec5962272d9c843abffb6d4db9b66e04efd3 /lib/libcrypt/tests/crypt_tests.c | |
parent | f146c1921cfde17a6716187a95a05c21f5e46b94 (diff) | |
parent | a841c9341b2afeabcf32a11c8bd91bbe3346177a (diff) | |
download | FreeBSD-src-1a164db277254c1198a5923050a4e403737937c3.zip FreeBSD-src-1a164db277254c1198a5923050a4e403737937c3.tar.gz |
IFC @ r242940
Diffstat (limited to 'lib/libcrypt/tests/crypt_tests.c')
-rw-r--r-- | lib/libcrypt/tests/crypt_tests.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/libcrypt/tests/crypt_tests.c b/lib/libcrypt/tests/crypt_tests.c new file mode 100644 index 0000000..3331d12 --- /dev/null +++ b/lib/libcrypt/tests/crypt_tests.c @@ -0,0 +1,54 @@ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <crypt.h> +#include <unistd.h> + +#include <atf-c.h> + +#define LEET "0.s0.l33t" + +ATF_TC(md5); +ATF_TC_HEAD(md5, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Tests the MD5 based password hash"); +} + +ATF_TC_BODY(md5, tc) +{ + const char want[] = "$1$deadbeef$0Huu6KHrKLVWfqa4WljDE0"; + char *pw; + + pw = crypt(LEET, want); + ATF_CHECK_STREQ(pw, want); +} + +ATF_TC(invalid); +ATF_TC_HEAD(invalid, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Tests that invalid password fails"); +} + +ATF_TC_BODY(invalid, tc) +{ + const char want[] = "$1$cafebabe$0Huu6KHrKLVWfqa4WljDE0"; + char *pw; + + pw = crypt(LEET, want); + ATF_CHECK(strcmp(pw, want) != 0); +} + +/* + * This function must not do anything except enumerate + * the test cases, else atf-run is likely to be upset. + */ +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, md5); + ATF_TP_ADD_TC(tp, invalid); + return atf_no_error(); +} |