wasabi 3.2.3 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +29 -0
- data/README.md +4 -4
- data/lib/wasabi.rb +2 -0
- data/lib/wasabi/core_ext/string.rb +7 -8
- data/lib/wasabi/document.rb +6 -3
- data/lib/wasabi/parser.rb +42 -21
- data/lib/wasabi/resolver.rb +7 -4
- data/lib/wasabi/version.rb +3 -1
- data/spec/fixtures/brand.wsdl +624 -0
- data/spec/fixtures/multiple_parts_in_message.wsdl +66 -0
- data/spec/fixtures/no_message_parts.wsdl +82 -56
- data/spec/spec_helper.rb +2 -0
- data/spec/support/adapter.rb +20 -0
- data/spec/support/fixture.rb +2 -0
- data/spec/support/profiling.rb +2 -0
- data/spec/wasabi/core_ext/string_spec.rb +13 -11
- data/spec/wasabi/document/authentication_spec.rb +21 -5
- data/spec/wasabi/document/economic_spec.rb +2 -0
- data/spec/wasabi/document/encoded_endpoint_spec.rb +6 -1
- data/spec/wasabi/document/geotrust_spec.rb +25 -9
- data/spec/wasabi/document/inherited_spec.rb +12 -7
- data/spec/wasabi/document/multiple_namespaces_spec.rb +38 -16
- data/spec/wasabi/document/namespaced_actions_spec.rb +21 -5
- data/spec/wasabi/document/no_namespace_spec.rb +24 -8
- data/spec/wasabi/document/savon295_spec.rb +7 -2
- data/spec/wasabi/document/soap12_spec.rb +6 -1
- data/spec/wasabi/document/two_bindings_spec.rb +13 -3
- data/spec/wasabi/document_spec.rb +8 -6
- data/spec/wasabi/parser/get_servicename_spec.rb +3 -1
- data/spec/wasabi/parser/import_port_types_spec.rb +4 -2
- data/spec/wasabi/parser/juniper_spec.rb +5 -3
- data/spec/wasabi/parser/marketo_spec.rb +3 -1
- data/spec/wasabi/parser/multiple_namespaces_spec.rb +9 -7
- data/spec/wasabi/parser/multiple_parts_in_message_spec.rb +33 -0
- data/spec/wasabi/parser/no_message_parts_spec.rb +11 -3
- data/spec/wasabi/parser/no_namespace_spec.rb +6 -4
- data/spec/wasabi/parser/no_target_namespace_spec.rb +3 -1
- data/spec/wasabi/parser/softlayer_spec.rb +20 -0
- data/spec/wasabi/parser/symbolic_endpoint_spec.rb +8 -9
- data/spec/wasabi/parser/tradetracker_spec.rb +3 -1
- data/spec/wasabi/resolver_spec.rb +28 -11
- data/spec/wasabi/wasabi_spec.rb +3 -1
- metadata +73 -70
- data/.gitignore +0 -8
- data/.rspec +0 -1
- data/.travis.yml +0 -6
- data/Gemfile +0 -13
- data/Rakefile +0 -7
- data/wasabi.gemspec +0 -28
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,30 +7,50 @@ describe Wasabi::Document do
|
|
5
7
|
|
6
8
|
subject { Wasabi::Document.new fixture(:multiple_namespaces).read }
|
7
9
|
|
8
|
-
|
10
|
+
describe '#namespace' do
|
11
|
+
subject { super().namespace }
|
12
|
+
it { is_expected.to eq "http://example.com/actions" }
|
13
|
+
end
|
9
14
|
|
10
|
-
|
15
|
+
describe '#endpoint' do
|
16
|
+
subject { super().endpoint }
|
17
|
+
it { is_expected.to eq URI("http://example.com:1234/soap") }
|
18
|
+
end
|
11
19
|
|
12
|
-
|
20
|
+
describe '#element_form_default' do
|
21
|
+
subject { super().element_form_default }
|
22
|
+
it { is_expected.to eq :qualified }
|
23
|
+
end
|
13
24
|
|
14
|
-
it
|
25
|
+
it 'has 1 operation' do
|
26
|
+
expect(subject.operations.size).to eq(1)
|
27
|
+
end
|
15
28
|
|
16
|
-
|
17
|
-
|
29
|
+
describe '#operations' do
|
30
|
+
subject { super().operations }
|
31
|
+
it do
|
32
|
+
is_expected.to match({ :save => { :input => "Save", :output=>"SaveResponse", :action => "http://example.com/actions.Save", :namespace_identifier => "actions", :parameters => { :article => { :name => "article", :type => "Article" } } } })
|
33
|
+
end
|
18
34
|
end
|
19
35
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
[
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
36
|
+
describe '#type_namespaces' do
|
37
|
+
subject { super().type_namespaces }
|
38
|
+
it do
|
39
|
+
is_expected.to match([
|
40
|
+
[["Save"], "http://example.com/actions"],
|
41
|
+
[["Save", "article"], "http://example.com/actions"],
|
42
|
+
[["Article"], "http://example.com/article"],
|
43
|
+
[["Article", "Author"], "http://example.com/article"],
|
44
|
+
[["Article", "Title"], "http://example.com/article"]
|
45
|
+
])
|
46
|
+
end
|
28
47
|
end
|
29
48
|
|
30
|
-
|
31
|
-
|
49
|
+
describe '#type_definitions' do
|
50
|
+
subject { super().type_definitions }
|
51
|
+
it do
|
52
|
+
is_expected.to match([ [["Save", "article"], "Article"] ])
|
53
|
+
end
|
32
54
|
end
|
33
55
|
|
34
56
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,21 +7,35 @@ describe Wasabi::Document do
|
|
5
7
|
|
6
8
|
subject { Wasabi::Document.new fixture(:namespaced_actions).read }
|
7
9
|
|
8
|
-
|
10
|
+
describe '#namespace' do
|
11
|
+
subject { super().namespace }
|
12
|
+
it { should == "http://api.example.com/api/" }
|
13
|
+
end
|
9
14
|
|
10
|
-
|
15
|
+
describe '#endpoint' do
|
16
|
+
subject { super().endpoint }
|
17
|
+
it { should == URI("https://api.example.com/api/api.asmx") }
|
18
|
+
end
|
11
19
|
|
12
|
-
|
20
|
+
describe '#element_form_default' do
|
21
|
+
subject { super().element_form_default }
|
22
|
+
it { should == :qualified }
|
23
|
+
end
|
13
24
|
|
14
|
-
it
|
25
|
+
it 'has 3 operations' do
|
26
|
+
expect(subject.operations.size).to eq(3)
|
27
|
+
end
|
15
28
|
|
16
|
-
|
29
|
+
describe '#operations' do
|
30
|
+
subject { super().operations }
|
31
|
+
it do
|
17
32
|
should include(
|
18
33
|
{ :delete_client => { :input => "Client.Delete", :output => "Client.DeleteResponse", :action => "http://api.example.com/api/Client.Delete", :namespace_identifier => "tns" } },
|
19
34
|
{ :get_clients => { :input => "User.GetClients", :output => "User.GetClientsResponse", :action => "http://api.example.com/api/User.GetClients", :namespace_identifier => "tns" } },
|
20
35
|
{ :get_api_key => { :input => "User.GetApiKey", :output => "User.GetApiKeyResponse", :action => "http://api.example.com/api/User.GetApiKey", :namespace_identifier => "tns" } }
|
21
36
|
)
|
22
37
|
end
|
38
|
+
end
|
23
39
|
|
24
40
|
end
|
25
41
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,21 +7,35 @@ describe Wasabi::Document do
|
|
5
7
|
|
6
8
|
subject { Wasabi::Document.new fixture(:no_namespace).read }
|
7
9
|
|
8
|
-
|
10
|
+
describe '#namespace' do
|
11
|
+
subject { super().namespace }
|
12
|
+
it { should == "urn:ActionWebService" }
|
13
|
+
end
|
9
14
|
|
10
|
-
|
15
|
+
describe '#endpoint' do
|
16
|
+
subject { super().endpoint }
|
17
|
+
it { should == URI("http://example.com/api/api") }
|
18
|
+
end
|
11
19
|
|
12
|
-
|
20
|
+
describe '#element_form_default' do
|
21
|
+
subject { super().element_form_default }
|
22
|
+
it { should == :unqualified }
|
23
|
+
end
|
13
24
|
|
14
|
-
it
|
25
|
+
it 'has 3 operations' do
|
26
|
+
expect(subject.operations.size).to eq(3)
|
27
|
+
end
|
15
28
|
|
16
|
-
|
29
|
+
describe '#operations' do
|
30
|
+
subject { super().operations }
|
31
|
+
it do
|
17
32
|
should include(
|
18
|
-
{ :get_user_login_by_id => { :input => "GetUserLoginById",
|
19
|
-
{ :get_all_contacts => { :input => "GetAllContacts", :output
|
20
|
-
{ :search_user => { :input => "SearchUser", :output
|
33
|
+
{ :get_user_login_by_id => { :input => { "GetUserLoginById" => { "api_key" => ["xsd", "string"], "id" => ["xsd", "int"] }}, :output=>{"GetUserLoginById"=>{"return"=>["xsd", "string"]}}, :action => "/api/api/GetUserLoginById", :namespace_identifier => "typens" } },
|
34
|
+
{ :get_all_contacts => { :input => {"GetAllContacts" => { "api_key" => ["xsd", "string"], "login"=>["xsd", "string"] }}, :output=>{"GetAllContacts"=>{"return"=>["typens", "McContactArray"]}}, :action => "/api/api/GetAllContacts", :namespace_identifier => "typens" } },
|
35
|
+
{ :search_user => { :input => { "SearchUser" => { "api_key" => ["xsd", "string"], "phrase"=>["xsd", "string"], "page"=>["xsd", "string"], "per_page"=>["xsd", "string"] }}, :output=>{"SearchUser"=>{"return"=>["typens", "MpUserArray"]}}, :action => "/api/api/SearchUser", :namespace_identifier => nil } }
|
21
36
|
)
|
22
37
|
end
|
38
|
+
end
|
23
39
|
|
24
40
|
end
|
25
41
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,11 +7,14 @@ describe Wasabi::Document do
|
|
5
7
|
|
6
8
|
subject { Wasabi::Document.new fixture(:savon295).read }
|
7
9
|
|
8
|
-
|
10
|
+
describe '#operations' do
|
11
|
+
subject { super().operations }
|
12
|
+
it do
|
9
13
|
should include(
|
10
|
-
{ :sendsms => { :input => "
|
14
|
+
{ :sendsms => { :input=>{"sendsms"=>{"sender"=>["xsd", "string"], "cellular"=>["xsd", "string"], "msg"=>["xsd", "string"], "smsnumgroup"=>["xsd", "string"], "emailaddr"=>["xsd", "string"], "udh"=>["xsd", "string"], "datetime"=>["xsd", "string"], "format"=>["xsd", "string"], "dlrurl"=>["xsd", "string"]}}, :output=>{"sendsms"=>{"body"=>["xsd", "string"]}}, :action => "sendsms", :namespace_identifier => 'tns' } }
|
11
15
|
)
|
12
16
|
end
|
17
|
+
end
|
13
18
|
|
14
19
|
end
|
15
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,7 +7,10 @@ describe Wasabi::Document do
|
|
5
7
|
|
6
8
|
subject { Wasabi::Document.new fixture(:soap12).read }
|
7
9
|
|
8
|
-
|
10
|
+
describe '#endpoint' do
|
11
|
+
subject { super().endpoint }
|
12
|
+
it { should == URI("http://blogsite.example.com/endpoint12") }
|
13
|
+
end
|
9
14
|
|
10
15
|
end
|
11
16
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,17 +7,25 @@ describe Wasabi::Document do
|
|
5
7
|
|
6
8
|
subject { Wasabi::Document.new fixture(:two_bindings).read }
|
7
9
|
|
8
|
-
|
10
|
+
describe '#element_form_default' do
|
11
|
+
subject { super().element_form_default }
|
12
|
+
it { should == :unqualified }
|
13
|
+
end
|
9
14
|
|
10
|
-
it
|
15
|
+
it 'has 3 operations' do
|
16
|
+
expect(subject.operations.size).to eq(3)
|
17
|
+
end
|
11
18
|
|
12
|
-
|
19
|
+
describe '#operations' do
|
20
|
+
subject { super().operations }
|
21
|
+
it do
|
13
22
|
should include(
|
14
23
|
{ :post => { :input => "Post", :action => "Post" } },
|
15
24
|
{ :post11only => { :input => "Post11only", :action => "Post11only" } },
|
16
25
|
{ :post12only => { :input => "Post12only", :action => "Post12only" } }
|
17
26
|
)
|
18
27
|
end
|
28
|
+
end
|
19
29
|
|
20
30
|
end
|
21
31
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Document do
|
@@ -5,20 +7,20 @@ describe Wasabi::Document do
|
|
5
7
|
subject { Wasabi::Document.new fixture(:authentication).read }
|
6
8
|
|
7
9
|
it "accepts a URL" do
|
8
|
-
HTTPI.
|
10
|
+
expect(HTTPI).to receive(:get) { HTTPI::Response.new(200, {}, "wsdl") }
|
9
11
|
|
10
12
|
document = Wasabi::Document.new("http://example.com?wsdl")
|
11
|
-
document.xml.
|
13
|
+
expect(document.xml).to eq("wsdl")
|
12
14
|
end
|
13
15
|
|
14
16
|
it "accepts a path" do
|
15
17
|
document = Wasabi::Document.new fixture(:authentication).path
|
16
|
-
document.xml.
|
18
|
+
expect(document.xml).to eq(fixture(:authentication).read)
|
17
19
|
end
|
18
20
|
|
19
21
|
it "accepts raw XML" do
|
20
22
|
document = Wasabi::Document.new fixture(:authentication).read
|
21
|
-
document.xml.
|
23
|
+
expect(document.xml).to eq(fixture(:authentication).read)
|
22
24
|
end
|
23
25
|
|
24
26
|
describe ".validate_element_form_default!" do
|
@@ -39,13 +41,13 @@ describe Wasabi::Document do
|
|
39
41
|
|
40
42
|
describe "#element_form_default" do
|
41
43
|
it "defaults to :unqualified" do
|
42
|
-
subject.element_form_default.
|
44
|
+
expect(subject.element_form_default).to eq(:unqualified)
|
43
45
|
end
|
44
46
|
|
45
47
|
[:unqualified, :qualified].each do |value|
|
46
48
|
it "accepts :#{value}" do
|
47
49
|
subject.element_form_default = value
|
48
|
-
subject.element_form_default.
|
50
|
+
expect(subject.element_form_default).to eq(value)
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Parser do
|
@@ -12,7 +14,7 @@ describe Wasabi::Parser do
|
|
12
14
|
let(:xml) { fixture(:geotrust).read }
|
13
15
|
|
14
16
|
it "returns the #service_name attribute" do
|
15
|
-
subject.service_name.
|
17
|
+
expect(subject.service_name).to eq("queryDefinitions")
|
16
18
|
end
|
17
19
|
|
18
20
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Parser do
|
@@ -14,8 +16,8 @@ describe Wasabi::Parser do
|
|
14
16
|
it "does blow up when portTypes are imported" do
|
15
17
|
get_customer = subject.operations[:get_customer]
|
16
18
|
|
17
|
-
get_customer[:input].
|
18
|
-
get_customer[:namespace_identifier].
|
19
|
+
expect(get_customer[:input]).to eq("GetCustomer")
|
20
|
+
expect(get_customer[:namespace_identifier]).to be_nil
|
19
21
|
end
|
20
22
|
|
21
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Parser do
|
@@ -14,9 +16,9 @@ describe Wasabi::Parser do
|
|
14
16
|
it 'does not blow up when an extension base element is defined in an import' do
|
15
17
|
request = subject.operations[:get_system_info_request]
|
16
18
|
|
17
|
-
request[:input].
|
18
|
-
request[:action].
|
19
|
-
request[:namespace_identifier].
|
19
|
+
expect(request[:input]).to eq('GetSystemInfoRequest')
|
20
|
+
expect(request[:action]).to eq('urn:#GetSystemInfoRequest')
|
21
|
+
expect(request[:namespace_identifier]).to eq('impl')
|
20
22
|
end
|
21
23
|
|
22
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Wasabi::Parser do
|
@@ -11,7 +13,7 @@ describe Wasabi::Parser do
|
|
11
13
|
let(:xml) { fixture(:marketo).read }
|
12
14
|
|
13
15
|
it 'parses the operations' do
|
14
|
-
subject.operations[:get_lead][:input].
|
16
|
+
expect(subject.operations[:get_lead][:input]).to eq('paramsGetLead')
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Wasabi::Parser do
|
@@ -12,28 +14,28 @@ describe Wasabi::Parser do
|
|
12
14
|
let(:xml) { fixture(:multiple_namespaces).read }
|
13
15
|
|
14
16
|
it "lists the types" do
|
15
|
-
subject.types.keys.sort.
|
17
|
+
expect(subject.types.keys.sort).to eq(["Article", "Save"])
|
16
18
|
end
|
17
19
|
|
18
20
|
it "records the namespace for each type" do
|
19
|
-
subject.types["Save"][:namespace].
|
21
|
+
expect(subject.types["Save"][:namespace]).to eq("http://example.com/actions")
|
20
22
|
end
|
21
23
|
|
22
24
|
it "records the fields under a type" do
|
23
|
-
subject.types["Save"].keys.
|
25
|
+
expect(subject.types["Save"].keys).to match_array(["article", :namespace, :order!])
|
24
26
|
end
|
25
27
|
|
26
28
|
it "records multiple fields when there are more than one" do
|
27
|
-
subject.types["Article"].keys.
|
29
|
+
expect(subject.types["Article"].keys).to match_array(["Title", "Author", :namespace, :order!])
|
28
30
|
end
|
29
31
|
|
30
32
|
it "records the type of a field" do
|
31
|
-
subject.types["Save"]["article"][:type].
|
32
|
-
subject.namespaces["article"].
|
33
|
+
expect(subject.types["Save"]["article"][:type]).to eq("article:Article")
|
34
|
+
expect(subject.namespaces["article"]).to eq("http://example.com/article")
|
33
35
|
end
|
34
36
|
|
35
37
|
it "lists the order of the type elements" do
|
36
|
-
subject.types["Article"][:order!].
|
38
|
+
expect(subject.types["Article"][:order!]).to eq(["Author", "Title"])
|
37
39
|
end
|
38
40
|
|
39
41
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe Wasabi::Parser do
|
6
|
+
context 'with: multiple_parts_in_message.wsdl' do
|
7
|
+
|
8
|
+
subject do
|
9
|
+
parser = Wasabi::Parser.new Nokogiri::XML(xml)
|
10
|
+
parser.parse
|
11
|
+
parser
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:xml) { fixture(:multiple_parts_in_message).read }
|
15
|
+
|
16
|
+
context "with a parts attribute in soap:body element" do
|
17
|
+
it 'uses the part specified in parts attribute' do
|
18
|
+
request = subject.operations[:some_operation][:input]
|
19
|
+
|
20
|
+
expect(request).to eq("SomeRequestBody")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "with no parts attribute in soap:body element" do
|
25
|
+
it 'uses the first part element in message' do
|
26
|
+
request = subject.operations[:other_operation][:input]
|
27
|
+
|
28
|
+
expect(request).to eq("SomeRequest")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Wasabi::Parser do
|
@@ -13,14 +15,20 @@ describe Wasabi::Parser do
|
|
13
15
|
|
14
16
|
it 'falls back to using the message type in the port element' do
|
15
17
|
# Operation's input has no part element in the message, so using the message type.
|
16
|
-
subject.operations[:save][:input].
|
18
|
+
expect(subject.operations[:save][:input]).to eq('Save')
|
17
19
|
|
18
20
|
# Operation's output has part element in the message, so using part element's type.
|
19
|
-
subject.operations[:save][:output].
|
21
|
+
expect(subject.operations[:save][:output]).to eq('SaveResponse')
|
20
22
|
end
|
21
23
|
|
22
24
|
it 'falls back to using the namespace ID in the port element' do
|
23
|
-
subject.operations[:save][:namespace_identifier].
|
25
|
+
expect(subject.operations[:save][:namespace_identifier]).to eq('actions')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'gracefully handles port messages without a colon' do
|
29
|
+
expect(subject.operations[:delete][:input]).to eq('Delete')
|
30
|
+
expect(subject.operations[:delete][:output]).to eq('DeleteResponse')
|
31
|
+
expect(subject.operations[:delete][:namespace_identifier]).to be_nil
|
24
32
|
end
|
25
33
|
end
|
26
34
|
end
|