summaryrefslogtreecommitdiffstats
path: root/pigeonhole/tests/extensions/mime/content-header.svtest
blob: 9686e35443e03da6a2b6ab31ed005b73c52b1a36 (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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
require "vnd.dovecot.testsuite";
require "relational";
require "mime";

test_set "message" text:
From: stephan@example.com
To: timo@example.com
Subject: Frop
Content-Type: text/plain

Frop
.
;

test "Simple Content-Type :type" {
	if not header :mime :type "content-type" "text" {
		test_fail "wrong type extracted";
	}
}

test "Simple Content-Type :subype" {
	if not header :mime :subtype "content-type" "plain" {
		test_fail "wrong subtype extracted";
	}
}

test "Simple Content-Type :contenttype" {
	if not header :mime :contenttype "content-type" "text/plain" {
		test_fail "wrong contenttype extracted";
	}
}

test_set "message" text:
From: stephan@example.com
To: timo@example.com
Subject: Frop
Content-Type: text/calendar; method=request; charset=UTF-8;

Frop
.
;

test "Advanced Content-Type :type" {
	if not header :mime :type "content-type" "text" {
		test_fail "wrong type extracted";
	}
}

test "Advanced Content-Type :subype" {
	if not header :mime :subtype "content-type" "calendar" {
		test_fail "wrong subtype extracted";
	}
}

test "Advanced Content-Type :contenttype" {
	if not header :mime :contenttype "content-type" "text/calendar" {
		test_fail "wrong contenttype extracted";
	}
}

test "Advanced Content-Type :param" {
	if not header :mime :param "method" "content-type" "request" {
		test_fail "wrong method param extracted";
	}

	if not header :mime :param "charset" "content-type" "UTF-8" {
		test_fail "wrong charset param extracted";
	}

	if not header :mime :param ["method", "charset"]
		"content-type" "request" {
		test_fail "wrong method param extracted";
	}

	if not header :mime :param ["method", "charset"]
		"content-type" "UTF-8" {
		test_fail "wrong charset param extracted";
	}

	if not header :count "eq" :mime :param ["method", "charset"]
		"content-type" "2" {
		test_fail "wrong number of parameters";
	}
}

test_set "message" text:
From: stephan@example.com
To: timo@example.com
Subject: Frop
Content-Type: application/x-stuff;
	title*0*=us-ascii'en'This%20is%20even%20more%20;
	title*1*=%2A%2A%2Afun%2A%2A%2A%20;
	title*2="isn't it!"

Frop
.
;

test "Encoded Content-Type :param" {
	if not header :mime :param "title" "content-type"
		"This is even more ***fun*** isn't it!" {
		test_fail "wrong method param extracted";
	}
}

test_set "message" text:
From: stephan@example.com
To: timo@example.com
Subject: Frop
Content-Type: image/png
Content-Disposition: inline; filename="frop.exe"; title="Frop!"

Frop
.
;

test "Content-Disposition :type" {
	if not header :mime :type "content-disposition" "inline" {
		test_fail "wrong type extracted";
	}
}

test "Content-Disposition :subype" {
	if not header :mime :subtype "content-disposition" "" {
		test_fail "wrong subtype extracted";
	}
}

test "Content-Disposition :contenttype" {
	if not header :mime :contenttype "content-disposition" "inline" {
		test_fail "wrong contenttype extracted";
	}
}

test "Content-Disposition :param" {
	if not header :mime :param "filename" "content-disposition" "frop.exe" {
		test_fail "wrong filename param extracted";
	}

	if not header :mime :param "title" "content-disposition" "Frop!" {
		test_fail "wrong title param extracted";
	}

	if not header :mime :param ["filename", "title"]
		"content-disposition" "frop.exe" {
		test_fail "wrong filename param extracted";
	}

	if not header :mime :param ["filename", "title"]
		"content-disposition" "Frop!" {
		test_fail "wrong title param extracted";
	}

	if not header :count "eq" :mime :param ["filename", "title"]
		"content-disposition" "2" {
		test_fail "wrong number of parameters";
	}

}