Back to index

opendkim  2.6.6
t-test58.c
Go to the documentation of this file.
00001 /*
00002 **  Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers.
00003 **    All rights reserved.
00004 **
00005 **  Copyright (c) 2009, 2011, The OpenDKIM Project.  All rights reserved.
00006 */
00007 
00008 #ifndef lint
00009 static char t_test58_c_id[] = "@(#)$Id: t-test58.c,v 1.2 2009/12/08 19:14:27 cm-msk Exp $";
00010 #endif /* !lint */
00011 
00012 #include "build-config.h"
00013 
00014 /* system includes */
00015 #include <sys/types.h>
00016 #include <assert.h>
00017 #include <string.h>
00018 #include <stdio.h>
00019 
00020 #ifdef USE_GNUTLS
00021 # include <gnutls/gnutls.h>
00022 #endif /* USE_GNUTLS */
00023 
00024 /* libopendkim includes */
00025 #include "../dkim.h"
00026 #include "t-testdata.h"
00027 
00028 #define       MAXHEADER     4096
00029 
00030 #define BADHEADER05  "From: msk-at-opendkim.org"
00031 
00032 /*
00033 **  MAIN -- program mainline
00034 **
00035 **  Parameters:
00036 **     The usual.
00037 **
00038 **  Return value:
00039 **     Exit status.
00040 */
00041 
00042 int
00043 main(int argc, char **argv)
00044 {
00045 #ifdef TEST_KEEP_FILES
00046        u_int flags;
00047 #endif /* TEST_KEEP_FILES */
00048        DKIM_STAT status;
00049        DKIM *dkim;
00050        DKIM_LIB *lib;
00051        dkim_query_t qtype = DKIM_QUERY_FILE;
00052 
00053        printf("*** verifying malformed message\n");
00054 
00055 #ifdef USE_GNUTLS
00056        (void) gnutls_global_init();
00057 #endif /* USE_GNUTLS */
00058 
00059        /* instantiate the library */
00060        lib = dkim_init(NULL, NULL);
00061        assert(lib != NULL);
00062 
00063 #ifdef TEST_KEEP_FILES
00064        /* set flags */
00065        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
00066        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
00067                            sizeof flags);
00068 #endif /* TEST_KEEP_FILES */
00069 
00070        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
00071                            &qtype, sizeof qtype);
00072        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
00073                            KEYFILE, strlen(KEYFILE));
00074 
00075        dkim = dkim_verify(lib, JOBID, NULL, &status);
00076        assert(dkim != NULL);
00077 
00078        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
00079        assert(status == DKIM_STAT_OK);
00080 
00081        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
00082        assert(status == DKIM_STAT_OK);
00083 
00084        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
00085        assert(status == DKIM_STAT_OK);
00086 
00087        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
00088        assert(status == DKIM_STAT_OK);
00089 
00090        status = dkim_header(dkim, BADHEADER05, strlen(BADHEADER05));
00091        assert(status == DKIM_STAT_OK);
00092 
00093        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
00094        assert(status == DKIM_STAT_OK);
00095 
00096        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
00097        assert(status == DKIM_STAT_OK);
00098 
00099        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
00100        assert(status == DKIM_STAT_OK);
00101 
00102        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
00103        assert(status == DKIM_STAT_OK);
00104 
00105        status = dkim_eoh(dkim);
00106        assert(status == DKIM_STAT_SYNTAX);
00107 
00108        status = dkim_free(dkim);
00109        assert(status == DKIM_STAT_OK);
00110 
00111        dkim_close(lib);
00112 
00113        return 0;
00114 }