sekken 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +11 -0
- data/.yardopts +6 -0
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +27 -0
- data/MIT-LICENSE +20 -0
- data/README.md +28 -0
- data/Rakefile +21 -0
- data/donate.png +0 -0
- data/lib/sekken.rb +75 -0
- data/lib/sekken/envelope.rb +92 -0
- data/lib/sekken/errors.rb +9 -0
- data/lib/sekken/example_message.rb +41 -0
- data/lib/sekken/httpclient.rb +35 -0
- data/lib/sekken/importer.rb +77 -0
- data/lib/sekken/message.rb +135 -0
- data/lib/sekken/operation.rb +100 -0
- data/lib/sekken/resolver.rb +20 -0
- data/lib/sekken/response.rb +50 -0
- data/lib/sekken/version.rb +5 -0
- data/lib/sekken/wsdl.rb +86 -0
- data/lib/sekken/wsdl/binding.rb +64 -0
- data/lib/sekken/wsdl/binding_operation.rb +85 -0
- data/lib/sekken/wsdl/document.rb +83 -0
- data/lib/sekken/wsdl/document_collection.rb +61 -0
- data/lib/sekken/wsdl/input_output.rb +84 -0
- data/lib/sekken/wsdl/message.rb +38 -0
- data/lib/sekken/wsdl/operation.rb +47 -0
- data/lib/sekken/wsdl/port.rb +29 -0
- data/lib/sekken/wsdl/port_type.rb +38 -0
- data/lib/sekken/wsdl/port_type_operation.rb +42 -0
- data/lib/sekken/wsdl/service.rb +55 -0
- data/lib/sekken/xml/attribute.rb +13 -0
- data/lib/sekken/xml/element.rb +82 -0
- data/lib/sekken/xml/element_builder.rb +220 -0
- data/lib/sekken/xs/schema.rb +57 -0
- data/lib/sekken/xs/schema_collection.rb +49 -0
- data/lib/sekken/xs/types.rb +272 -0
- data/sekken.gemspec +42 -0
- data/spec/fixtures/response/another_soap_fault.xml +14 -0
- data/spec/fixtures/response/authentication.xml +14 -0
- data/spec/fixtures/response/header.xml +13 -0
- data/spec/fixtures/response/list.xml +18 -0
- data/spec/fixtures/response/multi_ref.xml +39 -0
- data/spec/fixtures/response/soap_fault.xml +8 -0
- data/spec/fixtures/response/soap_fault12.xml +18 -0
- data/spec/fixtures/response/taxcloud.xml +1 -0
- data/spec/fixtures/wsdl/amazon.wsdl +1920 -0
- data/spec/fixtures/wsdl/arrays_with_attributes.wsdl +117 -0
- data/spec/fixtures/wsdl/authentication.wsdl +63 -0
- data/spec/fixtures/wsdl/awse.wsdl +1510 -0
- data/spec/fixtures/wsdl/betfair.wsdl +2981 -0
- data/spec/fixtures/wsdl/blz_service.wsdl +88 -0
- data/spec/fixtures/wsdl/bookt/bookt.wsdl +11 -0
- data/spec/fixtures/wsdl/bookt/bookt0.xsd +433 -0
- data/spec/fixtures/wsdl/bookt/bookt1.xsd +42 -0
- data/spec/fixtures/wsdl/bookt/bookt10.xsd +38 -0
- data/spec/fixtures/wsdl/bookt/bookt11.xsd +17 -0
- data/spec/fixtures/wsdl/bookt/bookt12.xsd +18 -0
- data/spec/fixtures/wsdl/bookt/bookt13.xsd +22 -0
- data/spec/fixtures/wsdl/bookt/bookt14.xsd +27 -0
- data/spec/fixtures/wsdl/bookt/bookt15.xsd +28 -0
- data/spec/fixtures/wsdl/bookt/bookt2.wsdl +243 -0
- data/spec/fixtures/wsdl/bookt/bookt2.xsd +81 -0
- data/spec/fixtures/wsdl/bookt/bookt3.wsdl +286 -0
- data/spec/fixtures/wsdl/bookt/bookt3.xsd +61 -0
- data/spec/fixtures/wsdl/bookt/bookt4.xsd +35 -0
- data/spec/fixtures/wsdl/bookt/bookt5.xsd +22 -0
- data/spec/fixtures/wsdl/bookt/bookt6.xsd +26 -0
- data/spec/fixtures/wsdl/bookt/bookt7.xsd +18 -0
- data/spec/fixtures/wsdl/bookt/bookt8.xsd +22 -0
- data/spec/fixtures/wsdl/bookt/bookt9.xsd +29 -0
- data/spec/fixtures/wsdl/bronto.wsdl +3285 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange.wsdl +104 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange0.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange1.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange2.wsdl +119 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange2.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange3.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange4.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange5.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange6.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange7.xsd +1 -0
- data/spec/fixtures/wsdl/bydexchange/bydexchange8.xsd +1 -0
- data/spec/fixtures/wsdl/crowd.wsdl +2437 -0
- data/spec/fixtures/wsdl/data_exchange.wsdl +98 -0
- data/spec/fixtures/wsdl/document_literal_wrapped.wsdl +153 -0
- data/spec/fixtures/wsdl/economic.wsdl +65660 -0
- data/spec/fixtures/wsdl/edialog.wsdl +13148 -0
- data/spec/fixtures/wsdl/email_verification.wsdl +394 -0
- data/spec/fixtures/wsdl/equifax.wsdl +794 -0
- data/spec/fixtures/wsdl/geotrust.wsdl +156 -0
- data/spec/fixtures/wsdl/interhome.wsdl +2137 -0
- data/spec/fixtures/wsdl/iws.wsdl +695 -0
- data/spec/fixtures/wsdl/jetairways.wsdl +156 -0
- data/spec/fixtures/wsdl/jira.wsdl +3890 -0
- data/spec/fixtures/wsdl/juniper.wsdl +215 -0
- data/spec/fixtures/wsdl/namespaced_actions.wsdl +307 -0
- data/spec/fixtures/wsdl/oracle.wsdl +3629 -0
- data/spec/fixtures/wsdl/ratp.wsdl +955 -0
- data/spec/fixtures/wsdl/rio2/rio2.wsdl +74 -0
- data/spec/fixtures/wsdl/rio2/rio2_0.wsdl +55 -0
- data/spec/fixtures/wsdl/rio2/rio2_0.xsd +58 -0
- data/spec/fixtures/wsdl/rio2/rio2_1.xsd +41 -0
- data/spec/fixtures/wsdl/rio2/rio2_2.xsd +222 -0
- data/spec/fixtures/wsdl/rio2/rio2_3.xsd +10 -0
- data/spec/fixtures/wsdl/rpc_literal.wsdl +105 -0
- data/spec/fixtures/wsdl/spyne.wsdl +70 -0
- data/spec/fixtures/wsdl/stockquote.wsdl +124 -0
- data/spec/fixtures/wsdl/taxcloud.wsdl +934 -0
- data/spec/fixtures/wsdl/team_software/team_software.wsdl +542 -0
- data/spec/fixtures/wsdl/team_software/team_software0.xsd +448 -0
- data/spec/fixtures/wsdl/team_software/team_software1.xsd +41 -0
- data/spec/fixtures/wsdl/team_software/team_software2.xsd +258 -0
- data/spec/fixtures/wsdl/team_software/team_software3.xsd +14 -0
- data/spec/fixtures/wsdl/telefonkatalogen.wsdl +45 -0
- data/spec/fixtures/wsdl/temperature.wsdl +136 -0
- data/spec/fixtures/wsdl/wasmuth/wasmuth.wsdl +157 -0
- data/spec/fixtures/wsdl/wasmuth/wasmuth1.xsd +210 -0
- data/spec/fixtures/wsdl/wasmuth/wasmuth2.xsd +549 -0
- data/spec/fixtures/wsdl/xignite.wsdl +3470 -0
- data/spec/fixtures/wsdl/yahoo.wsdl +2425 -0
- data/spec/fixtures/wsdl/zanox_export_service.xml +520 -0
- data/spec/integration/amazon_spec.rb +51 -0
- data/spec/integration/authentication_spec.rb +38 -0
- data/spec/integration/awse_spec.rb +95 -0
- data/spec/integration/betfair_spec.rb +179 -0
- data/spec/integration/blz_service_spec.rb +46 -0
- data/spec/integration/bookt_spec.rb +59 -0
- data/spec/integration/bronto_spec.rb +178 -0
- data/spec/integration/bydexchange_spec.rb +40 -0
- data/spec/integration/crowd_spec.rb +44 -0
- data/spec/integration/data_exchange_spec.rb +27 -0
- data/spec/integration/document_literal_spec.rb +104 -0
- data/spec/integration/economic_spec.rb +64 -0
- data/spec/integration/email_verification_spec.rb +82 -0
- data/spec/integration/equifax_spec.rb +216 -0
- data/spec/integration/geotrust_spec.rb +17 -0
- data/spec/integration/interhome_spec.rb +156 -0
- data/spec/integration/iws_spec.rb +27 -0
- data/spec/integration/jetairways_spec.rb +142 -0
- data/spec/integration/jira_spec.rb +27 -0
- data/spec/integration/juniper_spec.rb +20 -0
- data/spec/integration/namespaced_actions_spec.rb +37 -0
- data/spec/integration/oracle_spec.rb +61 -0
- data/spec/integration/ratp_spec.rb +178 -0
- data/spec/integration/rio2_spec.rb +56 -0
- data/spec/integration/rpc_literal_spec.rb +101 -0
- data/spec/integration/spyne_spec.rb +60 -0
- data/spec/integration/stockquote_spec.rb +46 -0
- data/spec/integration/taxcloud_spec.rb +45 -0
- data/spec/integration/team_software_spec.rb +51 -0
- data/spec/integration/telefonkatalogen_spec.rb +42 -0
- data/spec/integration/temperature_spec.rb +71 -0
- data/spec/integration/wasmuth_spec.rb +47 -0
- data/spec/integration/xignite_spec.rb +112 -0
- data/spec/integration/yahoo_spec.rb +116 -0
- data/spec/sekken/httpclient_spec.rb +41 -0
- data/spec/sekken/operation/build_spec.rb +308 -0
- data/spec/sekken/operation/document_literal_spec.rb +53 -0
- data/spec/sekken/operation/example_body_spec.rb +95 -0
- data/spec/sekken/operation/rpc_literal_spec.rb +50 -0
- data/spec/sekken/operation_spec.rb +169 -0
- data/spec/sekken/resolver_spec.rb +38 -0
- data/spec/sekken/response_spec.rb +17 -0
- data/spec/sekken/wsdl/document_spec.rb +191 -0
- data/spec/sekken/wsdl_spec.rb +46 -0
- data/spec/sekken/xs/complex_type_spec.rb +197 -0
- data/spec/sekken/xs/element_spec.rb +82 -0
- data/spec/sekken/xs/simple_type_spec.rb +39 -0
- data/spec/sekken_spec.rb +128 -0
- data/spec/spec_helper.rb +37 -0
- data/spec/support/fixture.rb +19 -0
- data/spec/support/http_mock.rb +43 -0
- metadata +344 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sekken::WSDL do
|
4
|
+
|
5
|
+
subject(:wsdl) { Sekken::WSDL.new fixture('wsdl/authentication'), http_mock }
|
6
|
+
|
7
|
+
let(:operation_name) { 'authenticate' }
|
8
|
+
let(:service_name) { 'AuthenticationWebServiceImplService' }
|
9
|
+
let(:port_name) { 'AuthenticationWebServiceImplPort' }
|
10
|
+
|
11
|
+
describe '#service_name' do
|
12
|
+
it 'returns the name of the service' do
|
13
|
+
expect(wsdl.service_name).to eq('AuthenticationWebServiceImplService')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#services' do
|
18
|
+
it 'returns a map of services and ports' do
|
19
|
+
expect(wsdl.services).to eq(
|
20
|
+
'AuthenticationWebServiceImplService' => {
|
21
|
+
:ports => {
|
22
|
+
'AuthenticationWebServiceImplPort' => {
|
23
|
+
:type => 'http://schemas.xmlsoap.org/wsdl/soap/',
|
24
|
+
:location => 'http://example.com/validation/1.0/AuthenticationService'
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#operations' do
|
33
|
+
it 'returns an Array of operation names' do
|
34
|
+
operations = wsdl.operations(service_name, port_name)
|
35
|
+
expect(operations).to eq([operation_name])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#operation' do
|
40
|
+
it 'returns a single operation by name' do
|
41
|
+
operation = wsdl.operation(service_name, port_name, operation_name)
|
42
|
+
expect(operation).to be_a(Sekken::WSDL::Operation)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sekken::XS::ComplexType do
|
4
|
+
|
5
|
+
specify 'all/element' do
|
6
|
+
complex_type = new_complex_type('
|
7
|
+
<xs:complexType name="MpUser" xmlns="http://www.w3.org/2001/XMLSchema">
|
8
|
+
<xs:all>
|
9
|
+
<xs:element name="speciality" type="xs:string"/>
|
10
|
+
<xs:element name="firstname" type="xs:string"/>
|
11
|
+
<xs:element name="lastname" type="xs:string"/>
|
12
|
+
<xs:element name="login" type="xs:string"/>
|
13
|
+
</xs:all>
|
14
|
+
</xs:complexType>
|
15
|
+
')
|
16
|
+
|
17
|
+
expect(complex_type).to be_a(Sekken::XS::ComplexType)
|
18
|
+
|
19
|
+
all = complex_type.children.first
|
20
|
+
expect(all).to be_a(Sekken::XS::All)
|
21
|
+
|
22
|
+
elements = all.children
|
23
|
+
expect(elements.count).to eq(4)
|
24
|
+
|
25
|
+
elements.each do |element|
|
26
|
+
expect(element).to be_a(Sekken::XS::Element)
|
27
|
+
end
|
28
|
+
|
29
|
+
element_names = elements.map(&:name)
|
30
|
+
expect(element_names).to eq(%w[speciality firstname lastname login])
|
31
|
+
|
32
|
+
expect(complex_type.collect_child_elements).to eq(elements)
|
33
|
+
end
|
34
|
+
|
35
|
+
specify 'complexContent/extension/sequence/element' do
|
36
|
+
base_type = new_complex_type('
|
37
|
+
<complexType name="baseObject">
|
38
|
+
<sequence>
|
39
|
+
<element minOccurs="0" maxOccurs="unbounded" name="ExemptState" nillable="true" type="tns:ExemptState" />
|
40
|
+
</sequence>
|
41
|
+
</complexType>
|
42
|
+
')
|
43
|
+
|
44
|
+
# mock the schemas for #collect_child_elements
|
45
|
+
schemas = mock('schemas')
|
46
|
+
schemas.expects(:complex_type).with('http://example.com/ons', 'baseObject').returns(base_type)
|
47
|
+
|
48
|
+
complex_type = new_complex_type('
|
49
|
+
<complexType name="Account" xmlns="http://www.w3.org/2001/XMLSchema"
|
50
|
+
xmlns:ons="http://example.com/ons"
|
51
|
+
xmlns:ens="http://example.com/ens">
|
52
|
+
<complexContent>
|
53
|
+
<extension base="ons:baseObject">
|
54
|
+
<sequence>
|
55
|
+
<element minOccurs="0" name="Description" nillable="true" type="string" />
|
56
|
+
<element minOccurs="0" name="ProcessId" nillable="true" type="ens:ID" />
|
57
|
+
<element minOccurs="0" name="CreatedDate" nillable="true" type="dateTime" />
|
58
|
+
</sequence>
|
59
|
+
</extension>
|
60
|
+
</complexContent>
|
61
|
+
</complexType>
|
62
|
+
', schemas)
|
63
|
+
|
64
|
+
expect(complex_type).to be_a(Sekken::XS::ComplexType)
|
65
|
+
|
66
|
+
complex_content = complex_type.children.first
|
67
|
+
expect(complex_content).to be_a(Sekken::XS::ComplexContent)
|
68
|
+
|
69
|
+
extension = complex_content.children.first
|
70
|
+
expect(extension).to be_a(Sekken::XS::Extension)
|
71
|
+
|
72
|
+
expect(extension['base']).to eq('ons:baseObject')
|
73
|
+
|
74
|
+
sequence = extension.children.first
|
75
|
+
expect(sequence).to be_a(Sekken::XS::Sequence)
|
76
|
+
|
77
|
+
sequence_elements = sequence.children
|
78
|
+
expect(sequence_elements.count).to eq(3)
|
79
|
+
|
80
|
+
expect(sequence_elements[0]).to be_a(Sekken::XS::Element)
|
81
|
+
expect(sequence_elements[0].name).to eq('Description')
|
82
|
+
|
83
|
+
expect(sequence_elements[1]).to be_a(Sekken::XS::Element)
|
84
|
+
expect(sequence_elements[1].name).to eq('ProcessId')
|
85
|
+
|
86
|
+
expect(sequence_elements[1].type).to eq('ens:ID')
|
87
|
+
expect(sequence_elements[1].namespaces).to include('xmlns:ens' => 'http://example.com/ens')
|
88
|
+
|
89
|
+
expect(sequence_elements[2]).to be_a(Sekken::XS::Element)
|
90
|
+
expect(sequence_elements[2].name).to eq('CreatedDate')
|
91
|
+
|
92
|
+
# complex_type#collect_child_elements resolves extensions
|
93
|
+
extension_elements = base_type.elements
|
94
|
+
all_elements = extension_elements + sequence_elements
|
95
|
+
|
96
|
+
expect(complex_type.collect_child_elements).to eq(all_elements)
|
97
|
+
end
|
98
|
+
|
99
|
+
specify 'complexType/simpleContent/attribute (plus annotations)' do
|
100
|
+
complex_type = new_complex_type('
|
101
|
+
<xs:complexType name="MeasureType">
|
102
|
+
<xs:annotation>
|
103
|
+
<xs:documentation>
|
104
|
+
Basic type for specifying measures and the system of measurement.
|
105
|
+
</xs:documentation>
|
106
|
+
</xs:annotation>
|
107
|
+
<xs:simpleContent>
|
108
|
+
<xs:extension base="xs:decimal">
|
109
|
+
<xs:attribute name="unit" type="xs:token" use="optional">
|
110
|
+
<xs:annotation>
|
111
|
+
<xs:documentation>
|
112
|
+
Unit of measure. This attribute is shared by various fields,
|
113
|
+
representing units such as lbs, oz, kg, g, in, cm.
|
114
|
+
</xs:documentation>
|
115
|
+
<xs:appinfo>
|
116
|
+
<CallInfo>
|
117
|
+
<CallName>AddItem</CallName>
|
118
|
+
<CallName>AddItems</CallName>
|
119
|
+
<RequiredInput>No</RequiredInput>
|
120
|
+
</CallInfo>
|
121
|
+
<CallInfo>
|
122
|
+
<CallName>GetItemShipping</CallName>
|
123
|
+
<CallName>GetSellerTransactions</CallName>
|
124
|
+
<CallName>GetShippingDiscountProfiles</CallName>
|
125
|
+
<Returned>Conditionally</Returned>
|
126
|
+
</CallInfo>
|
127
|
+
<CallInfo>
|
128
|
+
<CallName>GetItem</CallName>
|
129
|
+
<Details>DetailLevel: none, ItemReturnDescription, ItemReturnAttributes, ReturnAll</Details>
|
130
|
+
<Returned>Conditionally</Returned>
|
131
|
+
</CallInfo>
|
132
|
+
</xs:appinfo>
|
133
|
+
</xs:annotation>
|
134
|
+
</xs:attribute>
|
135
|
+
</xs:extension>
|
136
|
+
</xs:simpleContent>
|
137
|
+
</xs:complexType>
|
138
|
+
')
|
139
|
+
|
140
|
+
expect(complex_type).to be_a(Sekken::XS::ComplexType)
|
141
|
+
expect(complex_type.collect_child_elements).to be_empty
|
142
|
+
end
|
143
|
+
|
144
|
+
specify 'complexType/sequence/element/simpleType' do
|
145
|
+
complex_type = new_complex_type('
|
146
|
+
<xsd:complexType name="JobStats">
|
147
|
+
<xsd:sequence>
|
148
|
+
<xsd:element name="jobID" type="xsd:integer"/>
|
149
|
+
<xsd:element name="jobType" type="xsd:string"/>
|
150
|
+
<xsd:element name="jobState">
|
151
|
+
<xsd:simpleType>
|
152
|
+
<xsd:restriction base="xsd:string">
|
153
|
+
<xsd:enumeration value="Running"/>
|
154
|
+
<xsd:enumeration value="Finished"/>
|
155
|
+
<xsd:enumeration value="Error"/>
|
156
|
+
<xsd:enumeration value="Queued"/>
|
157
|
+
<xsd:enumeration value="Cancelled"/>
|
158
|
+
</xsd:restriction>
|
159
|
+
</xsd:simpleType>
|
160
|
+
</xsd:element>
|
161
|
+
</xsd:sequence>
|
162
|
+
</xsd:complexType>
|
163
|
+
')
|
164
|
+
|
165
|
+
expect(complex_type).to be_a(Sekken::XS::ComplexType)
|
166
|
+
|
167
|
+
elements = complex_type.collect_child_elements
|
168
|
+
expect(elements.count).to eq(3)
|
169
|
+
|
170
|
+
expect(elements[0].type).to eq('xsd:integer')
|
171
|
+
expect(elements[1].type).to eq('xsd:string')
|
172
|
+
|
173
|
+
expect(elements[2].type).to be_nil
|
174
|
+
expect(elements[2].inline_type).to be_a(Sekken::XS::SimpleType)
|
175
|
+
expect(elements[2].inline_type.base).to eq('xsd:string')
|
176
|
+
end
|
177
|
+
|
178
|
+
specify 'complexType/sequence' do
|
179
|
+
complex_type = new_complex_type('
|
180
|
+
<xs:complexType name="paypal">
|
181
|
+
<xs:sequence/>
|
182
|
+
</xs:complexType>
|
183
|
+
')
|
184
|
+
|
185
|
+
expect(complex_type).to be_a(Sekken::XS::ComplexType)
|
186
|
+
expect(complex_type).to be_empty
|
187
|
+
end
|
188
|
+
|
189
|
+
def new_complex_type(xml, schemas = nil)
|
190
|
+
node = Nokogiri.XML(xml).root
|
191
|
+
schemas ||= mock('schemas')
|
192
|
+
schema = {}
|
193
|
+
|
194
|
+
Sekken::XS::ComplexType.new(node, schemas, schema)
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sekken::XS::Element do
|
4
|
+
|
5
|
+
specify 'complexType/sequence/element' do
|
6
|
+
element = new_element('
|
7
|
+
<xs:element name="TermOfPayment" xmlns="http://www.w3.org/2001/XMLSchema"
|
8
|
+
xmlns:tns="http://example.com">
|
9
|
+
<xs:complexType>
|
10
|
+
<xs:sequence>
|
11
|
+
<xs:element minOccurs="0" maxOccurs="1" name="termOfPaymentHandle" type="tns:TermOfPaymentHandle" />
|
12
|
+
<xs:element minOccurs="1" maxOccurs="1" name="value" nillable="true" type="xs:decimal" />
|
13
|
+
</xs:sequence>
|
14
|
+
</xs:complexType>
|
15
|
+
</xs:element>
|
16
|
+
')
|
17
|
+
|
18
|
+
expect(element).to be_a(Sekken::XS::Element)
|
19
|
+
|
20
|
+
complex_type = element.children.first
|
21
|
+
expect(complex_type).to be_a(Sekken::XS::ComplexType)
|
22
|
+
|
23
|
+
sequence = complex_type.children.first
|
24
|
+
expect(sequence).to be_a(Sekken::XS::Sequence)
|
25
|
+
|
26
|
+
elements = sequence.children
|
27
|
+
expect(elements.count).to eq(2)
|
28
|
+
|
29
|
+
expect(elements[0]).to be_a(Sekken::XS::Element)
|
30
|
+
expect(elements[0].name).to eq('termOfPaymentHandle')
|
31
|
+
|
32
|
+
expect(elements[1]).to be_a(Sekken::XS::Element)
|
33
|
+
expect(elements[1].name).to eq('value')
|
34
|
+
|
35
|
+
expect(element.collect_child_elements).to eq(elements)
|
36
|
+
end
|
37
|
+
|
38
|
+
specify 'element/complexType/sequence/choice/element' do
|
39
|
+
element = new_element('
|
40
|
+
<xs:element name="source">
|
41
|
+
<xs:complexType>
|
42
|
+
<xs:sequence>
|
43
|
+
<xs:choice minOccurs="1">
|
44
|
+
<xs:element name="account" type="tns:id"/>
|
45
|
+
<xs:element name="linkedExternalAccountId" type="tns:id"/>
|
46
|
+
<xs:element name="newExternalAccount" type="tns:collectExternalAccount"/>
|
47
|
+
</xs:choice>
|
48
|
+
</xs:sequence>
|
49
|
+
</xs:complexType>
|
50
|
+
</xs:element>
|
51
|
+
')
|
52
|
+
|
53
|
+
expect(element).to be_a(Sekken::XS::Element)
|
54
|
+
expect(element.collect_child_elements.count).to eq(3)
|
55
|
+
end
|
56
|
+
|
57
|
+
specify 'element/complexType/sequence/choice/element' do
|
58
|
+
element = new_element('
|
59
|
+
<xsd:element name="commandGroup">
|
60
|
+
<xsd:simpleType>
|
61
|
+
<xsd:restriction base="xsd:string"/>
|
62
|
+
</xsd:simpleType>
|
63
|
+
</xsd:element>
|
64
|
+
')
|
65
|
+
|
66
|
+
expect(element).to be_a(Sekken::XS::Element)
|
67
|
+
|
68
|
+
expect(element.collect_child_elements).to be_empty
|
69
|
+
expect(element.type).to be_nil
|
70
|
+
expect(element.inline_type).to be_a(Sekken::XS::SimpleType)
|
71
|
+
expect(element.inline_type.base).to eq('xsd:string')
|
72
|
+
end
|
73
|
+
|
74
|
+
def new_element(xml)
|
75
|
+
node = Nokogiri.XML(xml).root
|
76
|
+
schemas ||= mock('schemas')
|
77
|
+
schema = {}
|
78
|
+
|
79
|
+
Sekken::XS::Element.new(node, schemas, schema)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sekken::XS::SimpleType do
|
4
|
+
|
5
|
+
specify 'complexType/sequence/element' do
|
6
|
+
simple_type = new_simple_type('
|
7
|
+
<xs:simpleType name="TemperatureUnit" xmlns="http://www.w3.org/2001/XMLSchema">
|
8
|
+
<xs:restriction base="xs:string">
|
9
|
+
<xs:enumeration value="degreeCelsius" />
|
10
|
+
<xs:enumeration value="degreeFahrenheit" />
|
11
|
+
<xs:enumeration value="degreeRankine" />
|
12
|
+
<xs:enumeration value="degreeReaumur" />
|
13
|
+
<xs:enumeration value="kelvin" />
|
14
|
+
</xs:restriction>
|
15
|
+
</xs:simpleType>
|
16
|
+
')
|
17
|
+
|
18
|
+
expect(simple_type).to be_a(Sekken::XS::SimpleType)
|
19
|
+
|
20
|
+
restriction = simple_type.children.first
|
21
|
+
expect(restriction).to be_a(Sekken::XS::Restriction)
|
22
|
+
|
23
|
+
enums = restriction.children
|
24
|
+
expect(enums.count).to eq(5)
|
25
|
+
|
26
|
+
enums.each do |enum|
|
27
|
+
expect(enum).to be_a(Sekken::XS::Enumeration)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def new_simple_type(xml)
|
32
|
+
node = Nokogiri.XML(xml).root
|
33
|
+
schemas ||= mock('schemas')
|
34
|
+
schema = {}
|
35
|
+
|
36
|
+
Sekken::XS::SimpleType.new(node, schemas, schema)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/spec/sekken_spec.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sekken do
|
4
|
+
|
5
|
+
subject(:client) { Sekken.new(wsdl, http_mock) }
|
6
|
+
|
7
|
+
let(:wsdl) { fixture('wsdl/amazon') }
|
8
|
+
|
9
|
+
let(:service_name) { 'AmazonFPS' }
|
10
|
+
let(:port_name) { 'AmazonFPSPort' }
|
11
|
+
let(:operation_name) { 'Pay' }
|
12
|
+
|
13
|
+
describe '.http_adapter' do
|
14
|
+
it 'returns the default HTTP client to use' do
|
15
|
+
expect(Sekken.http_adapter).to eq(Sekken::HTTPClient)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'can be changed to use a custom adapter' do
|
19
|
+
adapter = mock('http-adapter')
|
20
|
+
|
21
|
+
Sekken.http_adapter = adapter
|
22
|
+
expect(Sekken.http_adapter).to eq(adapter)
|
23
|
+
|
24
|
+
adapter.expects(:new).returns(adapter)
|
25
|
+
adapter.expects(:client).returns('http-client')
|
26
|
+
|
27
|
+
client = Sekken.new(wsdl)
|
28
|
+
expect(client.http).to eq('http-client')
|
29
|
+
|
30
|
+
# reset global state!
|
31
|
+
Sekken.http_adapter = nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '.new' do
|
36
|
+
it 'expects a local or remote WSDL document' do
|
37
|
+
Sekken::WSDL.expects(:new).with(wsdl, instance_of(Sekken.http_adapter)).returns(:wasabi)
|
38
|
+
Sekken.new(wsdl)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'also accepts a custom HTTP adapter to replace the default' do
|
42
|
+
http = :my_http_adapter
|
43
|
+
Sekken::WSDL.expects(:new).with(wsdl, http).returns(:wasabi)
|
44
|
+
|
45
|
+
Sekken.new(wsdl, http)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#wsdl' do
|
50
|
+
it 'returns the WSDL' do
|
51
|
+
expect(client.wsdl).to be_an_instance_of(Sekken::WSDL)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#http' do
|
56
|
+
it 'returns the HTTP adapter\'s client to configure' do
|
57
|
+
client = Sekken.new(wsdl)
|
58
|
+
expect(client.http).to be_an_instance_of(HTTPClient)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#services' do
|
63
|
+
it 'returns the services and ports defined by the WSDL' do
|
64
|
+
expect(client.services).to eq(
|
65
|
+
'AmazonFPS' => {
|
66
|
+
ports: {
|
67
|
+
'AmazonFPSPort' => {
|
68
|
+
type: 'http://schemas.xmlsoap.org/wsdl/soap/',
|
69
|
+
location: 'https://fps.amazonaws.com'
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#operations' do
|
78
|
+
it 'returns an Array of operations for a service and port' do
|
79
|
+
operations = client.operations(service_name, port_name)
|
80
|
+
|
81
|
+
expect(operations.count).to eq(25)
|
82
|
+
expect(operations).to include('GetAccountBalance', 'GetTransaction', 'SettleDebt')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'also accepts symbols for the service and port name' do
|
86
|
+
operations = client.operations(:AmazonFPS, :AmazonFPSPort)
|
87
|
+
expect(operations.count).to eq(25)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'raises if the service could not be found' do
|
91
|
+
expect { client.operations(:UnknownService, :UnknownPort) }.
|
92
|
+
to raise_error(ArgumentError, /Unknown service "UnknownService"/)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'raises if the port could not be found' do
|
96
|
+
expect { client.operations(service_name, :UnknownPort) }.
|
97
|
+
to raise_error(ArgumentError, /Unknown service "AmazonFPS" or port "UnknownPort"/)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#operation' do
|
102
|
+
it 'returns an Operation by service, port and operation name' do
|
103
|
+
operation = client.operation(service_name, port_name, operation_name)
|
104
|
+
expect(operation).to be_a(Sekken::Operation)
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'also accepts symbols for the service, port and operation name' do
|
108
|
+
operation = client.operation(:AmazonFPS, :AmazonFPSPort, :Pay)
|
109
|
+
expect(operation).to be_a(Sekken::Operation)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'raises if the service could not be found' do
|
113
|
+
expect { client.operation(:UnknownService, :UnknownPort, :UnknownOperation) }.
|
114
|
+
to raise_error(ArgumentError, /Unknown service "UnknownService"/)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'raises if the port could not be found' do
|
118
|
+
expect { client.operation(service_name, :UnknownPort, :UnknownOperation) }.
|
119
|
+
to raise_error(ArgumentError, /Unknown service "AmazonFPS" or port "UnknownPort"/)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'raises if the operation could not be found' do
|
123
|
+
expect { client.operation(service_name, port_name, :UnknownOperation) }.
|
124
|
+
to raise_error(ArgumentError, /Unknown operation "UnknownOperation" for service "AmazonFPS" and port "AmazonFPSPort"/)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|