blob: 510a52b7d89d2d2c39bf5963d7c1044cd2ec829b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
require "vnd.dovecot.testsuite";
require "foreverypart";
require "variables";
require "extracttext";
test_set "message" text:
From: Hendrik <hendrik@example.com>
To: Harrie <harrie@example.com>
Date: Sat, 11 Oct 2010 00:31:44 +0200
Subject: Harrie is een prutser
Content-Type: multipart/mixed; boundary=AA
This is a multi-part message in MIME format.
--AA
Content-Type: multipart/mixed; boundary=BB
This is a multi-part message in MIME format.
--BB
Content-Type: text/plain; charset="us-ascii"
This is the first message part containing
plain text.
--BB
Content-Type: text/plain; charset="us-ascii"
This is another plain text message part.
--BB--
This is the end of MIME multipart.
--AA
Content-Type: text/html; charset="us-ascii"
<html>
<body>This is a piece of HTML text.</body>
</html>
--AA--
This is the end of MIME multipart.
.
;
test "Basic" {
set "a" "a";
foreverypart {
extracttext "b";
if string "${a}" "aaa" {
if not string :contains "${b}" "first" {
test_fail "bad content extracted: ${b}";
}
} elsif string "${a}" "aaaa" {
if not string :contains "${b}" "another" {
test_fail "bad content extracted: ${b}";
}
} elsif string "${a}" "aaaaa" {
if not string :contains "${b}" "HTML text" {
test_fail "bad content extracted: ${b}";
}
if string :contains "${b}" "<html>" {
test_fail "content extracted html: ${b}";
}
}
set "a" "a${a}";
}
if not string "${a}" "aaaaaa" {
set :length "parts" "${a}";
test_fail "bad number of parts parsed: ${parts}";
}
}
test_set "message" text:
From: <stephan@example.com>
To: <frop@example.com>
Subject: Frop!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP! FROP!
.
;
test "First - less" {
foreverypart {
extracttext :first 20 "data";
if not string "${data}" "FROP! FROP! FROP! FR" {
test_fail "Bad data extracted";
}
extracttext :length :first 100 "data_len";
if not string "${data_len}" "100" {
test_fail "Bad number of bytes extracted";
}
}
}
test_set "message" text:
From: <stephan@example.com>
To: <frop@example.com>
Subject: Frop!
FROP! FROP! FROP! FROP!
.
;
test "First - more" {
foreverypart {
extracttext :first 100 "data";
if not string :matches "${data}" "FROP! FROP! FROP! FROP!*" {
test_fail "Bad data extracted";
}
}
}
test_set "message" text:
From: <stephan@example.com>
To: <frop@example.com>
Subject: Frop!
FROP! FROP! FROP! FROP!
.
;
test "Modifier" {
foreverypart {
extracttext :lower :upperfirst "data";
if not string :matches "${data}" "Frop! frop! frop! frop!*" {
test_fail "Bad data extracted";
}
}
}
|