mms2r 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,7 +42,8 @@ class TestMms2rMedia < Test::Unit::TestCase
42
42
  :parts => [],
43
43
  :content_type => 'text/plain',
44
44
  :sub_header => 'message.txt',
45
- :body => 'a'
45
+ :body => 'a',
46
+ :header => {}
46
47
  }.except(keys)
47
48
  stub('mail', attrs)
48
49
  end
@@ -128,6 +129,7 @@ class TestMms2rMedia < Test::Unit::TestCase
128
129
 
129
130
  def test_create_with_default_processor
130
131
  mail = mock()
132
+ mail.expects(:header).at_least_once.returns({})
131
133
  mail.expects(:from).at_least_once.returns(['joe@unknown.example.com'])
132
134
  mms = MMS2R::Media.create(mail)
133
135
  assert_equal MMS2R::Media, mms
@@ -136,13 +138,23 @@ class TestMms2rMedia < Test::Unit::TestCase
136
138
  def test_create_with_special_processor
137
139
  MMS2R.register('null.example.com', MMS2R::Media::NullCarrier)
138
140
  mail = mock()
141
+ mail.expects(:header).at_least_once.returns({})
139
142
  mail.expects(:from).at_least_once.returns(['joe@null.example.com'])
140
143
  mms = MMS2R::Media.create(mail)
141
144
  assert_equal MMS2R::Media::NullCarrier, mms
142
145
  end
143
146
 
147
+ def test_create_with_special_processor_and_return_path
148
+ MMS2R.register('null.example.com', MMS2R::Media::NullCarrier)
149
+ mail = mock()
150
+ mail.expects(:header).at_least_once.returns({'return-path' => '<joe@null.example.com>'})
151
+ mms = MMS2R::Media.create(mail)
152
+ assert_equal MMS2R::Media::NullCarrier, mms
153
+ end
154
+
144
155
  def test_create_should_fail_gracefully_with_broken_from
145
156
  mail = mock()
157
+ mail.expects(:header).at_least_once.returns({})
146
158
  mail.expects(:from).at_least_once.returns(nil)
147
159
  assert_nothing_raised { MMS2R::Media.create(mail) }
148
160
  end
@@ -210,6 +222,10 @@ class TestMms2rMedia < Test::Unit::TestCase
210
222
  result = [type, text]
211
223
  assert_equal result, mms.transform_text(type, text)
212
224
 
225
+ # testing the default config
226
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', 'Sent from my iPhone')
227
+ assert_equal ['text/plain', ''], mms.transform_text('text/plain', "image/jpeg\nSent via BlackBerry from T-Mobile")
228
+
213
229
  # has a bad regexp
214
230
  mms.expects(:config).once.returns({'transform' => {type => [['(hello)', 'world']]}})
215
231
  assert_equal result, mms.transform_text(type, text)
@@ -464,6 +480,19 @@ class TestMms2rMedia < Test::Unit::TestCase
464
480
  mms.purge # have to call purge since a file is put to disk as side effect
465
481
  end
466
482
 
483
+ def test_process_media_with_empty_text
484
+ name = 'foo.txt'
485
+ mms = MMS2R::Media.new(stub_mail())
486
+ mms.stubs(:transform_text_part).returns(['text/plain', nil])
487
+ part = stub(:sub_header => name, :content_type => 'text/plain')
488
+
489
+ assert_equal ['text/plain', nil], mms.process_media(part)
490
+
491
+ mms.stubs(:transform_text_part).returns(['text/plain', ''])
492
+ assert_equal ['text/plain', nil], mms.process_media(part)
493
+ mms.purge # have to call purge since a file is put to disk as side effect
494
+ end
495
+
467
496
  def test_process_media_for_application_smil
468
497
  name = 'foo.txt'
469
498
  mms = MMS2R::Media.new(stub_mail())
