gsasl-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVS gsasl/tests


From: gsasl-commit
Subject: CVS gsasl/tests
Date: Wed, 29 Sep 2004 03:45:53 +0200

Update of /home/cvs/gsasl/tests
In directory dopio:/tmp/cvs-serv19311

Modified Files:
        Makefile.am utils.c 
Added Files:
        md5file.c 
Log Message:
Add.

--- /home/cvs/gsasl/tests/Makefile.am   2004/09/26 07:19:20     1.24
+++ /home/cvs/gsasl/tests/Makefile.am   2004/09/29 01:45:53     1.25
@@ -18,6 +18,8 @@
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
+noinst_DATA = cram-md5.pwd
+
 AM_CPPFLAGS = -I$(top_builddir)/lib/src -I$(srcdir)/../gl -I../gl
 AM_LDFLAGS = -no-install
 LDADD = ../lib/src/libgsasl.la libutils.la
@@ -27,6 +29,6 @@
 
 TESTS_ENVIRONMENT = THREADSAFETY_FILES=$(top_srcdir)/lib/*/*.c
 
-TESTS = simple cram-md5 digest-md5 threadsafety
-check_PROGRAMS = simple cram-md5 digest-md5
+TESTS = simple cram-md5 digest-md5 md5file threadsafety
+check_PROGRAMS = simple cram-md5 digest-md5 md5file
 dist_check_SCRIPTS = threadsafety
--- /home/cvs/gsasl/tests/utils.c       2004/09/29 01:30:44     1.5
+++ /home/cvs/gsasl/tests/utils.c       2004/09/29 01:45:53     1.6
@@ -51,7 +51,7 @@
   va_list arg_ptr;
 
   va_start (arg_ptr, format);
-  if (verbose)
+  if (debug)
     vfprintf (stdout, format, arg_ptr);
   va_end (arg_ptr);
 }

--- /home/cvs/gsasl/tests/md5file.c     2004/09/29 01:45:54     NONE
+++ /home/cvs/gsasl/tests/md5file.c     2004/09/29 01:45:54     1.1
/* md5file.c --- Test the MD5 file password function.
 * Copyright (C) 2002, 2003, 2004  Simon Josefsson
 *
 * This file is part of GNU SASL.
 *
 * GNU SASL 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 of the License, or
 * (at your option) any later version.
 *
 * GNU SASL 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 GNU SASL; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <gsasl.h>

#include "utils.h"

/* Should match values from cram-md5.pwd. */
#define BILL "bill"
#define BILL_PASSWD "hubba-hubba"

void
doit (void)
{
  char key[BUFSIZ];
  size_t keylen = BUFSIZ - 1;
  int res;

  keylen = sizeof (key) - 1;
  res = gsasl_md5pwd_get_password ("non-existing-file", "user", key, &keylen);
  if (res == GSASL_FOPEN_ERROR)
    success ("non-existing-file OK\n");
  else
    fail ("non-existing-file FAIL (%d): %s\n", res, gsasl_strerror (res));

  keylen = sizeof (key) - 1;
  res = gsasl_md5pwd_get_password ("cram-md5.pwd", BILL, key, &keylen);
  if (res == GSASL_OK)
    success ("user-found OK\n");
  else
    fail ("user-found FAIL (%d): %s\n", res, gsasl_strerror (res));
  if (keylen != strlen (BILL_PASSWD) || memcmp (key, BILL_PASSWD, keylen) != 0)
    fail ("user-password FAIL (%d): %.*s\n", keylen, keylen, key);
  else
    success ("user-password OK\n");

  keylen = 5;
  res = gsasl_md5pwd_get_password ("cram-md5.pwd", BILL, key, &keylen);
  if (res == GSASL_TOO_SMALL_BUFFER)
    success ("too-small-buffer OK\n");
  else
    fail ("too-small-buffer FAIL (%d): %s\n", res, gsasl_strerror (res));

  keylen = sizeof (key) - 1;
  res = gsasl_md5pwd_get_password ("cram-md5.pwd", "user", key, &keylen);
  if (res == GSASL_AUTHENTICATION_ERROR)
    success ("no-such-user OK\n");
  else
    fail ("no-such-user FAIL (%d): %s\n", res, gsasl_strerror (res));
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]