Remove.
[gsasl.git] / tests / md5file.c
blob3952d7a7da511441b998dd3bf62769c4816b2206
1 /* md5file.c --- Test the MD5 file password function.
2 * Copyright (C) 2002, 2003, 2004 Simon Josefsson
4 * This file is part of GNU SASL.
6 * GNU SASL is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * GNU SASL is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU SASL; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #ifdef HAVE_CONFIG_H
23 # include "config.h"
24 #endif
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <gsasl.h>
32 #include "utils.h"
34 /* Should match values from cram-md5.pwd. */
35 #define BILL "bill"
36 #define BILL_PASSWD "hubba-hubba"
38 void
39 doit (void)
41 char *md5file;
42 char *key;
43 int res;
45 md5file = getenv ("MD5FILE");
46 if (md5file)
48 char *p;
49 if ((p = strchr (md5file, '=')))
50 md5file = p;
53 if (!md5file)
54 md5file = "cram-md5.pwd";
56 res = gsasl_simple_getpass ("non-existing-file", "user", &key);
57 if (res == GSASL_AUTHENTICATION_ERROR)
58 success ("non-existing-file OK\n");
59 else
60 fail ("non-existing-file FAIL (%d): %s\n", res, gsasl_strerror (res));
62 res = gsasl_simple_getpass (md5file, BILL, &key);
63 if (res == GSASL_OK)
64 success ("user-found OK\n");
65 else
66 fail ("user-found FAIL (%d): %s\n", res, gsasl_strerror (res));
67 if (strcmp (key, BILL_PASSWD) != 0)
68 fail ("user-password FAIL: %s\n", key);
69 else
70 success ("user-password OK\n");
71 if (res == GSASL_OK)
72 free (key);
74 res = gsasl_simple_getpass (md5file, "user", &key);
75 if (res == GSASL_AUTHENTICATION_ERROR)
76 success ("no-such-user OK\n");
77 else
78 fail ("no-such-user FAIL (%d): %s\n", res, gsasl_strerror (res));