@@ -0,0 +1,44 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
8
+
9
+ class TestMobileIndosatNetId < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def test_mms_indosat_with_yahoo_service
13
+ # mobile.indosat.net.id service
14
+ mail = TMail::Mail.parse(load_mail('indosat-image-01.mail').join)
15
+ mms = MMS2R::Media.new(mail)
16
+ assert_equal "mobile.indosat.net.id", mms.carrier
17
+ assert_equal "", mms.subject
18
+ assert_nil mms.media['text/html']
19
+ assert_equal 2, mms.media.size
20
+ assert_not_nil mms.media['image/jpeg']
21
+ assert_equal 1, mms.media['image/jpeg'].size
22
+ assert_not_nil mms.media['image/jpeg'].first
23
+ assert_match /Foto_14_.jpg/, mms.media['image/jpeg'].first
24
+ assert_file_size(mms.media['image/jpeg'].first, 10022)
25
+ assert_equal "Hello World", mms.default_text.read
26
+ mms.purge
27
+ end
28
+
29
+ def test_mms_indosat
30
+ # mobile.indosat.net.id service
31
+ mail = TMail::Mail.parse(load_mail('indosat-image-02.mail').join)
32
+ mms = MMS2R::Media.new(mail)
33
+ assert_equal "mobile.indosat.net.id", mms.carrier
34
+ assert_equal "Please pick up while I prepair another.", mms.subject
35
+ assert_nil mms.media['text/html']
36
+ assert_equal 1, mms.media.size
37
+ assert_not_nil mms.media['image/jpeg']
38
+ assert_equal 1, mms.media['image/jpeg'].size
39
+ assert_not_nil mms.media['image/jpeg'].first
40
+ assert_match /6033_small.jpeg/, mms.media['image/jpeg'].first
41
+ assert_file_size(mms.media['image/jpeg'].first, 3684)
42
+ mms.purge
43
+ end
44
+ end
@@ -180,6 +180,7 @@ class TestPmSprintCom < Test::Unit::TestCase
180
180
  def test_sprint_write_file
181
181
  require 'tempfile'
182
182
  mail = mock(:message_id => 'a')
183
+ mail.expects(:header).at_least_once.returns({})
183
184
  mail.expects(:from).at_least_once.returns(['joe@pm.sprint.com'])
184
185
  s = MMS2R::Media::Sprint.new(mail, :process => :lazy)
185
186
  type = 'text/plain'
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
8
+
9
+ class TestSmsSasktelCom < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def test_sms_sasktel_com
13
+ # sms.sasktel.com service
14
+ mail = TMail::Mail.parse(load_mail('sasktel-image-01.mail').join)
15
+ mms = MMS2R::Media.new(mail)
16
+ assert_equal "sms.sasktel.com", mms.carrier
17
+ assert_equal "", mms.subject
18
+ assert_nil mms.media['text/html']
19
+ assert_nil mms.media['image/gif']
20
+ assert_equal 1, mms.media.size
21
+ assert_not_nil mms.media['image/jpeg']
22
+ assert_equal 1, mms.media['image/jpeg'].size
23
+ assert_match /A1.8463391017738573$/, mms.media['image/jpeg'].first
24
+ assert_file_size(mms.media['image/jpeg'].first, 7336)
25
+ mms.purge
26
+ end
27
+
28
+ end
metadata CHANGED
@@ -1,15 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mms2r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mondragon
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPDCCAiSgAwIBAgIBADANBgkqhkiG9w0BAQUFADBEMRYwFAYDVQQDDA1taWtl
14
+ bW9uZHJhZ29uMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
15
+ FgNjb20wHhcNMDcwODI3MTk1NjQ1WhcNMDgwODI2MTk1NjQ1WjBEMRYwFAYDVQQD
16
+ DA1taWtlbW9uZHJhZ29uMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJ
17
+ k/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD9J/K2
18
+ wp3uqpMzXOfOlY+zb2qRuP0Q6SaqPf8+Y/OD4n+KR91999nRcd9MED4b9okQb5XF
19
+ KjbIRtEyXRtX+nmajf3CqrtOe+Gej9Uru1jBiqwdegCipN2HRrqqOX0Tv15o2W6n
20
+ Lxayxj4JD/DWLrBaKWagv87MCwb0FeKB45Z6bZFA62QM7beBSB9TY+Lv7qpW+uPk
21
+ vlLC9nj765cU0jZNcddgLZcKVl4AihhA5YNOI6XztxA+DSYze8EryrkES8YjY+O7
22
+ oPSSvyi/13QnIPpB884/k9alxWqzx3+qQI6UxXeVY1idS9M+1q3QC6vteo5KqE41
23
+ enZ5Unpw288x+gc5AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
24
+ A1UdDgQWBBQfSk8NE+/Ad8ZKbEAgwIoKvI5H+TANBgkqhkiG9w0BAQUFAAOCAQEA
25
+ ZyBadUGUGP/x2pZEIPYVcP9vG0l64wLDksJNVJ90rEgToaQqypCElvipbCXYF9Pe
26
+ y+5G/bJItH/OKiIHcdJUs8UdXMH5icCpyqNgNopHVkVsE8gghMYm0ptHyKWswRAK
27
+ 6nBO3mw0C2n+KiWdTSXf6HtF9sBg5SV+I/kZEGHbiFEglxfiVoUnlvsCbRt2QlCC
28
+ uMBzJ1sNVgCL3bqeEZwZj0o2HLxOHg0sSOc16rCfX5yvDo7bFM0XAMvwNgYg8ifQ
29
+ zeHINowDygx2eefh0hynPGd/QwgANxHpr4+V93KLsyLosIgAIsqoXRkNx3a5gecL
30
+ q8SfeAt4oNk4pWm9Ocmiww==
31
+ -----END CERTIFICATE-----
11
32
 
