savon-multipart--feb-2019 2.1.2

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 45b537faf5e50129b586e97d2c5011184998e452ed5db36c3028571ee2538392
4
+ data.tar.gz: 77a9068370e20934d025268d8893bb0c7874455a9491260cc05ce0fa968a73cb
5
+ SHA512:
6
+ metadata.gz: 7d5a2f5505875f9f3c3abb52f0a3dc6efb38b2ce90685b3c567ee4fdf1d3b8328e69ce461a6070e6d7b4063f252c7db52cf298e03b3bb54e4df078b37cb8857d
7
+ data.tar.gz: 245b8bb0586cf08cbc5a59c26cd9438676bbe9789332e1271cd58402433d1ef940fe38769f0c28803ec79385da92e5e0fcb4041301c857493231d61287d777c5
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,11 @@
1
+ # https://github.com/travis-ci/travis-ci/wiki/.travis.yml-options
2
+ language: "ruby"
3
+ sudo: false
4
+ script: "bundle exec rake"
5
+ rvm:
6
+ - 2.0.0
7
+ - 2.1.8
8
+ - 2.2.4
9
+ - 2.3.0
10
+ - jruby
11
+ - rbx-2
@@ -0,0 +1,27 @@
1
+ ## 2.1.2 (current)
2
+
3
+ * Add ability to flatten MTOM XOP parts back into the main XML document.
4
+ * Update mail dependency to mail 2.6
5
+
6
+ ## 2.1.1
7
+
8
+ * Improve detection of multipart content-type header.
9
+
10
+ ## 2.1.0
11
+
12
+ * Drops support for ruby 1.8.7
13
+
14
+ ## 2.0.2
15
+ * Removes hardcoded version lock on Mail gem
16
+
17
+ ## 2.0.0
18
+ * Rewrite of savon-multipart to work with Savon 2.0+
19
+ This includes all of the existing functionality in savon-multipart
20
+ for savon1, but in a way that will be easier to maintain.
21
+
22
+ ## 0.9.7
23
+
24
+ * Initial version. Adds multipart support (SOAP with Attachments) to Savon v0.9.7.
25
+ Please test and provide feedback so we can merge this into Savon proper.
26
+
27
+
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ platform :rbx do
5
+ gem 'json'
6
+ gem 'racc'
7
+ gem 'rubysl'
8
+ gem 'rubinius-coverage'
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Martin Westin, Daniel Harrington
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ Savon Multipart -- Feb 2019
2
+ ===============
3
+
4
+ _This fork exists to be able to make a new release of the gem on rubygem_
5
+
6
+ Adds multipart support (SOAP with Attachments) to [Savon](https://github.com/savonrb/savon).
7
+ Please test and provide feedback so we can support as many multipart-soap messages as possible.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ This fork of Savon Multipart is also available through [Rubygems](http://rubygems.org/gems/savon-multipart) and can be installed via:
13
+
14
+ ```
15
+ $ gem install savon-multipart--feb-2019
16
+ ```
17
+
18
+ Usage
19
+ ------------
20
+
21
+ Just require the gem 'savon-multipart', which automatically requires 'savon' as well:
22
+
23
+ ```
24
+ require 'savon-multipart'
25
+ ```
@@ -0,0 +1,11 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new do |t|
7
+ t.rspec_opts = %w(-c)
8
+ end
9
+
10
+ task :default => :spec
11
+ task :test => :spec
@@ -0,0 +1,3 @@
1
+ require 'savon'
2
+ require 'savon/multipart/version'
3
+ require 'savon/multipart/response'
@@ -0,0 +1,83 @@
1
+ require 'mail'
2
+
3
+ module Savon
4
+ module Multipart
5
+ class Response < Savon::Response
6
+ attr_reader :parts
7
+
8
+ def initialize(*args)
9
+ @parts = []
10
+ super
11
+ end
12
+
13
+ def attachments
14
+ if multipart?
15
+ parse_body unless @has_parsed_body
16
+ @parts.attachments
17
+ else
18
+ []
19
+ end
20
+ end
21
+
22
+ def xml
23
+ if multipart?
24
+ parse_body unless @has_parsed_body
25
+ if xop?
26
+ parse_xop unless @has_parsed_xop
27
+ @xop_body
28
+ else
29
+ @parts.first.body.to_s
30
+ end
31
+ else
32
+ super
33
+ end
34
+ end
35
+
36
+ private
37
+ def multipart?
38
+ !(http.headers['content-type'] =~ /^multipart/im).nil?
39
+ end
40
+
41
+ def xop?
42
+ if multipart?
43
+ parse_body unless @has_parsed_body
44
+ !(@parts.first.header['content-type'].to_s =~ /^application\/xop\+xml/i).nil?
45
+ else
46
+ false
47
+ end
48
+ end
49
+
50
+ def boundary
51
+ return unless multipart?
52
+ @boundary ||= Mail::Field.new('content-type', http.headers['content-type']).parameters['boundary']
53
+ end
54
+
55
+ def parse_body
56
+ @parts = Mail::Part.new(
57
+ :headers => http.headers,
58
+ :body => http.body
59
+ ).body.split!(boundary).parts
60
+ @has_parsed_body = true
61
+ end
62
+
63
+ def parse_xop
64
+ xml = @parts.first.body.to_s
65
+ parsed = Nokogiri.XML(xml)
66
+ xop_elements = parsed.xpath('//xop:Include', xop: "http://www.w3.org/2004/08/xop/include")
67
+ if xop_elements.count == 0
68
+ @xop_body = @parts.first.body.to_s
69
+ @has_parsed_xop = true
70
+ return
71
+ end
72
+ xop_elements.each do |xop_element|
73
+ href = xop_element.attributes['href'].to_s
74
+ cid = href[4..-1]
75
+ data = @parts.find { |p| p.header['content-id'].to_s == "<#{cid}>" }.body.to_s
76
+ xop_element.parent.content = Base64.encode64(data).chomp
77
+ end
78
+ @xop_body = parsed.to_s
79
+ @has_parsed_xop = true
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,5 @@
1
+ module Savon
2
+ module Multipart
3
+ VERSION = "2.1.2"
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $:.unshift lib unless $:.include? lib
3
+
4
+ require "savon/multipart/version"
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "savon-multipart--feb-2019"
8
+ s.version = Savon::Multipart::VERSION
9
+ s.authors = ["Martin Westin", "Daniel Harrington"]
10
+ s.email = ["martin@eimermusic.com", "me@rubiii.com"]
11
+ s.homepage = "http://savonrb.com"
12
+ s.summary = "Heavy metal Ruby SOAP client with multipart support"
13
+ s.description = "Adds multipart support (SOAP with Attachments) to Savon"
14
+ s.required_ruby_version = '>= 1.9.2'
15
+
16
+ s.rubyforge_project = s.name
17
+
18
+ s.add_dependency "savon", "~> 2"
19
+ s.add_dependency "mail", "~> 2.6"
20
+
21
+ s.add_development_dependency "rake"
22
+ s.add_development_dependency "pry"
23
+ s.add_development_dependency "rspec"
24
+ s.add_development_dependency "autotest"
25
+ s.add_development_dependency "transpec"
26
+
27
+ s.files = `git ls-files`.split("\n")
28
+ s.require_path = "lib"
29
+ end
@@ -0,0 +1,103 @@
1
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
2
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
3
+ Message-ID: <4d416ae631391_201a8043814c482c@Martin-iMac.local.mail>
4
+ Mime-Version: 1.0
5
+ Content-Type: text/xml;
6
+ charset=utf-8
7
+ Content-Transfer-Encoding: 7bit
8
+ content-id: soap_xml_part
9
+
10
+ <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>
11
+
12
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
13
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
14
+ Message-ID: <4d416ae63586d_201a8043814c518@Martin-iMac.local.mail>
15
+ Mime-Version: 1.0
16
+ Content-Type: multipart/mixed;
17
+ boundary="--==_mimepart_4d416ae628621_201a8043814c46ea";
18
+ charset=UTF-8
19
+ Content-Transfer-Encoding: 7bit
20
+ content-id: <attachment_1>
21
+
22
+
23
+
24
+ ----==_mimepart_4d416ae628621_201a8043814c46ea
25
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
26
+ Message-ID: <4d416ae635039_201a8043814c507d@Martin-iMac.local.mail>
27
+ Mime-Version: 1.0
28
+ Content-Type: application/smil;
29
+ charset=UTF-8
30
+ Content-Transfer-Encoding: 7bit
31
+ content-id: smil_1.smil
32
+
33
+ <smil>
34
+ <head>
35
+ <layout>
36
+ <root-layout width="240" height="320"/>
37
+ <region id="Image" top="0%" left="0%" height="70%" width="100%" fit="meet"/>
38
+ <region id="Text" top="70%" left="0%" height="30%" width="100%" fit="scroll"/>
39
+ </layout>
40
+ </head>
41
+ <body>
42
+ <par dur="5s"><img src="cid:github_logo.gif" region="Image"></img><text src="cid:text_0.txt" region="Text"><param name="hAlign" value="right"/><param name="textsize" value="small"/></text></par>
43
+ </body>
44
+ </smil>
45
+
46
+ ----==_mimepart_4d416ae628621_201a8043814c46ea
47
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
48
+ Mime-Version: 1.0
49
+ Content-Type: image/gif;
50
+ charset=UTF-8;
51
+ filename=mobile_baby_logo.gif
52
+ Content-Transfer-Encoding: base64
53
+ Content-Disposition: attachment;
54
+ filename=github_logo.gif
55
+ content-id: github_logo.gif
56
+
57
+ R0lGODlhZQAtALMAAPz8/MTExFBQUPn5+ZaWlgAAAPf393x8fNTU1LKysqKi
58
+ ouXl5YuLiyUlJTg4OGNjYyH5BAAAAAAALAAAAABlAC0AAAT/EMhJq7046827
59
+ /xLSFIUDAgKpnl+gkgf7GW8JHrXcLXWid4xaAfHBvX6cWgC5Mb6WHieJqVFS
60
+ M8EaMZq7XqxeC+9lKnbDFDCaglA5BhPDYT5XWKSFdfqpFxssNTEVeH0SaoUZ
61
+ gXdneoeIXy+CFISFjh4JBw4ODwwLFAkCEnRzBAALB1ludFCECwx0WxQBowdQ
62
+ E7SlAFaYdXAZCUIkDw8OK7ovDwAuwSqCeA9CDp4TCop7boYvKUIMGNXMQhIj
63
+ zcrgMKLmL7HLKnYUxdjH6QWhFd/zUwDw5+zMzvgFGkzoV8CWhH025M3zMWEA
64
+ QGMIYxAU8g+gIIIG9ZHJBtAXAAI1/5KZGqeigciIAAwEIPhgZYBpeEgI2PZC
65
+ YDk+7zYqLPmAZLsJNANSGKOCoUZyE6xNCumrTY+bKjIiLCPEFjSdR4VV8CkJ
66
+ ZdJIi45QuMfP0VSOJDL6zHMQWQWvWQtI2jkXndhrJExgfKvT0VUVWxDa/Fp0
67
+ Aly6YY3lxLZ3cV60BQeBwePuY40/bZFCrguAkmMbjQ33xTkBGE6iJR2srZf5
68
+ HGHXS++KZmx2dNQKqdJO+GtuWmu5eIFLlv1bb+14jvAYXCuk8u+5Sm8xKg6V
69
+ hPO4VEn/LuARwICYhflqRjxc8ezHO0WeT3gIdT4KQfMywCwe9k7W0oljh1zA
70
+ t2nkNU0zAP9CBYg0wIHuPXDgggweGBGDaxEwQAACBPBdDQ0OSMaB8cmlAG95
71
+ HRjMAwcwZyGDBGWY4YMLEvjEhS+suOEAZKXzhkMA3YhiDQqoyCCLB+amBIwq
72
+ yOjGgg/d+NCJDLon1wI+athMk+BYiIeRRR44ETNK4tOjiiCqIMB8DTLFYI1R
73
+ EUlChkKcGUwDPr2RYDBfqigkRT9qoomCDVJIBgEGDECMnjou2AChhQ6wADFw
74
+ CtDjoHtOiOiEAujZiY//pSNAlJx26umnoIbqFEAShmrqqaiaSqACCGgJ4qYD
75
+ IKCaAwkoWuKhpdKoWgMEgNLqdw3UOoCvGRKwa60I9HSohQgIMMz/Aa02mwAB
76
+ DZzY7AEDyAEnrQz2kKEUN6qWCQMDHqosttSatAm1J6rGJ7sNMgAnMQQssK0A
77
+ cCYggiZwIiACAdQ6EGgAJg2ArwO3CotjlvHO2ACsA1AL6wKqidAAlBPCSzCc
78
+ UMK7oL3SZJtsA9gOe+i/Jjvwb7oKivBAAgXHWiGSL+S6YFCwziphT78OIG+J
79
+ JR9Ibas9Udujxwcq0AC5hjbAIL4wlwo1rxLz6jLPPgox5koMEMj0yCb1xGC6
80
+ vI7dQKsPG3BoxNWabfPaC/akdKlyU302vkoP47TBcO6t5jyBfgxniQr3VCLE
81
+ bCOg9CYcD80gzEGXi3G5UTtYrd0IUDwvoeHDyquj2gB9KYKF+S67QMDlYjvL
82
+ 0O4+gO8BRr90oAGq9RiAAocvsKhJIkBr+MpnTzgvzCEDzaABHTa3oMVwkntr
83
+ 38juapLRDxvqANlMC9+3hPj2rTLz1RMMcNs+F/z8oZMv31M0ZDKIwAEP1IkJ
84
+ J5OfTiLX0zI57bQAM6koAyRqlQE+FL9Ana5/CGIA1yZHogPND1CeWkDgUkXB
85
+ ClowQxEAADs=
86
+
87
+
88
+ ----==_mimepart_4d416ae628621_201a8043814c46ea
89
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
90
+ Message-ID: <4d416ae633ce8_201a8043814c49c7@Martin-iMac.local.mail>
91
+ Mime-Version: 1.0
92
+ Content-Type: text/plain;
93
+ charset=UTF-8
94
+ Content-Transfer-Encoding: 7bit
95
+ content-id: text_0.txt
96
+
97
+ This is a test message from Github
98
+
99
+ ----==_mimepart_4d416ae628621_201a8043814c46ea--
100
+
101
+
102
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724--
103
+
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>
@@ -0,0 +1,25 @@
1
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
2
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
3
+ Message-ID: <4d416ae631391_201a8043814c482c@Martin-iMac.local.mail>
4
+ Mime-Version: 1.0
5
+ Content-Type: text/xml;
6
+ charset=utf-8
7
+ Content-Transfer-Encoding: 7bit
8
+ content-id: soap_xml_part
9
+
10
+ <?xml version="1.0" encoding="UTF-8"?><envelope ><header></header><body><SubmitReq>true</SubmitReq></body></envelope>
11
+
12
+ ----==_mimepart_4d416ae628621_201a8043814c46ea
13
+ Date: Thu, 27 Jan 2011 13:53:58 +0100
14
+ Message-ID: <4d416ae633ce8_201a8043814c49c7@Martin-iMac.local.mail>
15
+ Mime-Version: 1.0
16
+ Content-Type: text/plain;
17
+ charset=UTF-8
18
+ Content-Transfer-Encoding: 7bit
19
+ content-id: text_0.txt
20
+
21
+ This is a test message from Github
22
+
23
+ ----==_mimepart_4d416ae628621_201a8043814c46ea--
24
+
25
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724--
@@ -0,0 +1,13 @@
1
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
2
+ Content-ID: <http://tempuri.org/0>
3
+ Content-Transfer-Encoding: 8bit
4
+ Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
5
+
6
+ <?xml version="1.0" encoding="UTF-8"?><envelope ><header></header><body><BinaryData><xop:Include href="cid:http://tempuri.org/1/123456789" xmlns:xop="http://www.w3.org/2004/08/xop/include"/></BinaryData></body></envelope>
7
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
8
+ Content-ID: <http://tempuri.org/1/123456789>
9
+ Content-Transfer-Encoding: binary
10
+ Content-Type: application/octet-stream
11
+
12
+ BinaryDataGoesHere
13
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724--
@@ -0,0 +1,7 @@
1
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
2
+ Content-Type: text/xml; charset=UTF-8
3
+ Content-Transfer-Encoding: binary
4
+ Content-ID: <0.1bccd0fe5cc64dd5b5910cd3cc23a762332ffb50bdd8fe1b@apache.org>
5
+
6
+ <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault xmlns:axis2ns1="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>axis2ns1:Client</faultcode><faultstring>The service cannot be found for the endpoint reference (EPR) http://110.74.218.219:8080/EngineWS/services/SoapGWAppImp.SoapGWAppImpHttpSoap12Endpoint/</faultstring><detail /></soapenv:Fault></soapenv:Body></soapenv:Envelope>
7
+ ----==_mimepart_4d416ae62fd32_201a8043814c4724
@@ -0,0 +1,96 @@
1
+ require 'savon-multipart'
2
+
3
+ describe Savon::Multipart::Response do
4
+
5
+ let(:header) {{ "Content-Type" => 'multipart/related; boundary="--==_mimepart_4d416ae62fd32_201a8043814c4724"; charset=UTF-8; type="text/xml"' }}
6
+ let(:body) { File.read(path) }
7
+ let(:response) { soap_response(:headers => header, :body => body) }
8
+
9
+ def soap_response(options = {})
10
+ defaults = { :code => 200, :headers => {}, :body => "" }
11
+ response = defaults.merge options
12
+ globals = {
13
+ :multipart => true,
14
+ :raise_errors => true,
15
+ :convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym}
16
+ }
17
+ http = HTTPI::Response.new(response[:code], response[:headers], response[:body])
18
+
19
+ Savon::Multipart::Response.new(http, globals, {})
20
+ end
21
+
22
+ context "multipart" do
23
+ let(:path) { File.expand_path("../../../fixtures/response/multipart.txt", __FILE__) }
24
+
25
+ it "parses without Exception" do
26
+ expect(response.xml.strip).to eq('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>')
27
+ expect(response.parts.length).to eq(2)
28
+ expect(response.parts[1].parts.length).to eq(3)
29
+ expect(response.parts[1].parts[2].body.decoded.strip).to eq("This is a test message from Github")
30
+ end
31
+
32
+ it "returns the attachments" do
33
+ expect(response.attachments.size).to eq(1)
34
+ end
35
+
36
+ it "only parses the SOAP body once" do
37
+ Mail::Part.stub(:new).and_return(double(Mail::Part).as_null_object)
38
+ expect(Mail::Part).to receive(:new).exactly(1).times
39
+ 5.times { response.attachments }
40
+ end
41
+ end
42
+
43
+ context "simple multipart" do
44
+ let(:path) { File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__) }
45
+
46
+ it "returns a String from the #xml method" do
47
+ expect(response.xml.class).to eq(String)
48
+ end
49
+
50
+ it "returns a Hash from the #body method" do
51
+ expect(response.body.class).to eq(Hash)
52
+ expect(response.body).to eq({:submit_req => true})
53
+ end
54
+ end
55
+
56
+ context "simple xop" do
57
+ let(:path) { File.expand_path('../../../fixtures/response/simple_xop.txt', __FILE__) }
58
+
59
+ it "returns a String from the #xml method" do
60
+ expect(response.xml.class).to eq(String)
61
+ end
62
+
63
+ it "returns a Hash from the #body method, include xop data" do
64
+ expect(response.body.class).to eq(Hash)
65
+ expect(response.body).to eq({:binary_data => Base64.encode64('BinaryDataGoesHere').chomp})
66
+ end
67
+ end
68
+
69
+ describe "a multipart response with case sensitive headers" do
70
+ let(:header) {{ "Content-Type" => 'MuLtIpArT/rElAtEd; boundary="--==_mimepart_4d416ae62fd32_201a8043814c4724"; charset=UTF-8; type="text/xml"' }}
71
+ let(:path) { File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__) }
72
+
73
+ it "does not care about upper or lowercase values for ContentType" do
74
+ expect(response.body).to eq({:submit_req => true})
75
+ end
76
+ end
77
+
78
+ context "not multipart" do
79
+ let(:path) { File.expand_path('../../../fixtures/response/not_multipart.txt', __FILE__) }
80
+ let(:header) { { 'Content-Type' => 'text/html; charset=utf-8'} }
81
+
82
+ it "parses soap messages without attachments too" do
83
+ expect(response.xml.chomp).to eq('<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:wsdl="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header><ns1:TransactionID soapenv:actor="" soapenv:mustUnderstand="1" xsi:type="xsd:string" xmlns:ns1="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2">2011012713535811111111111</ns1:TransactionID></soapenv:Header><soapenv:Body><SubmitReq xmlns="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-2"><MM7Version>5.3.0</MM7Version><SenderIdentification><VASPID>messaging</VASPID><VASID>ADM</VASID><SenderAddress><ShortCode>1111</ShortCode></SenderAddress></SenderIdentification><Recipients><To><Number>11111111111</Number></To></Recipients><ServiceCode>1</ServiceCode><MessageClass>Personal</MessageClass><ExpiryDate>2011-01-28T13:53:58Z</ExpiryDate><DeliveryReport>false</DeliveryReport><ReadReply>false</ReadReply><Priority>Normal</Priority><Subject>Test MMS via Savon</Subject><ChargedParty>Sender</ChargedParty><Content href="cid:attachment_1" allowAdaptations="true"/></SubmitReq></soapenv:Body></soapenv:Envelope>')
84
+ expect(response.parts.size).to eq(0)
85
+ expect(response.attachments.size).to eq(0)
86
+ end
87
+ end
88
+
89
+ context "soap errors" do
90
+ let(:path) { File.expand_path('../../../fixtures/response/soap_fault.txt', __FILE__) }
91
+
92
+ it "handles them correctly" do
93
+ expect { response }.to raise_error(Savon::SOAPFault, /The service cannot be found/)
94
+ end
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: savon-multipart--feb-2019
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Martin Westin
8
+ - Daniel Harrington
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2019-02-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: savon
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2'
28
+ - !ruby/object:Gem::Dependency
29
+ name: mail
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.6'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.6'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: pry
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: autotest
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: transpec
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ description: Adds multipart support (SOAP with Attachments) to Savon
113
+ email:
114
+ - martin@eimermusic.com
115
+ - me@rubiii.com
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - CHANGELOG.md
124
+ - Gemfile
125
+ - LICENSE
126
+ - README.md
127
+ - Rakefile
128
+ - lib/savon-multipart.rb
129
+ - lib/savon/multipart/response.rb
130
+ - lib/savon/multipart/version.rb
131
+ - savon-multipart.gemspec
132
+ - spec/fixtures/response/multipart.txt
133
+ - spec/fixtures/response/not_multipart.txt
134
+ - spec/fixtures/response/simple_multipart.txt
135
+ - spec/fixtures/response/simple_xop.txt
136
+ - spec/fixtures/response/soap_fault.txt
137
+ - spec/savon/soap/response_spec.rb
138
+ homepage: http://savonrb.com
139
+ licenses: []
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 1.9.2
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubygems_version: 3.0.2
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Heavy metal Ruby SOAP client with multipart support
160
+ test_files: []