savon-multipart 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/CHANGELOG.md +11 -5
- data/README.md +7 -12
- data/lib/savon/multipart/version.rb +1 -1
- data/savon-multipart.gemspec +1 -0
- data/spec/fixtures/response/soap_fault.txt +7 -0
- data/spec/savon/soap/response_spec.rb +54 -51
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b2646fc41ff720bd7228d8c05f4300972e64686
|
4
|
+
data.tar.gz: 885ce75c4025dd8e64ee5fe7a430599caf534049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb7660f083792e8452663715fdd6624bbf1d01cab3469e72b12ff6b9146de5660d0a976b6f9df9f2c4f4c5e69b508b5efcbf38aeb96be6ea37b88ba560c0de9b
|
7
|
+
data.tar.gz: b7496671d6a550a9d9ae0c079f5bce6ae45371dd1141a1925698749a3a3552fecf8dd5b23d58015e928069520eb3297d9756b53b392f578bd9f3a6c828c48649
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
-
##
|
1
|
+
## 2.1.0 (current)
|
2
2
|
|
3
|
-
*
|
4
|
-
|
3
|
+
* Drops support for ruby 1.8.7
|
4
|
+
|
5
|
+
## 2.0.2
|
6
|
+
* Removes hardcoded version lock on Mail gem
|
5
7
|
|
6
8
|
## 2.0.0
|
7
9
|
* Rewrite of savon-multipart to work with Savon 2.0+
|
8
10
|
This includes all of the existing functionality in savon-multipart
|
9
11
|
for savon1, but in a way that will be easier to maintain.
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
## 0.9.7
|
14
|
+
|
15
|
+
* Initial version. Adds multipart support (SOAP with Attachments) to Savon v0.9.7.
|
16
|
+
Please test and provide feedback so we can merge this into Savon proper.
|
17
|
+
|
18
|
+
|
data/README.md
CHANGED
@@ -4,25 +4,20 @@ Savon Multipart [![Build Status](https://secure.travis-ci.org/savonrb/savon-mult
|
|
4
4
|
Adds multipart support (SOAP with Attachments) to [Savon](https://github.com/savonrb/savon).
|
5
5
|
Please test and provide feedback so we can support as many multipart-soap messages as possible.
|
6
6
|
|
7
|
+
Installation
|
8
|
+
------------
|
7
9
|
|
8
|
-
|
9
|
-
------
|
10
|
-
|
11
|
-
Recently Savon launched a rewrite that broke compatibility with savon-multipart. If you're using savon
|
12
|
-
version 1, this should just work, but if you'd like to use Savon2, you will probably want to specify
|
13
|
-
something like this in your Gemfile
|
14
|
-
|
10
|
+
Savon Multipart is available through [Rubygems](http://rubygems.org/gems/savon-multipart) and can be installed via:
|
15
11
|
|
16
12
|
```
|
17
|
-
gem
|
13
|
+
$ gem install savon-multipart
|
18
14
|
```
|
19
15
|
|
20
|
-
|
21
|
-
Installation
|
16
|
+
Usage
|
22
17
|
------------
|
23
18
|
|
24
|
-
|
19
|
+
Just require the gem 'savon-multipart', which automatically requires 'savon' as well:
|
25
20
|
|
26
21
|
```
|
27
|
-
|
22
|
+
require 'savon-multipart'
|
28
23
|
```
|
data/savon-multipart.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "http://savonrb.com"
|
12
12
|
s.summary = "Heavy metal Ruby SOAP client with multipart support"
|
13
13
|
s.description = "Adds multipart support (SOAP with Attachments) to Savon"
|
14
|
+
s.required_ruby_version = '>= 1.9.2'
|
14
15
|
|
15
16
|
s.rubyforge_project = s.name
|
16
17
|
|
@@ -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
|
@@ -2,70 +2,73 @@ require 'savon-multipart'
|
|
2
2
|
|
3
3
|
describe Savon::Multipart::Response do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
|
9
|
-
@body = File.read(path)
|
10
|
-
end
|
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) }
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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])
|
19
18
|
|
20
|
-
|
21
|
-
body = File.read(File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__))
|
22
|
-
response = soap_response :headers => @header, :body => body
|
23
|
-
expect(response.xml.class).to eq(String)
|
19
|
+
Savon::Multipart::Response.new(http, globals, {})
|
24
20
|
end
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
response = soap_response :headers => @header, :body => body
|
29
|
-
expect(response.body.class).to eq(Hash)
|
30
|
-
expect(response.body).to eq({:submit_req => true})
|
31
|
-
end
|
22
|
+
context "multipart" do
|
23
|
+
let(:path) { File.expand_path("../../../fixtures/response/multipart.txt", __FILE__) }
|
32
24
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
37
31
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
response = soap_response :headers => header, :body => body
|
32
|
+
it "returns the attachments" do
|
33
|
+
expect(response.attachments.size).to eq(1)
|
34
|
+
end
|
42
35
|
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
46
41
|
end
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
response.xml
|
43
|
+
context "simple multipart" do
|
44
|
+
let(:path) { File.expand_path('../../../fixtures/response/simple_multipart.txt', __FILE__) }
|
51
45
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
5.times { response.attachments }
|
46
|
+
it "returns a String from the #xml method" do
|
47
|
+
expect(response.xml.class).to eq(String)
|
48
|
+
end
|
56
49
|
|
57
|
-
|
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
|
58
54
|
end
|
59
55
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
globals = {
|
64
|
-
:multipart => true,
|
65
|
-
:convert_response_tags_to => lambda { |tag| tag.snakecase.to_sym}
|
66
|
-
}
|
67
|
-
http = HTTPI::Response.new(response[:code], response[:headers], response[:body])
|
56
|
+
context "not multipart" do
|
57
|
+
let(:path) { File.expand_path('../../../fixtures/response/not_multipart.txt', __FILE__) }
|
58
|
+
let(:header) { { 'Content-Type' => 'text/html; charset=utf-8'} }
|
68
59
|
|
69
|
-
|
60
|
+
it "parses soap messages without attachments too" do
|
61
|
+
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>')
|
62
|
+
expect(response.parts.size).to eq(0)
|
63
|
+
expect(response.attachments.size).to eq(0)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "soap errors" do
|
68
|
+
let(:path) { File.expand_path('../../../fixtures/response/soap_fault.txt', __FILE__) }
|
69
|
+
|
70
|
+
it "handles them correctly" do
|
71
|
+
expect { response }.to raise_error(Savon::SOAPFault, /The service cannot be found/)
|
72
|
+
end
|
70
73
|
end
|
71
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: savon-multipart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Westin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- spec/fixtures/response/multipart.txt
|
133
133
|
- spec/fixtures/response/not_multipart.txt
|
134
134
|
- spec/fixtures/response/simple_multipart.txt
|
135
|
+
- spec/fixtures/response/soap_fault.txt
|
135
136
|
- spec/savon/soap/response_spec.rb
|
136
137
|
homepage: http://savonrb.com
|
137
138
|
licenses: []
|
@@ -144,7 +145,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
145
|
requirements:
|
145
146
|
- - ">="
|
146
147
|
- !ruby/object:Gem::Version
|
147
|
-
version:
|
148
|
+
version: 1.9.2
|
148
149
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
150
|
requirements:
|
150
151
|
- - ">="
|