[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS gsasl/tests
From: |
gsasl-commit |
Subject: |
CVS gsasl/tests |
Date: |
Mon, 20 Dec 2004 02:14:39 +0100 |
Update of /home/cvs/gsasl/tests
In directory dopio:/tmp/cvs-serv4288/tests
Modified Files:
Makefile.am md5file.c
Added Files:
old-md5file.c
Log Message:
Replace gsasl_md5pwd_get_password with gsasl_simple_getpass, and update callers.
--- /home/cvs/gsasl/tests/Makefile.am 2004/12/20 01:12:56 1.36
+++ /home/cvs/gsasl/tests/Makefile.am 2004/12/20 01:14:38 1.37
@@ -36,10 +36,10 @@
THREADSAFETY_FILES=$(top_srcdir)/lib/*/*.c \
MD5FILE=$(srcdir)/cram-md5.pwd
-ctests = cram-md5 digest-md5
+ctests = cram-md5 digest-md5 md5file
if OBSOLETE
-ctests += simple md5file old-cram-md5 old-digest-md5
+ctests += simple old-md5file old-cram-md5 old-digest-md5
endif
# old-gssapi
--- /home/cvs/gsasl/tests/md5file.c 2004/11/07 18:00:58 1.3
+++ /home/cvs/gsasl/tests/md5file.c 2004/12/20 01:14:38 1.4
@@ -39,8 +39,7 @@
doit (void)
{
char *md5file;
- char key[BUFSIZ];
- size_t keylen = BUFSIZ - 1;
+ char *key;
int res;
md5file = getenv ("MD5FILE");
@@ -54,34 +53,25 @@
if (!md5file)
md5file = "cram-md5.pwd";
- keylen = sizeof (key) - 1;
- res = gsasl_md5pwd_get_password ("non-existing-file", "user", key, &keylen);
- if (res == GSASL_FOPEN_ERROR)
+ res = gsasl_simple_getpass ("non-existing-file", "user", &key);
+ if (res == GSASL_AUTHENTICATION_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 (md5file, BILL, key, &keylen);
+ res = gsasl_simple_getpass (md5file, BILL, &key);
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);
+ if (strcmp (key, BILL_PASSWD) != 0)
+ fail ("user-password FAIL: %s\n", key);
else
success ("user-password OK\n");
+ if (res == GSASL_OK)
+ free (key);
- keylen = 5;
- res = gsasl_md5pwd_get_password (md5file, 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 (md5file, "user", key, &keylen);
+ res = gsasl_simple_getpass (md5file, "user", &key);
if (res == GSASL_AUTHENTICATION_ERROR)
success ("no-such-user OK\n");
else
--- /home/cvs/gsasl/tests/old-md5file.c 2004/12/20 01:14:39 NONE
+++ /home/cvs/gsasl/tests/old-md5file.c 2004/12/20 01:14:39 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 *md5file;
char key[BUFSIZ];
size_t keylen = BUFSIZ - 1;
int res;
md5file = getenv ("MD5FILE");
if (md5file)
{
char *p;
if ((p = strchr (md5file, '=')))
md5file = p;
}
if (!md5file)
md5file = "cram-md5.pwd";
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 (md5file, 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 (md5file, 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 (md5file, "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));
}
- CVS gsasl/tests, gsasl-commit, 2004/12/14
- CVS gsasl/tests, gsasl-commit, 2004/12/14
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests,
gsasl-commit <=
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests, gsasl-commit, 2004/12/19
- CVS gsasl/tests, gsasl-commit, 2004/12/26