12
- date: 2008-01-23 00:00:00 -08:00
33
+ date: 2008-02-08 00:00:00 -08:00
13
34
  default_executable:
14
35
  dependencies:
15
36
  - !ruby/object:Gem::Dependency
@@ -37,7 +58,7 @@ dependencies:
37
58
  requirements:
38
59
  - - ">="
39
60
  - !ruby/object:Gem::Version
40
- version: 1.4.0
61
+ version: 1.5.0
41
62
  version:
42
63
  description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the mobile carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers. If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media. Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed! Corpus of carriers currently processed by MMS2R: * Alltel: message.alltel.com * AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com, cingularme.com * Dobson/Cellular One: mms.dobson.net * Helio: mms.myhelio.com * Hutchison 3G UK Ltd: mms.three.co.uk * LUXGSM S.A.: mms.luxgsm.lu * NetCom (Norway): mms.netcom.no * Nextel: messaging.nextel.com * O2 Germany: mms.o2online.de * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr * PXT New Zealand: pxt.vodafone.net.nz * Sprint: pm.sprint.com, messaging.sprintpcs.com * T-Mobile: tmomail.net * Verizon: vzwpix.com, vtext.com"
43
64
  email: mikemondragon@gmail.com
@@ -65,9 +86,11 @@ files:
65
86
  - conf/mms.o2online.de.yml
66
87
  - conf/mms.three.co.uk.yml
67
88
  - conf/mms2r_media.yml
89
+ - conf/mobile.indosat.net.id.yml
68
90
  - conf/orangemms.net.yml
69
91
  - conf/pm.sprint.com.yml
70
92
  - conf/pxt.vodafone.net.nz.yml
93
+ - conf/sms.sasktel.com.yml
71
94
  - conf/tmomail.net.yml
72
95
  - conf/vzwpix.com.yml
73
96
  - dev_tools/anonymizer.rb
@@ -85,6 +108,8 @@ files:
85
108
  - test/fixtures/dot.jpg
86
109
  - test/fixtures/helio-image-01.mail
87
110
  - test/fixtures/helio-message-01.mail
111
+ - test/fixtures/indosat-image-01.mail
112
+ - test/fixtures/indosat-image-02.mail
88
113
  - test/fixtures/luxgsm-image-01.mail
89
114
  - test/fixtures/mmode-image-01.mail
90
115
  - test/fixtures/mycingular-image-01.mail
@@ -99,6 +124,7 @@ files:
99
124
  - test/fixtures/orangepoland-text-01.mail
100
125
  - test/fixtures/orangepoland-text-02.mail
101
126
  - test/fixtures/pxt-image-01.mail
127
+ - test/fixtures/sasktel-image-01.mail
102
128
  - test/fixtures/sprint-broken-image-01.mail
103
129
  - test/fixtures/sprint-image-01.mail
104
130
  - test/fixtures/sprint-pcs-text-01.mail
@@ -127,9 +153,11 @@ files:
127
153
  - test/test_mms_netcom_no.rb
128
154
  - test/test_mms_o2online_de.rb
129
155
  - test/test_mms_three_co_uk.rb
156
+ - test/test_mobile_indosat_net_id.rb
130
157
  - test/test_orangemms_net.rb
131
158
  - test/test_pm_sprint_com.rb
132
159
  - test/test_pxt_vodafone_net_nz.rb
160
+ - test/test_sms_sasktel_com.rb
133
161
  - test/test_tmomail_net.rb
134
162
  - test/test_vzwpix_com.rb
135
163
  - vendor/plugins/mms2r/lib/autotest/discover.rb
@@ -164,7 +192,9 @@ signing_key:
164
192
  specification_version: 2
165
193
  summary: Extract user media from MMS (and not carrier cruft)
166
194
  test_files:
195
+ - test/test_sms_sasktel_com.rb
167
196
  - test/test_pxt_vodafone_net_nz.rb
197
+ - test/test_mobile_indosat_net_id.rb
168
198
  - test/test_pm_sprint_com.rb
169
199
  - test/test_messaging_sprintpcs_com.rb
170
200
  - test/test_vzwpix_com.rb
Binary file