| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::SMTP; |
|
2
|
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
101919
|
use strict; |
|
|
9
|
|
|
|
|
11
|
|
|
|
9
|
|
|
|
|
194
|
|
|
4
|
9
|
|
|
9
|
|
25
|
use warnings; |
|
|
9
|
|
|
|
|
10
|
|
|
|
9
|
|
|
|
|
299
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
|
7
|
|
|
|
|
|
|
# ABSTRACT: Module for writing SMTP Server tests |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
BEGIN { |
|
10
|
9
|
|
|
9
|
|
33
|
use Exporter (); |
|
|
9
|
|
|
|
|
11
|
|
|
|
9
|
|
|
|
|
101
|
|
|
11
|
9
|
|
|
9
|
|
25
|
use Carp; |
|
|
9
|
|
|
|
|
7
|
|
|
|
9
|
|
|
|
|
472
|
|
|
12
|
9
|
|
|
9
|
|
3331
|
use Net::SMTP_auth; |
|
|
9
|
|
|
|
|
631403
|
|
|
|
9
|
|
|
|
|
399
|
|
|
13
|
9
|
|
|
9
|
|
2636
|
use Test::Builder::Module; |
|
|
9
|
|
|
|
|
52500
|
|
|
|
9
|
|
|
|
|
47
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
9
|
|
|
9
|
|
245
|
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
|
9
|
|
|
|
|
10
|
|
|
|
9
|
|
|
|
|
620
|
|
|
16
|
9
|
|
|
9
|
|
144
|
@ISA = qw(Net::SMTP_auth Test::Builder::Module); |
|
17
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
|
18
|
9
|
|
|
|
|
13
|
@EXPORT = qw(); |
|
19
|
9
|
|
|
|
|
15
|
@EXPORT_OK = qw(plan); |
|
20
|
9
|
|
|
|
|
17589
|
%EXPORT_TAGS = (); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub plan { |
|
25
|
1
|
|
|
1
|
1
|
46
|
my $tb = __PACKAGE__->builder; |
|
26
|
1
|
|
|
|
|
27
|
$tb->plan(@_); |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub connect_ok { |
|
31
|
6
|
|
|
6
|
1
|
2004859
|
my ($class, $name, %params) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
6
|
100
|
100
|
|
|
113
|
if ((not defined($params{'AutoHello'})) or ($params{'AutoHello'} != 1)){ |
|
34
|
2
|
|
|
|
|
20
|
croak "Can only handle AutoHello for now..."; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
4
|
|
|
|
|
131
|
my $smtp = Net::SMTP_auth->new(%params); |
|
38
|
|
|
|
|
|
|
|
|
39
|
4
|
|
|
|
|
150097
|
my $tb = __PACKAGE__->builder(); |
|
40
|
4
|
|
|
|
|
87
|
$tb->ok(defined $smtp, $name); |
|
41
|
|
|
|
|
|
|
|
|
42
|
4
|
100
|
|
|
|
1559
|
if (not defined($smtp)){ |
|
43
|
1
|
|
|
|
|
5
|
return; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
3
|
|
|
|
|
13
|
bless $smtp, $class; |
|
47
|
3
|
|
|
|
|
19
|
return $smtp; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub connect_ko { |
|
52
|
3
|
|
|
3
|
1
|
433
|
my ($class, $name, @params) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
3
|
|
|
|
|
27
|
my $smtp = Net::SMTP_auth->new(@params); |
|
55
|
3
|
|
|
|
|
188819
|
my $tb = __PACKAGE__->builder(); |
|
56
|
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
46
|
$tb->ok(not(defined $smtp), $name); |
|
58
|
|
|
|
|
|
|
|
|
59
|
3
|
100
|
|
|
|
1067
|
if (not defined $smtp){ |
|
60
|
2
|
|
|
|
|
30
|
return; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
2
|
bless $smtp, $class; |
|
64
|
1
|
|
|
|
|
5
|
return $smtp; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub code_is { |
|
70
|
6
|
|
|
6
|
1
|
1154
|
my ($self, $expected, $name) = @_; |
|
71
|
6
|
|
|
|
|
21
|
my $tb = __PACKAGE__->builder(); |
|
72
|
|
|
|
|
|
|
|
|
73
|
6
|
|
|
|
|
66
|
$tb->cmp_ok($self->code(), '==', $expected, $name); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub code_isnt { |
|
78
|
6
|
|
|
6
|
1
|
2038
|
my ($self, $expected, $name) = @_; |
|
79
|
6
|
|
|
|
|
21
|
my $tb = __PACKAGE__->builder(); |
|
80
|
|
|
|
|
|
|
|
|
81
|
6
|
|
|
|
|
51
|
$tb->cmp_ok($self->code(), '!=', $expected, $name); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub code_is_success { |
|
86
|
4
|
|
|
4
|
1
|
745
|
my ($self, $name) = @_; |
|
87
|
4
|
|
|
|
|
14
|
my $tb = __PACKAGE__->builder(); |
|
88
|
|
|
|
|
|
|
|
|
89
|
4
|
100
|
|
|
|
29
|
if (_is_between($self->code(), 200, 399)){ |
|
90
|
2
|
|
|
|
|
8
|
$tb->ok(1, $name); |
|
91
|
|
|
|
|
|
|
} else { |
|
92
|
2
|
|
|
|
|
4
|
$tb->ok(0, $name); |
|
93
|
2
|
|
|
|
|
650
|
$self->_smtp_diag; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub code_isnt_success { |
|
99
|
5
|
|
|
5
|
1
|
1128
|
my ($self, $name) = @_; |
|
100
|
5
|
|
|
|
|
16
|
my $tb = __PACKAGE__->builder(); |
|
101
|
|
|
|
|
|
|
|
|
102
|
5
|
100
|
|
|
|
52
|
if (_is_between($self->code(), 200, 399)){ |
|
103
|
1
|
|
|
|
|
3
|
$tb->ok(0, $name); |
|
104
|
1
|
|
|
|
|
349
|
$self->_smtp_diag; |
|
105
|
|
|
|
|
|
|
} else { |
|
106
|
4
|
|
|
|
|
13
|
$tb->ok(1, $name); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub code_is_failure { |
|
112
|
5
|
|
|
5
|
1
|
1099
|
my ($self, $name) = @_; |
|
113
|
5
|
|
|
|
|
15
|
my $tb = __PACKAGE__->builder(); |
|
114
|
|
|
|
|
|
|
|
|
115
|
5
|
100
|
|
|
|
46
|
if (not _is_between($self->code(), 200, 399)){ |
|
116
|
4
|
|
|
|
|
12
|
$tb->ok(1, $name); |
|
117
|
|
|
|
|
|
|
} else { |
|
118
|
1
|
|
|
|
|
3
|
$tb->ok(0, $name); |
|
119
|
1
|
|
|
|
|
323
|
$self->_smtp_diag; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub code_isnt_failure { |
|
125
|
4
|
|
|
4
|
1
|
711
|
my ($self, $name) = @_; |
|
126
|
4
|
|
|
|
|
14
|
my $tb = __PACKAGE__->builder(); |
|
127
|
|
|
|
|
|
|
|
|
128
|
4
|
100
|
|
|
|
31
|
if (not _is_between($self->code(), 200, 399)){ |
|
129
|
2
|
|
|
|
|
6
|
$tb->ok(0, $name); |
|
130
|
2
|
|
|
|
|
663
|
$self->_smtp_diag; |
|
131
|
|
|
|
|
|
|
} else { |
|
132
|
2
|
|
|
|
|
7
|
$tb->ok(1, $name); |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub code_is_temporary { |
|
138
|
4
|
|
|
4
|
1
|
862
|
my ($self, $name) = @_; |
|
139
|
4
|
|
|
|
|
15
|
my $tb = __PACKAGE__->builder(); |
|
140
|
|
|
|
|
|
|
|
|
141
|
4
|
100
|
|
|
|
29
|
if (_is_between($self->code(), 400, 499)){ |
|
142
|
2
|
|
|
|
|
7
|
$tb->ok(1, $name); |
|
143
|
|
|
|
|
|
|
} else { |
|
144
|
2
|
|
|
|
|
6
|
$tb->ok(0, $name); |
|
145
|
2
|
|
|
|
|
674
|
$self->_smtp_diag; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub code_isnt_temporary { |
|
151
|
5
|
|
|
5
|
1
|
1430
|
my ($self, $name) = @_; |
|
152
|
5
|
|
|
|
|
16
|
my $tb = __PACKAGE__->builder(); |
|
153
|
|
|
|
|
|
|
|
|
154
|
5
|
100
|
|
|
|
40
|
if (_is_between($self->code(), 400, 499)){ |
|
155
|
1
|
|
|
|
|
3
|
$tb->ok(0, $name); |
|
156
|
1
|
|
|
|
|
327
|
$self->_smtp_diag; |
|
157
|
|
|
|
|
|
|
} else { |
|
158
|
4
|
|
|
|
|
12
|
$tb->ok(1, $name); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub code_is_permanent { |
|
164
|
4
|
|
|
4
|
1
|
722
|
my ($self, $name) = @_; |
|
165
|
4
|
|
|
|
|
15
|
my $tb = __PACKAGE__->builder(); |
|
166
|
|
|
|
|
|
|
|
|
167
|
4
|
100
|
|
|
|
30
|
if (_is_between($self->code(), 500, 599)){ |
|
168
|
2
|
|
|
|
|
5
|
$tb->ok(1, $name); |
|
169
|
|
|
|
|
|
|
} else { |
|
170
|
2
|
|
|
|
|
5
|
$tb->ok(0, $name); |
|
171
|
2
|
|
|
|
|
682
|
$self->_smtp_diag; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub code_isnt_permanent { |
|
177
|
5
|
|
|
5
|
1
|
1123
|
my ($self, $name) = @_; |
|
178
|
5
|
|
|
|
|
19
|
my $tb = __PACKAGE__->builder(); |
|
179
|
|
|
|
|
|
|
|
|
180
|
5
|
100
|
|
|
|
40
|
if (_is_between($self->code(), 500, 599)){ |
|
181
|
1
|
|
|
|
|
3
|
$tb->ok(0, $name); |
|
182
|
1
|
|
|
|
|
327
|
$self->_smtp_diag; |
|
183
|
|
|
|
|
|
|
} else { |
|
184
|
4
|
|
|
|
|
11
|
$tb->ok(1, $name); |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub message_like { |
|
190
|
6
|
|
|
6
|
1
|
2034
|
my ($self, $expected, $name) = @_; |
|
191
|
6
|
|
|
|
|
21
|
my $tb = __PACKAGE__->builder(); |
|
192
|
|
|
|
|
|
|
|
|
193
|
6
|
|
|
|
|
57
|
my $message = $self->message(); |
|
194
|
6
|
|
|
|
|
66
|
$tb->like($message, $expected, $name); |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub message_unlike { |
|
199
|
6
|
|
|
6
|
1
|
2016
|
my ($self, $expected, $name) = @_; |
|
200
|
6
|
|
|
|
|
20
|
my $tb = __PACKAGE__->builder(); |
|
201
|
|
|
|
|
|
|
|
|
202
|
6
|
|
|
|
|
52
|
my $message = $self->message(); |
|
203
|
6
|
|
|
|
|
63
|
$tb->unlike($message, $expected, $name); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub auth_ok { |
|
208
|
0
|
|
|
0
|
1
|
0
|
my ($self, $method, $user, $password, $name) = @_; |
|
209
|
0
|
|
|
|
|
0
|
my $tb = __PACKAGE__->builder(); |
|
210
|
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
0
|
my $result = $self->auth($method, $user, $password); |
|
212
|
0
|
0
|
|
|
|
0
|
if ($result){ |
|
213
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
214
|
|
|
|
|
|
|
} else { |
|
215
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
216
|
0
|
|
|
|
|
0
|
$self->_smtp_diag; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub auth_ko { |
|
222
|
0
|
|
|
0
|
1
|
0
|
my ($self, $method, $user, $password, $name) = @_; |
|
223
|
0
|
|
|
|
|
0
|
my $tb = __PACKAGE__->builder(); |
|
224
|
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
0
|
my $result = $self->auth($method, $user, $password); |
|
226
|
0
|
0
|
|
|
|
0
|
if ($result){ |
|
227
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
228
|
0
|
|
|
|
|
0
|
$self->_smtp_diag; |
|
229
|
|
|
|
|
|
|
} else { |
|
230
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
} |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub starttls_ok { |
|
236
|
0
|
|
|
0
|
1
|
0
|
my ($self, $name, @sslargs) = @_; |
|
237
|
0
|
|
|
|
|
0
|
my $tb = __PACKAGE__->builder(); |
|
238
|
|
|
|
|
|
|
|
|
239
|
0
|
0
|
|
|
|
0
|
if (not ($self->command('STARTTLS')->response() == Net::Cmd::CMD_OK)){ |
|
240
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
241
|
0
|
|
|
|
|
0
|
$self->_smtp_diag; |
|
242
|
0
|
|
|
|
|
0
|
return; |
|
243
|
|
|
|
|
|
|
} |
|
244
|
0
|
0
|
|
|
|
0
|
if (not $self->_convert_to_ssl(@sslargs)){ |
|
245
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
246
|
0
|
|
|
|
|
0
|
$tb->diag('SSL: ' . IO::Socket::SSL::errstr()); |
|
247
|
0
|
|
|
|
|
0
|
return; |
|
248
|
|
|
|
|
|
|
} |
|
249
|
|
|
|
|
|
|
|
|
250
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
sub starttls_ko { |
|
255
|
0
|
|
|
0
|
1
|
0
|
my ($self, $name, @sslargs) = @_; |
|
256
|
0
|
|
|
|
|
0
|
my $tb = __PACKAGE__->builder(); |
|
257
|
|
|
|
|
|
|
|
|
258
|
0
|
0
|
|
|
|
0
|
if (not ($self->command('STARTTLS')->response() == Net::Cmd::CMD_OK)){ |
|
259
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
260
|
0
|
|
|
|
|
0
|
return; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
0
|
0
|
|
|
|
0
|
if (not $self->_convert_to_ssl(@sslargs)){ |
|
263
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
264
|
0
|
|
|
|
|
0
|
return; |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
|
|
267
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
268
|
0
|
|
|
|
|
0
|
$self->_smtp_diag; |
|
269
|
0
|
|
|
|
|
0
|
$tb->diag('And SSL negotiation went OK'); |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
sub _convert_to_ssl { |
|
273
|
0
|
|
|
0
|
|
0
|
my ($self, @sslargs) = @_; |
|
274
|
0
|
0
|
|
|
|
0
|
require IO::Socket::SSL or die "starttls requires IO::Socket::SSL"; |
|
275
|
|
|
|
|
|
|
# the socket is stored in ${*self}{'_ssl_sock'}. |
|
276
|
|
|
|
|
|
|
# If not, when starttls sub ends *$self is not tied to the SSL |
|
277
|
|
|
|
|
|
|
# socket anymore, instead, it's tied to the old socket. |
|
278
|
0
|
0
|
|
|
|
0
|
my $ssl_sock = IO::Socket::SSL->new_from_fd($self->fileno, @sslargs) |
|
279
|
|
|
|
|
|
|
or return 0; |
|
280
|
0
|
|
|
|
|
0
|
${*self}{'_ssl_sock'} = $ssl_sock; |
|
|
0
|
|
|
|
|
0
|
|
|
281
|
0
|
|
|
|
|
0
|
*$self = *$ssl_sock; |
|
282
|
|
|
|
|
|
|
} |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
sub hello_ok { |
|
286
|
0
|
|
|
0
|
1
|
0
|
my ($self, $hello, $name) = @_; |
|
287
|
0
|
|
|
|
|
0
|
my $tb = __PACKAGE__->builder(); |
|
288
|
|
|
|
|
|
|
|
|
289
|
0
|
0
|
|
|
|
0
|
if ($self->hello($hello)){ |
|
290
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
291
|
|
|
|
|
|
|
} else { |
|
292
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
293
|
0
|
|
|
|
|
0
|
$self->_smtp_diag; |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
} |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub hello_ko { |
|
299
|
0
|
|
|
0
|
1
|
0
|
my ($self, $hello, $name) = @_; |
|
300
|
0
|
|
|
|
|
0
|
my $tb = __PACKAGE__->builder(); |
|
301
|
|
|
|
|
|
|
|
|
302
|
0
|
0
|
|
|
|
0
|
if ($self->hello($hello)){ |
|
303
|
0
|
|
|
|
|
0
|
$tb->ok(0, $name); |
|
304
|
0
|
|
|
|
|
0
|
$self->_smtp_diag; |
|
305
|
|
|
|
|
|
|
} else { |
|
306
|
0
|
|
|
|
|
0
|
$tb->ok(1, $name); |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
sub rset_ok { |
|
313
|
4
|
|
|
4
|
1
|
1410
|
my ($self, $name) = @_; |
|
314
|
4
|
|
|
|
|
22
|
my $tb = __PACKAGE__->builder(); |
|
315
|
|
|
|
|
|
|
|
|
316
|
4
|
100
|
|
|
|
63
|
if ($self->reset){ |
|
317
|
3
|
|
|
|
|
1195
|
$tb->ok(1, $name); |
|
318
|
|
|
|
|
|
|
} else { |
|
319
|
1
|
|
|
|
|
304
|
$tb->ok(0, $name); |
|
320
|
1
|
|
|
|
|
375
|
$self->_smtp_diag; |
|
321
|
|
|
|
|
|
|
} |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
sub rset_ko { |
|
326
|
3
|
|
|
3
|
1
|
587
|
my ($self, $name) = @_; |
|
327
|
3
|
|
|
|
|
11
|
my $tb = __PACKAGE__->builder(); |
|
328
|
|
|
|
|
|
|
|
|
329
|
3
|
100
|
|
|
|
46
|
if ($self->reset){ |
|
330
|
2
|
|
|
|
|
722
|
$tb->ok(0, $name); |
|
331
|
2
|
|
|
|
|
644
|
$self->_smtp_diag; |
|
332
|
|
|
|
|
|
|
} else { |
|
333
|
1
|
|
|
|
|
304
|
$tb->ok(1, $name); |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
} |
|
336
|
|
|
|
|
|
|
|
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
sub supports_ok { |
|
339
|
3
|
|
|
3
|
1
|
724
|
my ($self, $capa, $name) = @_; |
|
340
|
3
|
|
|
|
|
12
|
my $tb = __PACKAGE__->builder(); |
|
341
|
|
|
|
|
|
|
|
|
342
|
3
|
100
|
|
|
|
63
|
if (defined $self->supports($capa)){ |
|
343
|
2
|
|
|
|
|
33
|
$tb->ok(1, $name); |
|
344
|
|
|
|
|
|
|
} else { |
|
345
|
1
|
|
|
|
|
11
|
$tb->ok(0, $name); |
|
346
|
|
|
|
|
|
|
} |
|
347
|
|
|
|
|
|
|
} |
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
sub supports_ko { |
|
351
|
3
|
|
|
3
|
1
|
918
|
my ($self, $capa, $name) = @_; |
|
352
|
3
|
|
|
|
|
10
|
my $tb = __PACKAGE__->builder(); |
|
353
|
|
|
|
|
|
|
|
|
354
|
3
|
100
|
|
|
|
38
|
if (defined $self->supports($capa)){ |
|
355
|
2
|
|
|
|
|
25
|
$tb->ok(0, $name); |
|
356
|
2
|
|
|
|
|
672
|
$tb->diag("Server supports the feature $capa with " . $self->supports($capa)); |
|
357
|
|
|
|
|
|
|
} else { |
|
358
|
1
|
|
|
|
|
15
|
$tb->ok(1, $name); |
|
359
|
|
|
|
|
|
|
} |
|
360
|
|
|
|
|
|
|
} |
|
361
|
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub supports_cmp_ok { |
|
364
|
2
|
|
|
2
|
1
|
770
|
my ($self, $capa, $operator, $expected, $name) = @_; |
|
365
|
2
|
|
|
|
|
8
|
my $tb = __PACKAGE__->builder(); |
|
366
|
|
|
|
|
|
|
|
|
367
|
2
|
|
|
|
|
20
|
my $val = $self->supports($capa); |
|
368
|
2
|
|
|
|
|
25
|
$tb->cmp_ok($val, $operator, $expected, $name); |
|
369
|
|
|
|
|
|
|
} |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub supports_like { |
|
373
|
1
|
|
|
1
|
1
|
267
|
my ($self, $capa, $expected, $name) = @_; |
|
374
|
1
|
|
|
|
|
6
|
my $tb = __PACKAGE__->builder(); |
|
375
|
|
|
|
|
|
|
|
|
376
|
1
|
|
|
|
|
10
|
my $val = $self->supports($capa); |
|
377
|
1
|
|
|
|
|
51
|
$tb->like($val, $expected, $name); |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub supports_unlike { |
|
382
|
1
|
|
|
1
|
1
|
348
|
my ($self, $capa, $expected, $name) = @_; |
|
383
|
1
|
|
|
|
|
5
|
my $tb = __PACKAGE__->builder(); |
|
384
|
|
|
|
|
|
|
|
|
385
|
1
|
|
|
|
|
9
|
my $val = $self->supports($capa); |
|
386
|
1
|
|
|
|
|
12
|
$tb->unlike($val, $expected, $name); |
|
387
|
|
|
|
|
|
|
} |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
sub banner_like { |
|
391
|
1
|
|
|
1
|
1
|
42
|
my ($self, $qr, $name) = @_; |
|
392
|
1
|
|
|
|
|
7
|
my $tb = __PACKAGE__->builder(); |
|
393
|
|
|
|
|
|
|
|
|
394
|
1
|
|
|
|
|
24
|
$tb->like($self->banner(), $qr, $name); |
|
395
|
|
|
|
|
|
|
} |
|
396
|
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
sub banner_unlike { |
|
399
|
1
|
|
|
1
|
1
|
460
|
my ($self, $qr, $name) = @_; |
|
400
|
1
|
|
|
|
|
15
|
my $tb = __PACKAGE__->builder(); |
|
401
|
|
|
|
|
|
|
|
|
402
|
1
|
|
|
|
|
15
|
$tb->unlike($self->banner(), $qr, $name); |
|
403
|
|
|
|
|
|
|
} |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
sub domain_like { |
|
407
|
1
|
|
|
1
|
1
|
379
|
my ($self, $qr, $name) = @_; |
|
408
|
1
|
|
|
|
|
7
|
my $tb = __PACKAGE__->builder(); |
|
409
|
|
|
|
|
|
|
|
|
410
|
1
|
|
|
|
|
15
|
$tb->like($self->domain(), $qr, $name); |
|
411
|
|
|
|
|
|
|
} |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
sub domain_unlike { |
|
415
|
1
|
|
|
1
|
1
|
316
|
my ($self, $qr, $name) = @_; |
|
416
|
1
|
|
|
|
|
7
|
my $tb = __PACKAGE__->builder(); |
|
417
|
|
|
|
|
|
|
|
|
418
|
1
|
|
|
|
|
11
|
$tb->unlike($self->domain(), $qr, $name); |
|
419
|
|
|
|
|
|
|
} |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub mail_from_ok { |
|
423
|
4
|
|
|
4
|
1
|
38329
|
my ($self, $from, $name) = @_; |
|
424
|
4
|
|
|
|
|
24
|
my $tb = __PACKAGE__->builder(); |
|
425
|
|
|
|
|
|
|
|
|
426
|
4
|
100
|
|
|
|
36
|
if ($self->mail_from($from)) { |
|
427
|
2
|
|
|
|
|
965
|
$tb->ok(1, $name); |
|
428
|
|
|
|
|
|
|
} else { |
|
429
|
2
|
|
|
|
|
1233
|
$tb->ok(0, $name); |
|
430
|
2
|
|
|
|
|
726
|
$self->_smtp_diag; |
|
431
|
|
|
|
|
|
|
} |
|
432
|
|
|
|
|
|
|
} |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
sub mail_from_ko { |
|
436
|
3
|
|
|
3
|
1
|
741
|
my ($self, $from, $name) = @_; |
|
437
|
3
|
|
|
|
|
14
|
my $tb = __PACKAGE__->builder(); |
|
438
|
|
|
|
|
|
|
|
|
439
|
3
|
100
|
|
|
|
31
|
if (not $self->mail_from($from)) { |
|
440
|
2
|
|
|
|
|
1014
|
$tb->ok(1, $name); |
|
441
|
|
|
|
|
|
|
} else { |
|
442
|
1
|
|
|
|
|
330
|
$tb->ok(0, $name); |
|
443
|
1
|
|
|
|
|
336
|
$self->_smtp_diag; |
|
444
|
|
|
|
|
|
|
} |
|
445
|
|
|
|
|
|
|
} |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
sub rcpt_to_ok { |
|
449
|
4
|
|
|
4
|
1
|
791
|
my ($self, $to, $name) = @_; |
|
450
|
4
|
|
|
|
|
22
|
my $tb = __PACKAGE__->builder(); |
|
451
|
|
|
|
|
|
|
|
|
452
|
4
|
100
|
|
|
|
30
|
if ($self->rcpt_to($to)) { |
|
453
|
2
|
|
|
|
|
853
|
$tb->ok(1, $name); |
|
454
|
|
|
|
|
|
|
} else { |
|
455
|
2
|
|
|
|
|
673
|
$tb->ok(0, $name); |
|
456
|
2
|
|
|
|
|
652
|
$self->_smtp_diag; |
|
457
|
|
|
|
|
|
|
} |
|
458
|
|
|
|
|
|
|
} |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
sub rcpt_to_ko { |
|
462
|
3
|
|
|
3
|
1
|
607
|
my ($self, $to, $name) = @_; |
|
463
|
3
|
|
|
|
|
11
|
my $tb = __PACKAGE__->builder(); |
|
464
|
|
|
|
|
|
|
|
|
465
|
3
|
100
|
|
|
|
27
|
if (not $self->rcpt_to($to)) { |
|
466
|
2
|
|
|
|
|
859
|
$tb->ok(1, $name); |
|
467
|
|
|
|
|
|
|
} else { |
|
468
|
1
|
|
|
|
|
332
|
$tb->ok(0, $name); |
|
469
|
1
|
|
|
|
|
314
|
$self->_smtp_diag; |
|
470
|
|
|
|
|
|
|
} |
|
471
|
|
|
|
|
|
|
} |
|
472
|
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
sub data_ok { |
|
475
|
3
|
|
|
3
|
1
|
596
|
my ($self, $name) = @_; |
|
476
|
3
|
|
|
|
|
14
|
my $tb = __PACKAGE__->builder(); |
|
477
|
|
|
|
|
|
|
|
|
478
|
3
|
100
|
|
|
|
49
|
if ($self->data == 1){ |
|
479
|
2
|
|
|
|
|
806
|
$tb->ok(1, $name); |
|
480
|
|
|
|
|
|
|
} else { |
|
481
|
1
|
|
|
|
|
302
|
$tb->ok(0, $name); |
|
482
|
1
|
|
|
|
|
384
|
$self->_smtp_diag; |
|
483
|
|
|
|
|
|
|
} |
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
sub data_ko { |
|
488
|
2
|
|
|
2
|
1
|
327
|
my ($self, $name) = @_; |
|
489
|
2
|
|
|
|
|
10
|
my $tb = __PACKAGE__->builder(); |
|
490
|
|
|
|
|
|
|
|
|
491
|
2
|
100
|
|
|
|
33
|
if ($self->data != 1){ |
|
492
|
1
|
|
|
|
|
332
|
$tb->ok(1, $name); |
|
493
|
|
|
|
|
|
|
} else { |
|
494
|
1
|
|
|
|
|
398
|
$tb->ok(0, $name); |
|
495
|
1
|
|
|
|
|
305
|
$self->_smtp_diag; |
|
496
|
|
|
|
|
|
|
} |
|
497
|
|
|
|
|
|
|
} |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
#sub datasend { |
|
500
|
|
|
|
|
|
|
# my ($self, $data) = @_; |
|
501
|
|
|
|
|
|
|
# |
|
502
|
|
|
|
|
|
|
# if (ref($data) eq 'ARRAY'){ |
|
503
|
|
|
|
|
|
|
# $self::SUPER->datasend($data); |
|
504
|
|
|
|
|
|
|
# } |
|
505
|
|
|
|
|
|
|
#} |
|
506
|
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
sub dataend_ok { |
|
509
|
2
|
|
|
2
|
1
|
1428
|
my ($self, $name) = @_; |
|
510
|
2
|
|
|
|
|
10
|
my $tb = __PACKAGE__->builder(); |
|
511
|
|
|
|
|
|
|
|
|
512
|
2
|
100
|
|
|
|
24
|
if ($self->dataend() == 1){ |
|
513
|
1
|
|
|
|
|
39024
|
$tb->ok(1, $name); |
|
514
|
|
|
|
|
|
|
} else { |
|
515
|
1
|
|
|
|
|
38188
|
$tb->ok(0, $name); |
|
516
|
1
|
|
|
|
|
502
|
$self->_smtp_diag(); |
|
517
|
|
|
|
|
|
|
} |
|
518
|
|
|
|
|
|
|
} |
|
519
|
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
sub dataend_ko { |
|
522
|
2
|
|
|
2
|
1
|
722
|
my ($self, $name) = @_; |
|
523
|
2
|
|
|
|
|
8
|
my $tb = __PACKAGE__->builder(); |
|
524
|
|
|
|
|
|
|
|
|
525
|
2
|
100
|
|
|
|
26
|
if ($self->dataend() != 1){ |
|
526
|
1
|
|
|
|
|
37891
|
$tb->ok(1, $name); |
|
527
|
|
|
|
|
|
|
} else { |
|
528
|
1
|
|
|
|
|
37840
|
$tb->ok(0, $name); |
|
529
|
1
|
|
|
|
|
477
|
$self->_smtp_diag(); |
|
530
|
|
|
|
|
|
|
} |
|
531
|
|
|
|
|
|
|
} |
|
532
|
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
|
|
534
|
|
|
|
|
|
|
sub help_like { |
|
535
|
3
|
|
|
3
|
1
|
534
|
my ($self, $help_on, $expected, $name) = @_; |
|
536
|
3
|
|
|
|
|
8
|
my $tb = __PACKAGE__->builder(); |
|
537
|
|
|
|
|
|
|
|
|
538
|
3
|
100
|
|
|
|
34
|
my $msg = $self->help( |
|
539
|
|
|
|
|
|
|
defined $help_on ? $help_on : () |
|
540
|
|
|
|
|
|
|
); |
|
541
|
3
|
|
|
|
|
1028
|
$tb->like($msg, $expected, $name); |
|
542
|
|
|
|
|
|
|
} |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
sub help_unlike { |
|
546
|
2
|
|
|
2
|
1
|
582
|
my ($self, $help_on, $expected, $name) = @_; |
|
547
|
2
|
|
|
|
|
6
|
my $tb = __PACKAGE__->builder(); |
|
548
|
|
|
|
|
|
|
|
|
549
|
2
|
100
|
|
|
|
16
|
my $msg = $self->help( |
|
550
|
|
|
|
|
|
|
defined $help_on ? $help_on : () |
|
551
|
|
|
|
|
|
|
); |
|
552
|
2
|
|
|
|
|
580
|
$tb->unlike($msg, $expected, $name); |
|
553
|
|
|
|
|
|
|
} |
|
554
|
|
|
|
|
|
|
|
|
555
|
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
sub quit_ok { |
|
557
|
2
|
|
|
2
|
1
|
366
|
my ($self, $name) = @_; |
|
558
|
2
|
|
|
|
|
7
|
my $tb = __PACKAGE__->builder(); |
|
559
|
2
|
|
|
|
|
21
|
$self->quit(); |
|
560
|
2
|
100
|
|
|
|
2304
|
if (_is_between($self->code(), 200, 399)){ |
|
561
|
1
|
|
|
|
|
5
|
$tb->ok(1, $name); |
|
562
|
|
|
|
|
|
|
} else { |
|
563
|
1
|
|
|
|
|
6
|
$tb->ok(0, $name); |
|
564
|
1
|
|
|
|
|
389
|
$self->_smtp_diag; |
|
565
|
|
|
|
|
|
|
} |
|
566
|
|
|
|
|
|
|
} |
|
567
|
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
sub quit_ko { |
|
570
|
2
|
|
|
2
|
1
|
40980
|
my ($self, $name) = @_; |
|
571
|
2
|
|
|
|
|
12
|
my $tb = __PACKAGE__->builder(); |
|
572
|
2
|
|
|
|
|
33
|
$self->quit(); |
|
573
|
2
|
100
|
|
|
|
7067
|
if (_is_between($self->code(), 200, 399)){ |
|
574
|
1
|
|
|
|
|
6
|
$tb->ok(0, $name); |
|
575
|
1
|
|
|
|
|
434
|
$self->_smtp_diag; |
|
576
|
|
|
|
|
|
|
} else { |
|
577
|
1
|
|
|
|
|
6
|
$tb->ok(1, $name); |
|
578
|
|
|
|
|
|
|
} |
|
579
|
|
|
|
|
|
|
} |
|
580
|
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
sub _is_between { |
|
582
|
40
|
|
|
40
|
|
358
|
my ($what, $start, $end) = @_; |
|
583
|
40
|
|
100
|
|
|
295
|
return ($what >= $start and $what <= $end); |
|
584
|
|
|
|
|
|
|
} |
|
585
|
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
sub _smtp_diag { |
|
587
|
27
|
|
|
27
|
|
33
|
my $self = shift; |
|
588
|
27
|
|
|
|
|
61
|
my $tb = __PACKAGE__->builder(); |
|
589
|
27
|
|
|
|
|
188
|
$tb->diag(sprintf(" Got from server %s %s\n", $self->code, $self->message)); |
|
590
|
|
|
|
|
|
|
} |
|
591
|
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
sub mail_from { |
|
594
|
8
|
|
|
8
|
1
|
64
|
return shift->command("MAIL", "FROM:", @_)->response() == Net::Cmd::CMD_OK |
|
595
|
|
|
|
|
|
|
} |
|
596
|
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
sub rcpt_to { |
|
599
|
8
|
|
|
8
|
1
|
520
|
return shift->command("RCPT", "TO:", @_)->response() == Net::Cmd::CMD_OK |
|
600
|
|
|
|
|
|
|
} |
|
601
|
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
|
|
604
|
|
|
|
|
|
|
1; |
|
605
|
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
__END__ |