wasabi-ng-1.6 3.3.0

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.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +9 -0
  5. data/CHANGELOG.md +90 -0
  6. data/Gemfile +6 -0
  7. data/LICENSE +20 -0
  8. data/README.md +60 -0
  9. data/Rakefile +7 -0
  10. data/lib/wasabi.rb +12 -0
  11. data/lib/wasabi/core_ext/string.rb +21 -0
  12. data/lib/wasabi/document.rb +166 -0
  13. data/lib/wasabi/parser.rb +304 -0
  14. data/lib/wasabi/resolver.rb +54 -0
  15. data/lib/wasabi/version.rb +5 -0
  16. data/spec/fixtures/authentication.wsdl +63 -0
  17. data/spec/fixtures/economic.wsdl +65660 -0
  18. data/spec/fixtures/encoded_endpoint.wsdl +52 -0
  19. data/spec/fixtures/geotrust.wsdl +156 -0
  20. data/spec/fixtures/import_port_types.wsdl +86 -0
  21. data/spec/fixtures/inherited.wsdl +46 -0
  22. data/spec/fixtures/juniper.wsdl +215 -0
  23. data/spec/fixtures/lower_camel.wsdl +52 -0
  24. data/spec/fixtures/multiple_namespaces.wsdl +61 -0
  25. data/spec/fixtures/multiple_types.wsdl +60 -0
  26. data/spec/fixtures/namespaced_actions.wsdl +307 -0
  27. data/spec/fixtures/no_message_parts.wsdl +59 -0
  28. data/spec/fixtures/no_namespace.wsdl +115 -0
  29. data/spec/fixtures/savon295.wsdl +52 -0
  30. data/spec/fixtures/soap12.wsdl +11 -0
  31. data/spec/fixtures/symbolic_endpoint.wsdl +190 -0
  32. data/spec/fixtures/two_bindings.wsdl +24 -0
  33. data/spec/spec_helper.rb +19 -0
  34. data/spec/support/fixture.rb +40 -0
  35. data/spec/support/profiling.rb +18 -0
  36. data/spec/wasabi/core_ext/string_spec.rb +37 -0
  37. data/spec/wasabi/document/authentication_spec.rb +23 -0
  38. data/spec/wasabi/document/economic_spec.rb +13 -0
  39. data/spec/wasabi/document/encoded_endpoint_spec.rb +11 -0
  40. data/spec/wasabi/document/geotrust_spec.rb +24 -0
  41. data/spec/wasabi/document/inherited_spec.rb +38 -0
  42. data/spec/wasabi/document/multiple_namespaces_spec.rb +35 -0
  43. data/spec/wasabi/document/namespaced_actions_spec.rb +25 -0
  44. data/spec/wasabi/document/no_namespace_spec.rb +25 -0
  45. data/spec/wasabi/document/savon295_spec.rb +15 -0
  46. data/spec/wasabi/document/soap12_spec.rb +11 -0
  47. data/spec/wasabi/document/two_bindings_spec.rb +21 -0
  48. data/spec/wasabi/document_spec.rb +58 -0
  49. data/spec/wasabi/parser/get_servicename_spec.rb +19 -0
  50. data/spec/wasabi/parser/import_port_types_spec.rb +22 -0
  51. data/spec/wasabi/parser/juniper_spec.rb +23 -0
  52. data/spec/wasabi/parser/multiple_namespaces_spec.rb +40 -0
  53. data/spec/wasabi/parser/no_message_parts_spec.rb +26 -0
  54. data/spec/wasabi/parser/no_namespace_spec.rb +26 -0
  55. data/spec/wasabi/parser/no_target_namespace_spec.rb +36 -0
  56. data/spec/wasabi/parser/symbolic_endpoint_spec.rb +24 -0
  57. data/spec/wasabi/resolver_spec.rb +40 -0
  58. data/spec/wasabi/wasabi_spec.rb +12 -0
  59. data/wasabi.gemspec +27 -0
  60. metadata +159 -0
