Sync upstream.
[shishi.git] / tests / gss.c
blob893ee5d6014c4a422d31f3f6b3513be768e76fe7
1 /* gss.c Shishi GSS-API self tests.
2 * Copyright (C) 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Shishi 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "utils.c"
23 #include <shishi/gssapi.h>
25 int
26 main (int argc, char *argv[])
28 char buffer[BUFSIZ];
29 char buffer2[BUFSIZ];
30 char *p, *q;
31 int n, res;
32 gss_uint32 maj_stat, min_stat;
33 gss_buffer_desc bufdesc, bufdesc2;
34 gss_name_t service;
37 if (strcmp (argv[argc - 1], "-v") == 0 ||
38 strcmp (argv[argc - 1], "--verbose") == 0)
39 verbose = 1;
40 else if (strcmp (argv[argc - 1], "-d") == 0 ||
41 strcmp (argv[argc - 1], "--debug") == 0)
42 debug = 1;
43 else if (strcmp (argv[argc - 1], "-b") == 0 ||
44 strcmp (argv[argc - 1], "--break-on-error") == 0)
45 break_on_error = 1;
46 else if (strcmp (argv[argc - 1], "-h") == 0 ||
47 strcmp (argv[argc - 1], "-?") == 0 ||
48 strcmp (argv[argc - 1], "--help") == 0)
50 printf ("Usage: %s [-vdbh?] [--verbose] [--debug] "
51 "[--break-on-error] [--help]\n", argv[0]);
52 return 1;
54 while (argc-- > 1);
56 escapeprint (NULL, 0);
57 hexprint (NULL, 0);
58 binprint (NULL, 0);
60 service = NULL;
61 bufdesc.value = "imap@server.example.org@FOO";
62 bufdesc.length = strlen(bufdesc.value);
64 maj_stat = gss_import_name (&min_stat, &bufdesc, GSS_C_NT_HOSTBASED_SERVICE,
65 &service);
66 if (maj_stat == GSS_S_COMPLETE)
67 success("gss_import_name() OK\n");
68 else
69 fail("gss_import_name() failed (%d,%d)\n", maj_stat, min_stat);
71 maj_stat = gss_display_name (&min_stat, service, &bufdesc2, NULL);
72 if (maj_stat == GSS_S_COMPLETE)
73 success("gss_display_name() OK\n");
74 else
75 fail("gss_display_name() failed (%d,%d)\n", maj_stat, min_stat);
77 if (debug)
78 printf("display_name() => %d: %s\n", bufdesc2.length, bufdesc2.value);
80 if (verbose)
81 printf ("Ticket set self tests done with %d errors\n", error_count);
83 return error_count ? 1 : 0;