mms2r 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +18 -0
- data/Manifest.txt +13 -0
- data/README.txt +36 -16
- data/Rakefile +1 -1
- data/conf/mms2r_cingularmedia_transform.yml +2 -2
- data/conf/mms2r_nextelmedia_ignore.yml +5 -0
- data/lib/mms2r/media.rb +24 -7
- data/lib/mms2r/nextel_media.rb +11 -0
- data/lib/mms2r/sprint_media.rb +1 -2
- data/lib/mms2r/version.rb +1 -1
- data/test/files/cingularme-text-01.mail +13 -0
- data/test/files/hello_world_mail_multipart.mail +17 -0
- data/test/files/hello_world_mail_plain_no_content_type.mail +7 -0
- data/test/files/hello_world_mail_plain_with_content_type.mail +8 -0
- data/test/files/mmode-image-01.mail +36 -0
- data/test/files/nextel-image-01.mail +46 -0
- data/test/files/simple_image.mail +19 -0
- data/test/files/simple_multipart_alternative.mail +42 -0
- data/test/files/tmobile-image-01.mail +145 -0
- data/test/files/verizon-image-01.mail +7 -778
- data/test/files/verizon-text-01.mail +0 -1
- data/test/files/vtext-text-01.mail +10 -0
- data/test/test_mms2r_cingular.rb +10 -20
- data/test/test_mms2r_media.rb +68 -87
- data/test/test_mms2r_mmode.rb +17 -26
- data/test/test_mms2r_nextel.rb +43 -0
- data/test/test_mms2r_sprint.rb +4 -4
- data/test/test_mms2r_tmobile.rb +18 -145
- data/test/test_mms2r_verizon.rb +20 -6
- metadata +17 -3
@@ -0,0 +1,10 @@
|
|
1
|
+
Date: Sat, 24 Feb 2007 13:25:29 -0500 (EST)
|
2
|
+
Message-ID: <01234567.8901234567890.JavaMail.fooo@njbd-lalal3>
|
3
|
+
From: 2068675309@vtext.com
|
4
|
+
To: tommytutone@example.com
|
5
|
+
Subject: some text
|
6
|
+
Mime-Version: 1.0
|
7
|
+
Content-Type: text/plain; charset=utf-8
|
8
|
+
Content-Transfer-Encoding: 7bit
|
9
|
+
|
10
|
+
hello world
|
data/test/test_mms2r_cingular.rb
CHANGED
@@ -6,36 +6,20 @@ require 'mms2r/media'
|
|
6
6
|
require 'tmail/mail'
|
7
7
|
require 'logger'
|
8
8
|
|
9
|
+
|
9
10
|
class MMS2RCingularTest < Test::Unit::TestCase
|
10
11
|
|
11
12
|
def setup
|
12
13
|
@log = Logger.new(STDOUT)
|
13
14
|
@log.level = Logger::DEBUG
|
14
15
|
@log.datetime_format = "%H:%M:%S"
|
15
|
-
|
16
|
-
msg = <<EOF
|
17
|
-
Message-ID: <0000000.0000000000001.JavaMail.faalala@lalalala03>
|
18
|
-
Mime-Version: 1.0
|
19
|
-
From: 2068675309@mms.mycingular.com
|
20
|
-
To: tommytutone@example.com
|
21
|
-
Subject: text with ad
|
22
|
-
Date: Thu, 11 Jan 2007 02:28:22 -0500
|
23
|
-
|
24
|
-
hello world
|
25
|
-
|
26
|
-
--
|
27
|
-
===============================================
|
28
|
-
Brought to you by, Cingular Wireless Messaging
|
29
|
-
http://www.CingularMe.COM/
|
30
|
-
|
31
|
-
EOF
|
32
|
-
@text_sms_with_ad = TMail::Mail.parse(msg)
|
33
16
|
end
|
34
17
|
|
35
18
|
def teadown; end
|
36
19
|
|
37
20
|
def test_clean_text_ad
|
38
|
-
|
21
|
+
mail = TMail::Mail.parse(load_mail('cingularme-text-01.mail').join)
|
22
|
+
mms = MMS2R::Media.create(mail)
|
39
23
|
assert_equal(MMS2R::CingularMedia, mms.class, "expected a #{MMS2R::CingularMedia} and received a #{mms.class}")
|
40
24
|
mms.process
|
41
25
|
assert_not_nil(mms.media['text/plain'])
|
@@ -43,10 +27,16 @@ EOF
|
|
43
27
|
assert_not_nil(file)
|
44
28
|
assert(File::exist?(file), "file #{file} does not exist")
|
45
29
|
text = IO.readlines("#{file}").join
|
46
|
-
ad = "--\n===============================================\nBrought to you by, Cingular Wireless Messaging\nhttp://www.CingularMe.COM/
|
30
|
+
ad = "\n--\n===============================================\nBrought to you by, Cingular Wireless Messaging\nhttp://www.CingularMe.COM/"
|
47
31
|
assert_no_match(/#{ad}/m, text)
|
32
|
+
assert_no_match(/Brought to you by, Cingular Wireless Messaging/, text)
|
48
33
|
good_text = "hello world\n\n"
|
49
34
|
assert_match(/#{good_text}/m, text)
|
50
35
|
mms.purge
|
51
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def load_mail(file)
|
40
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
41
|
+
end
|
52
42
|
end
|
data/test/test_mms2r_media.rb
CHANGED
@@ -17,11 +17,14 @@ class MMS2RMediaTest < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
CARRIER_TO_CLASS = {
|
19
19
|
'unknowncarrier.tld' => MMS2R::Media,
|
20
|
-
'mmode.com' => MMS2R::MModeMedia,
|
21
20
|
'mms.mycingular.com' => MMS2R::CingularMedia,
|
21
|
+
'cingularme.com' => MMS2R::CingularMedia,
|
22
|
+
'mmode.com' => MMS2R::MModeMedia,
|
23
|
+
'messaging.nextel.com' => MMS2R::NextelMedia,
|
22
24
|
'pm.sprint.com' => MMS2R::SprintMedia,
|
23
25
|
'messaging.sprintpcs.com' => MMS2R::SprintMedia,
|
24
26
|
'tmomail.net' => MMS2R::TMobileMedia,
|
27
|
+
'vtext.com' => MMS2R::VerizonMedia,
|
25
28
|
'vzwpix.com' => MMS2R::VerizonMedia
|
26
29
|
}
|
27
30
|
|
@@ -42,73 +45,6 @@ class MMS2RMediaTest < Test::Unit::TestCase
|
|
42
45
|
|
43
46
|
@oldtmpdir = MMS2R::Media.tmp_dir
|
44
47
|
@oldconfdir = MMS2R::Media.conf_dir
|
45
|
-
|
46
|
-
msg = <<EOF
|
47
|
-
From:2068675309@mms.example.com
|
48
|
-
To:tommytutone@example.com
|
49
|
-
Subject: text only
|
50
|
-
Message-Id: <00000000000001.0123456789@mx.mms.example.com>
|
51
|
-
Date: Wed, 10 Jan 2007 08:18:30 -0600 (CST)
|
52
|
-
|
53
|
-
hello world
|
54
|
-
EOF
|
55
|
-
@hello_world_mail_plain_no_content_type = TMail::Mail.parse(msg)
|
56
|
-
|
57
|
-
msg = <<EOF
|
58
|
-
From:2068675309@mms.example.com
|
59
|
-
To:tommytutone@example.com
|
60
|
-
Subject: text only
|
61
|
-
Message-Id: <00000000000001.0123456789@mx.mms.example.com>
|
62
|
-
Content-Type: text/plain; charset=utf-8
|
63
|
-
Date: Wed, 10 Jan 2007 08:18:30 -0600 (CST)
|
64
|
-
|
65
|
-
hello world
|
66
|
-
EOF
|
67
|
-
@hello_world_mail_plain_with_content_type = TMail::Mail.parse(msg)
|
68
|
-
|
69
|
-
msg = <<EOF
|
70
|
-
Message-Id: <00000000000002.0123456789@mx.mms.example.com>
|
71
|
-
Mime-Version: 1.0
|
72
|
-
From: 2068675309@mms.example.com
|
73
|
-
To: tommytutone@example.com
|
74
|
-
Subject: text only
|
75
|
-
Date: Thu, 11 Jan 2007 02:28:22 -0500
|
76
|
-
Content-Type: multipart/mixed; boundary="----=_Part_1061064_5544954.1168500502466"
|
77
|
-
|
78
|
-
------=_Part_1061064_5544954.1168500502466
|
79
|
-
Content-Type: text/plain; charset=utf-8
|
80
|
-
Content-Transfer-Encoding: base64
|
81
|
-
Content-Location: hello_world.txt
|
82
|
-
Content-Disposition: inline
|
83
|
-
|
84
|
-
aGVsbG8gd29ybGQ=
|
85
|
-
------=_Part_1061064_5544954.1168500502466--
|
86
|
-
|
87
|
-
EOF
|
88
|
-
@hello_world_mail_multi = TMail::Mail.parse(msg)
|
89
|
-
|
90
|
-
msg = <<EOF
|
91
|
-
Mime-Version: 1.0
|
92
|
-
Message-Id: <00000000000001.0123456789@mx.mms.example.com>
|
93
|
-
Date: Sun, 29 Oct 2006 20:40:30 -0800 (PST)
|
94
|
-
To: tommytutone@example.com
|
95
|
-
From: 2068675309@mms.example.com
|
96
|
-
Subject: image test
|
97
|
-
Content-Type: multipart/related; type="multipart/alternative";
|
98
|
-
boundary="----=_Part_1224755_98719.1162204830872"; start="<SMIL.TXT>"
|
99
|
-
X-Mms-Delivery-Report: no
|
100
|
-
|
101
|
-
------=_Part_1224755_98719.1162204830872
|
102
|
-
Content-Type: image/gif; name=spacer.gif
|
103
|
-
Content-Transfer-Encoding: base64
|
104
|
-
Content-Disposition: attachment; filename=spacer.gif
|
105
|
-
Content-ID: <spacer.gif>
|
106
|
-
|
107
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
108
|
-
------=_Part_1224755_98719.1162204830872--
|
109
|
-
|
110
|
-
EOF
|
111
|
-
@simple_image_mail = TMail::Mail.parse(msg)
|
112
48
|
end
|
113
49
|
|
114
50
|
def teardown
|
@@ -118,10 +54,30 @@ EOF
|
|
118
54
|
MMS2R::Media.conf_dir = @oldconfdir
|
119
55
|
end
|
120
56
|
|
57
|
+
def test_collect_text_multipart_alternative
|
58
|
+
mail = TMail::Mail.parse(load_mail('simple_multipart_alternative.mail').join)
|
59
|
+
mms = MMS2R::Media.create(mail)
|
60
|
+
mms.process
|
61
|
+
assert_not_nil(mms.media['text/plain'])
|
62
|
+
assert(mms.media.size == 3)
|
63
|
+
assert(mms.media['text/plain'].size == 1)
|
64
|
+
assert(mms.media['text/html'].size == 1)
|
65
|
+
assert(mms.media['image/gif'].size == 1)
|
66
|
+
|
67
|
+
file = mms.media['text/plain'][0]
|
68
|
+
assert_not_nil(file)
|
69
|
+
assert(File::exist?(file), "file #{file} does not exist")
|
70
|
+
text = IO.readlines("#{file}").join
|
71
|
+
assert_match(/This is an MMS message. Hello World./, text)
|
72
|
+
mms.purge
|
73
|
+
end
|
74
|
+
|
121
75
|
def test_collect_simple_image
|
122
|
-
|
76
|
+
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
77
|
+
mms = MMS2R::Media.create(mail)
|
123
78
|
mms.process
|
124
79
|
assert_not_nil(mms.media['image/gif'])
|
80
|
+
assert(mms.media.size == 1)
|
125
81
|
file = mms.media['image/gif'][0]
|
126
82
|
assert_not_nil(file)
|
127
83
|
assert(File::exist?(file), "file #{file} does not exist")
|
@@ -130,9 +86,11 @@ EOF
|
|
130
86
|
end
|
131
87
|
|
132
88
|
def test_collect_text_plain
|
133
|
-
|
89
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
90
|
+
mms = MMS2R::Media.create(mail)
|
134
91
|
mms.process
|
135
92
|
assert_not_nil(mms.media['text/plain'])
|
93
|
+
assert(mms.media.size == 1)
|
136
94
|
file = mms.media['text/plain'][0]
|
137
95
|
assert_not_nil(file)
|
138
96
|
assert(File::exist?(file), "file #{file} does not exist")
|
@@ -142,9 +100,11 @@ EOF
|
|
142
100
|
end
|
143
101
|
|
144
102
|
def test_collect_text_multi
|
145
|
-
|
103
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_multipart.mail').join)
|
104
|
+
mms = MMS2R::Media.create(mail)
|
146
105
|
mms.process
|
147
106
|
assert_not_nil(mms.media['text/plain'])
|
107
|
+
assert(mms.media.size == 1)
|
148
108
|
file = mms.media['text/plain'][0]
|
149
109
|
assert_not_nil(file)
|
150
110
|
assert(File::exist?(file), "file #{file} does not exist")
|
@@ -216,7 +176,8 @@ EOF
|
|
216
176
|
File.open(f, 'w') do |out|
|
217
177
|
YAML.dump(h, out)
|
218
178
|
end
|
219
|
-
|
179
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
180
|
+
mms = MMS2R::Media.create(mail)
|
220
181
|
mms.process
|
221
182
|
assert_not_nil(mms.media['text/plain'])
|
222
183
|
file = mms.media['text/plain'][0]
|
@@ -235,7 +196,8 @@ EOF
|
|
235
196
|
File.open(f, 'w') do |out|
|
236
197
|
YAML.dump(h, out)
|
237
198
|
end
|
238
|
-
|
199
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
200
|
+
mms = MMS2R::Media.create(mail)
|
239
201
|
mms.process
|
240
202
|
assert(mms.media['text/plain'].nil?)
|
241
203
|
assert(mms.media.size == 0)
|
@@ -250,7 +212,8 @@ EOF
|
|
250
212
|
File.open(f, 'w') do |out|
|
251
213
|
YAML.dump(h, out)
|
252
214
|
end
|
253
|
-
|
215
|
+
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
216
|
+
mms = MMS2R::Media.create(mail)
|
254
217
|
mms.process
|
255
218
|
assert(mms.media['image/gif'].nil?)
|
256
219
|
assert(mms.media.size == 0)
|
@@ -265,7 +228,8 @@ EOF
|
|
265
228
|
File.open(f, 'w') do |out|
|
266
229
|
YAML.dump(h, out)
|
267
230
|
end
|
268
|
-
|
231
|
+
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
232
|
+
mms = MMS2R::Media.create(mail)
|
269
233
|
mms.process
|
270
234
|
assert(mms.media['image/gif'].size == 1)
|
271
235
|
assert(mms.media.size == 1)
|
@@ -289,23 +253,40 @@ EOF
|
|
289
253
|
end
|
290
254
|
|
291
255
|
def test_part_type
|
292
|
-
|
293
|
-
assert(MMS2R::Media.part_type?(
|
294
|
-
|
295
|
-
assert(MMS2R::Media.part_type?(
|
256
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
257
|
+
assert(MMS2R::Media.part_type?(mail).eql?('text/plain'))
|
258
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_with_content_type.mail').join)
|
259
|
+
assert(MMS2R::Media.part_type?(mail).eql?('text/plain'))
|
260
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_multipart.mail').join)
|
261
|
+
assert(MMS2R::Media.part_type?(mail.parts[0]).eql?('text/plain'))
|
262
|
+
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
263
|
+
assert(MMS2R::Media.part_type?(mail.parts[0]).eql?('image/gif'))
|
296
264
|
end
|
297
265
|
|
298
266
|
def test_main_type
|
299
|
-
|
300
|
-
assert(MMS2R::Media.main_type?(
|
301
|
-
|
302
|
-
assert(MMS2R::Media.main_type?(
|
267
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
268
|
+
assert(MMS2R::Media.main_type?(mail).eql?('text'))
|
269
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_with_content_type.mail').join)
|
270
|
+
assert(MMS2R::Media.main_type?(mail).eql?('text'))
|
271
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_multipart.mail').join)
|
272
|
+
assert(MMS2R::Media.main_type?(mail.parts[0]).eql?('text'))
|
273
|
+
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
274
|
+
assert(MMS2R::Media.main_type?(mail.parts[0]).eql?('image'))
|
303
275
|
end
|
304
276
|
|
305
277
|
def test_sub_type
|
306
|
-
|
307
|
-
assert(MMS2R::Media.sub_type?(
|
308
|
-
|
309
|
-
assert(MMS2R::Media.sub_type?(
|
278
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
|
279
|
+
assert(MMS2R::Media.sub_type?(mail).eql?('plain'))
|
280
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_with_content_type.mail').join)
|
281
|
+
assert(MMS2R::Media.sub_type?(mail).eql?('plain'))
|
282
|
+
mail = TMail::Mail.parse(load_mail('hello_world_mail_multipart.mail').join)
|
283
|
+
assert(MMS2R::Media.sub_type?(mail.parts[0]).eql?('plain'))
|
284
|
+
mail = TMail::Mail.parse(load_mail('simple_image.mail').join)
|
285
|
+
assert(MMS2R::Media.sub_type?(mail.parts[0]).eql?('gif'))
|
286
|
+
end
|
287
|
+
|
288
|
+
private
|
289
|
+
def load_mail(file)
|
290
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
310
291
|
end
|
311
292
|
end
|
data/test/test_mms2r_mmode.rb
CHANGED
@@ -12,41 +12,32 @@ class MMS2RMModeTest < Test::Unit::TestCase
|
|
12
12
|
@log = Logger.new(STDOUT)
|
13
13
|
@log.level = Logger::DEBUG
|
14
14
|
@log.datetime_format = "%H:%M:%S"
|
15
|
-
|
16
|
-
msg = <<EOF
|
17
|
-
Message-ID: <0000000.0000000000001.JavaMail.faalala@lalalala03>
|
18
|
-
Mime-Version: 1.0
|
19
|
-
From: 12068675309@mmode.com
|
20
|
-
To: tommytutone@example.com
|
21
|
-
Date: Thu, 11 Jan 2007 02:28:22 -0500
|
22
|
-
Subject: image test
|
23
|
-
Content-Type: multipart/related; type="multipart/alternative";
|
24
|
-
boundary="----=_Part_1224755_98719.1162204830872"; start="<SMIL.TXT>"
|
25
|
-
X-Mms-Delivery-Report: no
|
26
|
-
|
27
|
-
------=_Part_1224755_98719.1162204830872
|
28
|
-
Content-Type: image/gif; name=foo.gif
|
29
|
-
Content-Transfer-Encoding: base64
|
30
|
-
Content-Disposition: attachment; filename=foo.gif
|
31
|
-
Content-ID: <foo.gif>
|
32
|
-
|
33
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
34
|
-
------=_Part_1224755_98719.1162204830872--
|
35
|
-
|
36
|
-
EOF
|
37
|
-
@simple_image_mail = TMail::Mail.parse(msg)
|
38
15
|
end
|
39
16
|
|
40
17
|
def teadown; end
|
41
18
|
|
42
19
|
def test_simple
|
43
|
-
|
20
|
+
mail = TMail::Mail.parse(load_mail('mmode-image-01.mail').join)
|
21
|
+
mms = MMS2R::Media.create(mail)
|
44
22
|
assert_equal(MMS2R::MModeMedia, mms.class, "expected a #{MMS2R::MModeMedia} and received a #{mms.class}")
|
45
23
|
mms.process
|
46
|
-
|
47
|
-
|
24
|
+
|
25
|
+
assert(mms.media.size == 1)
|
26
|
+
assert_nil(mms.media['text/plain'])
|
27
|
+
assert_nil(mms.media['text/html'])
|
28
|
+
assert_not_nil(mms.media['image/jpeg'][0])
|
29
|
+
assert_match(/picture\(3\).jpg$/, mms.media['image/jpeg'][0])
|
30
|
+
|
31
|
+
file = mms.media['image/jpeg'][0]
|
48
32
|
assert_not_nil(file)
|
49
33
|
assert(File::exist?(file), "file #{file} does not exist")
|
34
|
+
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
35
|
+
|
50
36
|
mms.purge
|
51
37
|
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def load_mail(file)
|
41
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
42
|
+
end
|
52
43
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'mms2r'
|
6
|
+
require 'mms2r/media'
|
7
|
+
require 'tmail/mail'
|
8
|
+
require 'logger'
|
9
|
+
|
10
|
+
class MMS2RNextelTest < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@log = Logger.new(STDOUT)
|
14
|
+
@log.level = Logger::DEBUG
|
15
|
+
@log.datetime_format = "%H:%M:%S"
|
16
|
+
end
|
17
|
+
|
18
|
+
def teadown; end
|
19
|
+
|
20
|
+
def test_simple_image
|
21
|
+
mail = TMail::Mail.parse(load_mail('nextel-image-01.mail').join)
|
22
|
+
mms = MMS2R::Media.create(mail)
|
23
|
+
mms.process
|
24
|
+
|
25
|
+
assert(mms.media.size == 1)
|
26
|
+
assert_nil(mms.media['text/plain'])
|
27
|
+
assert_nil(mms.media['text/html'])
|
28
|
+
assert_not_nil(mms.media['image/jpeg'][0])
|
29
|
+
assert_match(/Jan15_0001.jpg$/, mms.media['image/jpeg'][0])
|
30
|
+
|
31
|
+
file = mms.media['image/jpeg'][0]
|
32
|
+
assert_not_nil(file)
|
33
|
+
assert(File::exist?(file), "file #{file} does not exist")
|
34
|
+
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
35
|
+
|
36
|
+
mms.purge
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
def load_mail(file)
|
41
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
42
|
+
end
|
43
|
+
end
|
data/test/test_mms2r_sprint.rb
CHANGED
@@ -117,7 +117,7 @@ class MMS2RSprintTest < Test::Unit::TestCase
|
|
117
117
|
|
118
118
|
def test_simple_image
|
119
119
|
mail = TMail::Mail.parse(load_mail('sprint-image-01.mail').join)
|
120
|
-
mms = MMS2R::Media.create(mail
|
120
|
+
mms = MMS2R::Media.create(mail)
|
121
121
|
mms.process
|
122
122
|
|
123
123
|
assert(mms.media.size == 1)
|
@@ -148,7 +148,7 @@ class MMS2RSprintTest < Test::Unit::TestCase
|
|
148
148
|
end
|
149
149
|
|
150
150
|
private
|
151
|
-
|
152
|
-
|
153
|
-
|
151
|
+
def load_mail(file)
|
152
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
153
|
+
end
|
154
154
|
end
|
data/test/test_mms2r_tmobile.rb
CHANGED
@@ -12,158 +12,31 @@ class MMS2RTMobileTest < Test::Unit::TestCase
|
|
12
12
|
@log = Logger.new(STDOUT)
|
13
13
|
@log.level = Logger::DEBUG
|
14
14
|
@log.datetime_format = "%H:%M:%S"
|
15
|
-
|
16
|
-
msg = <<EOF
|
17
|
-
Message-ID: <10234453.0093232090000.JavaMail.mms@lalaaa05>
|
18
|
-
From: 2068675309@tmomail.net
|
19
|
-
To: tommytutone@example.com
|
20
|
-
Subject: ads are bad
|
21
|
-
Date: Fri, 29 Dec 2006 17:48:41 -0800
|
22
|
-
Mime-Version: 1.0
|
23
|
-
Content-Type: multipart/related; type="text/html";
|
24
|
-
boundary="----=_Part_6032807_21271850.1167443321223"
|
25
|
-
Importance: Normal
|
26
|
-
X-MMS-Message-Type: MM4_forward.REQ
|
27
|
-
X-Priority: 3
|
28
|
-
|
29
|
-
------=_Part_6032807_21271850.1167443321223
|
30
|
-
Content-Type: text/html
|
31
|
-
Content-Transfer-Encoding: quoted-printable
|
32
|
-
Content-ID: <0000>
|
33
|
-
Content-Disposition: inline
|
34
|
-
|
35
|
-
<html>
|
36
|
-
<head>
|
37
|
-
=09=09<title>T-Mobile</title>=20
|
38
|
-
=09=09<!--
|
39
|
-
=09=09=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
|
40
|
-
=09=09If you can read this text, but much of the message below seems unread=
|
41
|
-
able, you might be using an e-mail program that does not work with HTML.
|
42
|
-
|
43
|
-
=09=09=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D-->
|
44
|
-
=09=09<style type=3D"text/css">
|
45
|
-
<!--
|
46
|
-
|
47
|
-
=09=09.footer {
|
48
|
-
=09=09=09font-family: Arial, Helvetica, sans-serif;
|
49
|
-
=09=09=09font-size: 11px;
|
50
|
-
=09=09=09color: #555555;
|
51
|
-
=09=09=09text-decoration: none;
|
52
|
-
=09=09}
|
53
|
-
=09=09.normal {
|
54
|
-
=09=09=09font-family: Arial, Helvetica, sans-serif;
|
55
|
-
=09=09=09font-size: 10px;
|
56
|
-
=09=09=09color: #555555;
|
57
|
-
=09=09=09text-decoration: none;
|
58
|
-
=09=09}
|
59
|
-
|
60
|
-
=09=09-->
|
61
|
-
=09=09</style>
|
62
|
-
=09</head>
|
63
|
-
=09<body marginwidth=3D"0" marginheight=3D"0" leftmargin=3D"0" topmargin=3D=
|
64
|
-
"0" bgcolor=3D"#ffffff">
|
65
|
-
=09=09<table border=3D"0" width=3D"600" cellspacing=3D"0" cellpadding=3D"0"=
|
66
|
-
>
|
67
|
-
=09=09=09<tr>
|
68
|
-
=09=09=09=09<td width=3D"20" rowspan=3D"8"><img src=3D"cid:tmobilespace.gif=
|
69
|
-
" width=3D"20" height=3D"20"></td>
|
70
|
-
=09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilespace.gi=
|
71
|
-
f" width=3D"600" height=3D"20"></td>
|
72
|
-
=09=09=09=09<td width=3D"20" rowspan=3D"8"><img src=3D"cid:tmobilespace.gif=
|
73
|
-
" width=3D"20" height=3D"20"></td>
|
74
|
-
=09=09=09</tr>
|
75
|
-
=09=09=09<tr>
|
76
|
-
=09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:dottedline600.g=
|
77
|
-
if" width=3D"600"></td>
|
78
|
-
=09=09=09</tr>
|
79
|
-
=09=09=09<tr>
|
80
|
-
=09=09=09=09<td width=3D"370">
|
81
|
-
=09=09=09=09 <!-- presentation starts here -->
|
82
|
-
=09=09=09=09 <table border=3D0><tr><tr><td colspan=3D1 align=3D"Left"><IM=
|
83
|
-
G align=3Dbaseline alt=3D"" border=3D0 hspace=3D0 src=3D"cid:280"></td></tr=
|
84
|
-
></tr><TR><TD width=3D350 colSpan=3D1><IMG height=3D30 src=3D"cid:tmobilesp=
|
85
|
-
ace.gif" width=3D350></TD></TR><TR><TD width=3D350 colSpan=3D4><IMG src=3D=
|
86
|
-
"cid:dottedline350.gif" width=3D350></TD></TR><TR><TR><TD width=3D350 colS=
|
87
|
-
pan=3D4><IMG height=3D30 src=3D"cid:tmobilespace.gif" width=3D350></TD></T=
|
88
|
-
R></table>=20
|
89
|
-
=09=09=09=09 <!-- presentation ends here -->
|
90
|
-
=09=09=09=09</td>
|
91
|
-
=09=09=09=09<td width=3D"240" bgcolor=3D"#f2f2f2"><BR></td>
|
92
|
-
=09=09=09</tr>
|
93
|
-
<tr>
|
94
|
-
=09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilelogo.gif=
|
95
|
-
" width=3D"600" height=3D"45"></td>
|
96
|
-
</tr>
|
97
|
-
<tr>
|
98
|
-
=09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilespace.gi=
|
99
|
-
f" width=3D"600" height=3D"10"></td>
|
100
|
-
=09=09=09</tr>
|
101
|
-
=09=09=09<tr>
|
102
|
-
=09=09=09=09<td width=3D"600" colspan=3D"2"><span class=3D"footer">This mes=
|
103
|
-
sage was sent from a T-Mobile wireless phone.
|
104
|
-
</span></td>
|
105
|
-
</tr>
|
106
|
-
<tr>
|
107
|
-
=09=09=09=09<td width=3D"600" colspan=3D"2"><img src=3D"cid:tmobilespace.gi=
|
108
|
-
f" width=3D"600" height=3D"40"></td>
|
109
|
-
</tr>
|
110
|
-
</table>
|
111
|
-
</body></html>
|
112
|
-
|
113
|
-
------=_Part_6032807_21271850.1167443321223
|
114
|
-
Content-Type: image/jpeg; name=12-01-06_1234.jpg
|
115
|
-
Content-Transfer-Encoding: base64
|
116
|
-
Content-Location: 12-01-06_1234.jpg
|
117
|
-
Content-ID: <280>
|
118
|
-
|
119
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
120
|
-
------=_Part_6032807_21271850.1167443321223
|
121
|
-
Content-Type: image/gif; name=audio.gif
|
122
|
-
Content-Transfer-Encoding: base64
|
123
|
-
Content-Disposition: attachment; filename=audio.gif
|
124
|
-
Content-ID: <audio.gif>
|
125
|
-
|
126
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
127
|
-
------=_Part_6032807_21271850.1167443321223
|
128
|
-
Content-Type: image/gif; name=dottedline600.gif
|
129
|
-
Content-Transfer-Encoding: base64
|
130
|
-
Content-Disposition: attachment; filename=dottedline600.gif
|
131
|
-
Content-ID: <dottedline600.gif>
|
132
|
-
|
133
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
134
|
-
------=_Part_6032807_21271850.1167443321223
|
135
|
-
Content-Type: image/gif; name=tmobilelogo.gif
|
136
|
-
Content-Transfer-Encoding: base64
|
137
|
-
Content-Disposition: attachment; filename=tmobilelogo.gif
|
138
|
-
Content-ID: <tmobilelogo.gif>
|
139
|
-
|
140
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
141
|
-
------=_Part_6032807_21271850.1167443321223
|
142
|
-
Content-Type: image/gif; name=tmobilespace.gif
|
143
|
-
Content-Transfer-Encoding: base64
|
144
|
-
Content-Disposition: attachment; filename=tmobilespace.gif
|
145
|
-
Content-ID: <tmobilespace.gif>
|
146
|
-
|
147
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
148
|
-
------=_Part_6032807_21271850.1167443321223
|
149
|
-
Content-Type: image/gif; name=video.gif
|
150
|
-
Content-Transfer-Encoding: base64
|
151
|
-
Content-Disposition: attachment; filename=video.gif
|
152
|
-
Content-ID: <video.gif>
|
153
|
-
|
154
|
-
R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==
|
155
|
-
------=_Part_6032807_21271850.1167443321223--
|
156
|
-
EOF
|
157
|
-
@simple_image_mail = TMail::Mail.parse(msg)
|
158
15
|
end
|
159
16
|
|
160
17
|
def teadown; end
|
161
18
|
|
162
19
|
def test_ignore_simple_image
|
163
|
-
|
20
|
+
mail = TMail::Mail.parse(load_mail('tmobile-image-01.mail').join)
|
21
|
+
mms = MMS2R::Media.create(mail)
|
164
22
|
mms.process
|
23
|
+
|
165
24
|
assert(mms.media.size == 1)
|
166
|
-
|
25
|
+
assert_nil(mms.media['text/plain'])
|
26
|
+
assert_nil(mms.media['text/html'])
|
27
|
+
assert_not_nil(mms.media['image/jpeg'][0])
|
28
|
+
assert_match(/12-01-06_1234.jpg$/, mms.media['image/jpeg'][0])
|
29
|
+
|
30
|
+
file = mms.media['image/jpeg'][0]
|
31
|
+
assert_not_nil(file)
|
32
|
+
assert(File::exist?(file), "file #{file} does not exist")
|
33
|
+
assert(File::size(file) == 337, "file #{file} not 337 byts")
|
34
|
+
|
167
35
|
mms.purge
|
168
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def load_mail(file)
|
40
|
+
IO.readlines("#{File.dirname(__FILE__)}/files/#{file}")
|
41
|
+
end
|
169
42
|
end
|