~ubuntu-branches/ubuntu/maverick/opendkim/maverick

« back to all changes in this revision

Viewing changes to libopendkim/tests/t-test66.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-04-11 22:01:02 UTC
  • mfrom: (1.2.1 upstream) (3.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100411220102-jbukmeir0w7xych9
Tags: 2.0.1+dfsg-0ubuntu1
* New upstream bugfix release (fixes bug that made previous package non-
  operable with Yahoo!)
  - Remove non-free IETF drafts and RFCs and repack tarball
  - Adjust Makefile.in to not build with removed documentation
  - Set default socket to localhost port 8891 to work with Postfix and match
    Ubuntu default for dkim-filter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
**  Copyright (c) 2005-2008 Sendmail, Inc. and its suppliers.
 
3
**    All rights reserved.
 
4
**
 
5
**  Copyright (c) 2009, The OpenDKIM Project.  All rights reserved.
 
6
*/
 
7
 
 
8
#ifndef lint
 
9
static char t_test66_c_id[] = "@(#)$Id: t-test66.c,v 1.2 2009/12/08 19:14:27 cm-msk Exp $";
 
10
#endif /* !lint */
 
11
 
 
12
/* system includes */
 
13
#include <sys/types.h>
 
14
#include <assert.h>
 
15
#include <string.h>
 
16
#include <stdio.h>
 
17
 
 
18
 
 
19
/* libopendkim includes */
 
20
#include "../dkim.h"
 
21
#include "t-testdata.h"
 
22
 
 
23
#define MAXHEADER       4096
 
24
 
 
25
#define SIG2 "v=1; a=rsa-sha1; c=relaxed/simple; d=example.com; s=test;\r\n\tt=1172620939; bh=ll/0h2aWgG+D3ewmE4Y3pY7Ukz8=; h=Received:Received:\r\n\t Received:From:To:Date:Subject:Message-ID; b=bj9kVUbnBYfe9sVzH9lT45\r\n\tTFKO3eQnDbXLfgmgu/b5QgxcnhT9ojnV2IAM4KUO8+hOo5sDEu5Co/0GASH0vHpSV4P\r\n\t377Iwew3FxvLpHsVbVKgXzoKD4QSbHRpWNxyL6LypaaqFa96YqjXuYXr0vpb88hticn\r\n\t6I16//WThMz8fMU="
 
26
 
 
27
/*
 
28
**  MAIN -- program mainline
 
29
**
 
30
**  Parameters:
 
31
**      The usual.
 
32
**
 
33
**  Return value:
 
34
**      Exit status.
 
35
*/
 
36
 
 
37
int
 
38
main(int argc, char **argv)
 
39
{
 
40
#ifdef TEST_KEEP_FILES
 
41
        u_int flags;
 
42
#endif /* TEST_KEEP_FILES */
 
43
        DKIM_STAT status;
 
44
        DKIM *dkim;
 
45
        DKIM_LIB *lib;
 
46
        dkim_query_t qtype = DKIM_QUERY_FILE;
 
47
        unsigned char hdr[MAXHEADER + 1];
 
48
 
 
49
        printf("*** relaxed/simple rsa-sha1 verifying with bogus From:\n");
 
50
 
 
51
        /* instantiate the library */
 
52
        lib = dkim_init(NULL, NULL);
 
53
        assert(lib != NULL);
 
54
 
 
55
#ifdef TEST_KEEP_FILES
 
56
        /* set flags */
 
57
        flags = (DKIM_LIBFLAGS_TMPFILES|DKIM_LIBFLAGS_KEEPFILES);
 
58
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_FLAGS, &flags,
 
59
                            sizeof flags);
 
60
#endif /* TEST_KEEP_FILES */
 
61
 
 
62
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYMETHOD,
 
63
                            &qtype, sizeof qtype);
 
64
        (void) dkim_options(lib, DKIM_OP_SETOPT, DKIM_OPTS_QUERYINFO,
 
65
                            KEYFILE, strlen(KEYFILE));
 
66
 
 
67
        dkim = dkim_verify(lib, JOBID, NULL, &status);
 
68
        assert(dkim != NULL);
 
69
 
 
70
        snprintf(hdr, sizeof hdr, "%s: %s", DKIM_SIGNHEADER, SIG2);
 
71
        status = dkim_header(dkim, hdr, strlen(hdr));
 
72
        assert(status == DKIM_STAT_OK);
 
73
 
 
74
        status = dkim_header(dkim, HEADER01, strlen(HEADER01));
 
75
        assert(status == DKIM_STAT_OK);
 
76
 
 
77
        status = dkim_header(dkim, HEADER02, strlen(HEADER02));
 
78
        assert(status == DKIM_STAT_OK);
 
79
 
 
80
        status = dkim_header(dkim, HEADER03, strlen(HEADER03));
 
81
        assert(status == DKIM_STAT_OK);
 
82
 
 
83
        status = dkim_header(dkim, HEADER04, strlen(HEADER04));
 
84
        assert(status == DKIM_STAT_OK);
 
85
 
 
86
#define ALTHEADER05     "From: Murray"
 
87
        status = dkim_header(dkim, ALTHEADER05, strlen(ALTHEADER05));
 
88
        assert(status == DKIM_STAT_OK);
 
89
 
 
90
        status = dkim_header(dkim, HEADER06, strlen(HEADER06));
 
91
        assert(status == DKIM_STAT_OK);
 
92
 
 
93
        status = dkim_header(dkim, HEADER07, strlen(HEADER07));
 
94
        assert(status == DKIM_STAT_OK);
 
95
 
 
96
        status = dkim_header(dkim, HEADER08, strlen(HEADER08));
 
97
        assert(status == DKIM_STAT_OK);
 
98
 
 
99
        status = dkim_header(dkim, HEADER09, strlen(HEADER09));
 
100
        assert(status == DKIM_STAT_OK);
 
101
 
 
102
        status = dkim_eoh(dkim);
 
103
        assert(status == DKIM_STAT_SYNTAX);
 
104
 
 
105
        status = dkim_body(dkim, BODY00, strlen(BODY00));
 
106
        assert(status == DKIM_STAT_INVALID);
 
107
 
 
108
        status = dkim_eom(dkim, NULL);
 
109
        assert(status == DKIM_STAT_INVALID);
 
110
 
 
111
        status = dkim_free(dkim);
 
112
        assert(status == DKIM_STAT_OK);
 
113
 
 
114
        dkim_close(lib);
 
115
 
 
116
        return 0;
 
117
}