rt 4.2.14 (#13852)
[freeside.git] / rt / t / mail / header-characters.t
1 use strict;
2 use warnings;
3
4 use RT::Test tests => 12;
5 use Test::Warn;
6
7 my ($baseurl, $m) = RT::Test->started_ok;
8
9 diag "Testing non-ASCII latin1 in From: header";
10 {
11     my $mail = Encode::encode( 'iso-8859-1', Encode::decode( "UTF-8", <<'.') );
12 From: <René@example.com>
13 Reply-To: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
14 Subject: testing non-ASCII From
15 Content-Type: text/plain; charset=iso-8859-1
16
17 here's some content
18 .
19
20     my ($status, $id);
21     warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
22         [(qr/Unable to parse an email address from/) x 2,
23          qr/Couldn't parse or find sender's address/
24         ],
25         'Got parse error for non-ASCII in From';
26     TODO: {
27         local $TODO = "Currently don't handle non-ASCII for sender";
28         is( $status >> 8, 0, "The mail gateway exited normally" );
29         ok( $id, "Created ticket" );
30     }
31 }
32
33 diag "Testing non-ASCII latin1 in From: header with MIME-word-encoded phrase";
34 {
35     my $mail = Encode::encode( 'iso-8859-1', Encode::decode( "UTF-8", <<'.') );
36 From: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
37 Reply-To: =?iso-8859-1?Q?Ren=E9?= <René@example.com>
38 Subject: testing non-ASCII From
39 Content-Type: text/plain; charset=iso-8859-1
40
41 here's some content
42 .
43
44     my ($status, $id);
45     warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
46         [(qr/Unable to parse an email address from/) x 2,
47          qr/Couldn't parse or find sender's address/
48         ],
49         'Got parse error for iso-8859-1 in From';
50     TODO: {
51         local $TODO = "Currently don't handle non-ASCII in sender";
52         is( $status >> 8, 0, "The mail gateway exited normally" );
53         ok( $id, "Created ticket" );
54       }
55 }
56
57 diag "No sender";
58 {
59     my $mail = <<'.';
60 To: rt@example.com
61 Subject: testing non-ASCII From
62 Content-Type: text/plain; charset=iso-8859-1
63
64 here's some content
65 .
66
67     my ($status, $id);
68     warnings_like { ( $status, $id ) = RT::Test->send_via_mailgate($mail) }
69         [qr/Couldn't parse or find sender's address/],
70         'Got parse error with no sender fields';
71     is( $status >> 8, 1, "The mail gateway failed" );
72     ok( !$id, "No ticket created" );
73 }