@@ -0,0 +1,19 @@
1
+ require "bundler"
2
+ Bundler.require :default, :development
3
+
4
+ unless RUBY_PLATFORM =~ /java/
5
+ require "simplecov"
6
+ require "coveralls"
7
+
8
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
9
+ SimpleCov.start do
10
+ add_filter "spec"
11
+ end
12
+ end
13
+
14
+ support_files = File.expand_path("spec/support/**/*.rb")
15
+ Dir[support_files].each { |file| require file }
16
+
17
+ RSpec.configure do |config|
18
+ config.include SpecSupport
19
+ end
@@ -0,0 +1,40 @@
1
+ module SpecSupport
2
+
3
+ class Fixture
4
+ def self.[](name)
5
+ fixtures[name]
6
+ end
7
+
8
+ def self.[]=(name, value)
9
+ fixtures[name] = value
10
+ end
11
+
12
+ def self.fixtures
13
+ @fixtures ||= {}
14
+ end
15
+
16
+ def initialize(file, ext = :wsdl)
17
+ self.file = file
18
+ self.ext = ext
19
+ end
20
+
21
+ attr_accessor :file, :ext
22
+
23
+ def filename
24
+ "#{file}.#{ext}"
25
+ end
26
+
27
+ def path
28
+ File.expand_path("spec/fixtures/#{filename}")
29
+ end
30
+
31
+ def read
32
+ Fixture[filename] ||= File.read(path)
33
+ end
34
+ end
35
+
36
+ def fixture(*args)
37
+ Fixture.new(*args)
38
+ end
39
+
40
+ end
@@ -0,0 +1,18 @@
1
+ module SpecSupport
2
+
3
+ def benchmark(&block)
4
+ require 'benchmark'
5
+
6
+ puts "Benchmark:"
7
+ puts Benchmark.measure(&block)
8
+ end
9
+
10
+ def profile_methods
11
+ require 'method_profiler'
12
+
13
+ profiler = MethodProfiler.observe(Wasabi::Parser)
14
+ yield
15
+ puts profiler.report
16
+ end
17
+
18
+ end
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe String do
4
+
5
+ describe "#snakecase" do
6
+ it "lowercases one word CamelCase" do
7
+ "Merb".snakecase.should == "merb"
8
+ end
9
+
10
+ it "makes one underscore snakecase two word CamelCase" do
11
+ "MerbCore".snakecase.should == "merb_core"
12
+ end
13
+
14
+ it "handles CamelCase with more than 2 words" do
15
+ "SoYouWantContributeToMerbCore".snakecase.should == "so_you_want_contribute_to_merb_core"
16
+ end
17
+
18
+ it "handles CamelCase with more than 2 capital letter in a row" do
19
+ "CNN".snakecase.should == "cnn"
20
+ "CNNNews".snakecase.should == "cnn_news"
21
+ "HeadlineCNNNews".snakecase.should == "headline_cnn_news"
22
+ end
23
+
24
+ it "does NOT change one word lowercase" do
25
+ "merb".snakecase.should == "merb"
26
+ end
27
+
28
+ it "leaves snake_case as is" do
29
+ "merb_core".snakecase.should == "merb_core"
30
+ end
31
+
32
+ it "converts period characters to underscores" do
33
+ "User.GetEmail".snakecase.should == "user_get_email"
34
+ end
35
+ end
36
+
37
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: authentication.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:authentication).read }
7
+
8
+ its(:namespace) { should == "http://v1_0.ws.auth.order.example.com/" }
9
+
10
+ its(:endpoint) { should == URI("http://example.com/validation/1.0/AuthenticationService") }
11
+
12
+ its(:element_form_default) { should == :unqualified }
13
+
14
+ it { should have(1).operations }
15
+
16
+ its(:operations) do
17
+ should == {
18
+ :authenticate => { :input => "authenticate", :output => "authenticateResponse", :action => "authenticate", :namespace_identifier => "tns" }
19
+ }
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wasabi::Document do
4
+ context 'with: economic.wsdl' do
5
+
6
+ subject { Wasabi::Document.new fixture(:economic).read }
7
+
8
+ it 'has an ok parse-time for huge wsdl files' do
9
+ expect(subject.operations.count).to eq(1511)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: encoded_endpoint.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:encoded_endpoint).read }
7
+
8
+ its(:endpoint) { should == URI("http://localhost/soapservice/execute?path=/base/includes/Test+Soap/Return+Rows") }
9
+
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: geotrust.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:geotrust).read }
7
+
8
+ its(:namespace) { should == "http://api.geotrust.com/webtrust/query" }
9
+
10
+ its(:endpoint) { should == URI("https://test-api.geotrust.com:443/webtrust/query.jws") }
11
+
12
+ its(:element_form_default) { should == :qualified }
13
+
14
+ it { should have(2).operations }
15
+
16
+ its(:operations) do
17
+ should include(
18
+ { :get_quick_approver_list => { :input => "GetQuickApproverList", :action => "GetQuickApproverList", :parameters=>{:Request=>{:name=>"Request", :type=>"GetQuickApproverListInput"}}}},
19
+ { :hello => { :input => "hello", :action => "hello", :parameters=>{:Input=>{:name=>"Input", :type=>"string"}} } }
20
+ )
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: inherited.xml" do
5
+
6
+ subject { Wasabi::Document.new fixture(:inherited).read }
7
+
8
+ its(:type_definitions) do
9
+ should include([["Account", "Id"], "ID"])
10
+ should include([["Account", "ProcessId"], "ID"])
11
+ should include([["Account", "CreatedDate"], "dateTime"])
12
+ should include([["Account", "Description"], "string"])
13
+ should include([["Account", "fieldsToNull"], "string"])
14
+ end
15
+
16
+ it "should position base class attributes before subclass attributes in :order! array" do
17
+ account = subject.parser.types["Account"]
18
+ account[:order!].should == ["fieldsToNull", "Id", "Description", "ProcessId", "CreatedDate"]
19
+ end
20
+
21
+ it "should have each type's hash remember it's base type in :base_type element" do
22
+ account = subject.parser.types["Account"]
23
+ account[:base_type].should == "baseObject"
24
+
25
+ base_object = subject.parser.types["baseObject"]
26
+ base_object.should_not have_key(:base_type)
27
+ end
28
+
29
+ it "should have element's hash contain all these attributes (:nillable, :minOccurs, :maxOccurs) in addition to :type" do
30
+ base_object = subject.parser.types["baseObject"]
31
+ fields_to_null = base_object["fieldsToNull"]
32
+ fields_to_null[:nillable].should == "true"
33
+ fields_to_null[:minOccurs].should == "0"
34
+ fields_to_null[:maxOccurs].should == "unbounded"
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: multiple_namespaces.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:multiple_namespaces).read }
7
+
8
+ its(:namespace) { should == "http://example.com/actions" }
9
+
10
+ its(:endpoint) { should == URI("http://example.com:1234/soap") }
11
+
12
+ its(:element_form_default) { should == :qualified }
13
+
14
+ it { should have(1).operations }
15
+
16
+ its(:operations) do
17
+ should == { :save => { :input => "Save", :output=>"SaveResponse", :action => "http://example.com/actions.Save", :namespace_identifier => "actions", :parameters => { :article => { :name => "article", :type => "Article" } } } }
18
+ end
19
+
20
+ its(:type_namespaces) do
21
+ should =~ [
22
+ [["Save"], "http://example.com/actions"],
23
+ [["Save", "article"], "http://example.com/actions"],
24
+ [["Article"], "http://example.com/article"],
25
+ [["Article", "Author"], "http://example.com/article"],
26
+ [["Article", "Title"], "http://example.com/article"]
27
+ ]
28
+ end
29
+
30
+ its(:type_definitions) do
31
+ should =~ [ [["Save", "article"], "Article"] ]
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: namespaced_actions.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:namespaced_actions).read }
7
+
8
+ its(:namespace) { should == "http://api.example.com/api/" }
9
+
10
+ its(:endpoint) { should == URI("https://api.example.com/api/api.asmx") }
11
+
12
+ its(:element_form_default) { should == :qualified }
13
+
14
+ it { should have(3).operations }
15
+
16
+ its(:operations) do
17
+ should include(
18
+ { :delete_client => { :input => "Client.Delete", :output => "Client.DeleteResponse", :action => "http://api.example.com/api/Client.Delete", :namespace_identifier => "tns" } },
19
+ { :get_clients => { :input => "User.GetClients", :output => "User.GetClientsResponse", :action => "http://api.example.com/api/User.GetClients", :namespace_identifier => "tns" } },
20
+ { :get_api_key => { :input => "User.GetApiKey", :output => "User.GetApiKeyResponse", :action => "http://api.example.com/api/User.GetApiKey", :namespace_identifier => "tns" } }
21
+ )
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: no_namespace.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:no_namespace).read }
7
+
8
+ its(:namespace) { should == "urn:ActionWebService" }
9
+
10
+ its(:endpoint) { should == URI("http://example.com/api/api") }
11
+
12
+ its(:element_form_default) { should == :unqualified }
13
+
14
+ it { should have(3).operations }
15
+
16
+ its(:operations) do
17
+ should include(
18
+ { :get_user_login_by_id => { :input => "GetUserLoginById", :output => "GetUserLoginByIdResponse", :action => "/api/api/GetUserLoginById", :namespace_identifier => "typens" } },
19
+ { :get_all_contacts => { :input => "GetAllContacts", :output =>"GetAllContactsResponse", :action => "/api/api/GetAllContacts", :namespace_identifier => "typens" } },
20
+ { :search_user => { :input => "SearchUser", :output =>"SearchUserResponse", :action => "/api/api/SearchUser", :namespace_identifier => "typens" } }
21
+ )
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: savon295.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:savon295).read }
7
+
8
+ its(:operations) do
9
+ should include(
10
+ { :sendsms => { :input => "sendsmsRequest", :output => "sendsmsResponse", :action => "sendsms", :namespace_identifier => "tns" } }
11
+ )
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: soap12.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:soap12).read }
7
+
8
+ its(:endpoint) { should == URI("http://blogsite.example.com/endpoint12") }
9
+
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+ context "with: two_bindings.wsdl" do
5
+
6
+ subject { Wasabi::Document.new fixture(:two_bindings).read }
7
+
8
+ its(:element_form_default) { should == :unqualified }
9
+
10
+ it { should have(3).operations }
11
+
12
+ its(:operations) do
13
+ should include(
14
+ { :post => { :input => "Post", :action => "Post" } },
15
+ { :post11only => { :input => "Post11only", :action => "Post11only" } },
16
+ { :post12only => { :input => "Post12only", :action => "Post12only" } }
17
+ )
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Document do
4
+
5
+ subject { Wasabi::Document.new fixture(:authentication).read }
6
+
7
+ it "accepts a URL" do
8
+ HTTPI.should_receive(:get) { HTTPI::Response.new(200, {}, "wsdl") }
9
+
10
+ document = Wasabi::Document.new("http://example.com?wsdl")
11
+ document.xml.should == "wsdl"
12
+ end
13
+
14
+ it "accepts a path" do
15
+ document = Wasabi::Document.new fixture(:authentication).path
16
+ document.xml.should == fixture(:authentication).read
17
+ end
18
+
19
+ it "accepts raw XML" do
20
+ document = Wasabi::Document.new fixture(:authentication).read
21
+ document.xml.should == fixture(:authentication).read
22
+ end
23
+
24
+ describe ".validate_element_form_default!" do
25
+ [:unqualified, :qualified].each do |value|
26
+ it "does not raise for :#{value}" do
27
+ expect { Wasabi::Document.validate_element_form_default!(value) }.to_not raise_error
28
+ end
29
+ end
30
+
31
+ it "raises if given an invalid value" do
32
+ error_msg = "Invalid value for elementFormDefault: invalid\n" +
33
+ "Must be one of: [:unqualified, :qualified]"
34
+
35
+ expect { Wasabi::Document.validate_element_form_default!(:invalid) }.
36
+ to raise_error(ArgumentError, error_msg)
37
+ end
38
+ end
39
+
40
+ describe "#element_form_default" do
41
+ it "defaults to :unqualified" do
42
+ subject.element_form_default.should == :unqualified
43
+ end
44
+
45
+ [:unqualified, :qualified].each do |value|
46
+ it "accepts :#{value}" do
47
+ subject.element_form_default = value
48
+ subject.element_form_default.should == value
49
+ end
50
+ end
51
+
52
+ it "raises if set to an invalid value" do
53
+ expect { subject.element_form_default = :invalid }.
54
+ to raise_error(ArgumentError, /Invalid value for elementFormDefault/)
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Wasabi::Parser do
4
+ context "with: geotrust.wsdl" do
5
+
6
+ subject do
7
+ parser = Wasabi::Parser.new Nokogiri::XML(xml)
8
+ parser.parse
9
+ parser
10
+ end
11
+
12
+ let(:xml) { fixture(:geotrust).read }
13
+
14
+ it "returns the #service_name attribute" do
15
+ subject.service_name.should == "queryDefinitions"
16
+ end
17
+
18
+ end
19
+ end