From: Adam Dickmeiss Date: Wed, 11 Oct 2006 20:19:31 +0000 (+0000) Subject: Added tstpass test X-Git-Tag: ZEBRA.2.0.6~92 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=736d28749cda5e336fbdd7751e55be385d2db7d4;p=idzebra-moved-to-github.git Added tstpass test --- diff --git a/util/Makefile.am b/util/Makefile.am index f8d7b15..0af7186 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -1,16 +1,14 @@ -## $Id: Makefile.am,v 1.26 2006-08-14 12:18:50 adam Exp $ +## $Id: Makefile.am,v 1.27 2006-10-11 20:19:31 adam Exp $ noinst_LTLIBRARIES = libidzebra-util.la -noinst_PROGRAMS = passtest - -check_PROGRAMS = tstcharmap tstflock tstlockscope +check_PROGRAMS = tstcharmap tstflock tstlockscope tstpass TESTS = $(check_PROGRAMS) bin_SCRIPTS = idzebra-config-2.0 -EXTRA_DIST = zebrasrv.rh tstcharmap.chr +EXTRA_DIST = zebrasrv.rh tstcharmap.chr tstpass.txt DISTCLEANFILES = idzebra-config-2.0 @@ -20,7 +18,7 @@ LDADD = libidzebra-util.la $(YAZLALIB) libidzebra_util_la_SOURCES = zint.c res.c charmap.c zebramap.c passwddb.c \ zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c attrfind.c -passtest_SOURCES = passtest.c +tstpass_SOURCES = tstpass.c tstcharmap_SOURCES = tstcharmap.c diff --git a/util/passtest.c b/util/passtest.c deleted file mode 100644 index 6a36a0f..0000000 --- a/util/passtest.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $Id: passtest.c,v 1.8 2006-08-14 10:40:34 adam Exp $ - Copyright (C) 1995-2006 - Index Data ApS - -This file is part of the Zebra server. - -Zebra is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free -Software Foundation; either version 2, or (at your option) any later -version. - -Zebra is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - - -#include - -int main (int argc, char **argv) -{ - Passwd_db db; - - db = passwd_db_open(); - - passwd_db_file_plain(db, "/etc/passwd"); - passwd_db_auth(db, "adam", "xtx9Y="); - passwd_db_close(db); - return 0; -} -/* - * Local variables: - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - * vim: shiftwidth=4 tabstop=8 expandtab - */ - diff --git a/util/tstpass.c b/util/tstpass.c new file mode 100644 index 0000000..f599071 --- /dev/null +++ b/util/tstpass.c @@ -0,0 +1,63 @@ +/* $Id: tstpass.c,v 1.1 2006-10-11 20:19:31 adam Exp $ + Copyright (C) 1995-2006 + Index Data ApS + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +#include +#include + +static void tst(void) +{ + Passwd_db db; + + db = passwd_db_open(); + YAZ_CHECK(db); + if (!db) + return; + + YAZ_CHECK_EQ(passwd_db_file_plain(db, "no_such_file.txt"), -1); + YAZ_CHECK_EQ(passwd_db_file_crypt(db, "no_such_file.txt"), -1); +#if HAVE_CRYPT_H + YAZ_CHECK_EQ(passwd_db_file_crypt(db, "tstpass.txt"), 0); + YAZ_CHECK_EQ(passwd_db_auth(db, "other", "x1234"), -1); + YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "abcd"), -2); + YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "fruitbat"), 0); + YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "fruitbatx"), -2); + YAZ_CHECK_EQ(passwd_db_auth(db, "admin", "fruitba"), -2); +#else + YAZ_CHECK_EQ(passwd_db_file_plain(db, "passtest.txt"), -1); +#endif + passwd_db_close(db); +} + +int main (int argc, char **argv) +{ + YAZ_CHECK_INIT(argc, argv); + tst(); + YAZ_CHECK_TERM; +} +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/util/tstpass.txt b/util/tstpass.txt new file mode 100644 index 0000000..ebeaaa2 --- /dev/null +++ b/util/tstpass.txt @@ -0,0 +1,2 @@ +admin:7UpqGgE7qp7nY +adam:$apr1$zkQS9/..$0XJOWp9OnxwefzDdbaTfw/