sekken 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +11 -0
  4. data/.yardopts +6 -0
  5. data/CONTRIBUTING.md +46 -0
  6. data/Gemfile +27 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +28 -0
  9. data/Rakefile +21 -0
  10. data/donate.png +0 -0
  11. data/lib/sekken.rb +75 -0
  12. data/lib/sekken/envelope.rb +92 -0
  13. data/lib/sekken/errors.rb +9 -0
  14. data/lib/sekken/example_message.rb +41 -0
  15. data/lib/sekken/httpclient.rb +35 -0
  16. data/lib/sekken/importer.rb +77 -0
  17. data/lib/sekken/message.rb +135 -0
  18. data/lib/sekken/operation.rb +100 -0
  19. data/lib/sekken/resolver.rb +20 -0
  20. data/lib/sekken/response.rb +50 -0
  21. data/lib/sekken/version.rb +5 -0
  22. data/lib/sekken/wsdl.rb +86 -0
  23. data/lib/sekken/wsdl/binding.rb +64 -0
  24. data/lib/sekken/wsdl/binding_operation.rb +85 -0
  25. data/lib/sekken/wsdl/document.rb +83 -0
  26. data/lib/sekken/wsdl/document_collection.rb +61 -0
  27. data/lib/sekken/wsdl/input_output.rb +84 -0
  28. data/lib/sekken/wsdl/message.rb +38 -0
  29. data/lib/sekken/wsdl/operation.rb +47 -0
  30. data/lib/sekken/wsdl/port.rb +29 -0
  31. data/lib/sekken/wsdl/port_type.rb +38 -0
  32. data/lib/sekken/wsdl/port_type_operation.rb +42 -0
  33. data/lib/sekken/wsdl/service.rb +55 -0
  34. data/lib/sekken/xml/attribute.rb +13 -0
  35. data/lib/sekken/xml/element.rb +82 -0
  36. data/lib/sekken/xml/element_builder.rb +220 -0
  37. data/lib/sekken/xs/schema.rb +57 -0
  38. data/lib/sekken/xs/schema_collection.rb +49 -0
  39. data/lib/sekken/xs/types.rb +272 -0
  40. data/sekken.gemspec +42 -0
  41. data/spec/fixtures/response/another_soap_fault.xml +14 -0
  42. data/spec/fixtures/response/authentication.xml +14 -0
  43. data/spec/fixtures/response/header.xml +13 -0
  44. data/spec/fixtures/response/list.xml +18 -0
  45. data/spec/fixtures/response/multi_ref.xml +39 -0
  46. data/spec/fixtures/response/soap_fault.xml +8 -0
  47. data/spec/fixtures/response/soap_fault12.xml +18 -0
  48. data/spec/fixtures/response/taxcloud.xml +1 -0
  49. data/spec/fixtures/wsdl/amazon.wsdl +1920 -0
  50. data/spec/fixtures/wsdl/arrays_with_attributes.wsdl +117 -0
  51. data/spec/fixtures/wsdl/authentication.wsdl +63 -0
  52. data/spec/fixtures/wsdl/awse.wsdl +1510 -0
  53. data/spec/fixtures/wsdl/betfair.wsdl +2981 -0
  54. data/spec/fixtures/wsdl/blz_service.wsdl +88 -0
  55. data/spec/fixtures/wsdl/bookt/bookt.wsdl +11 -0
  56. data/spec/fixtures/wsdl/bookt/bookt0.xsd +433 -0
  57. data/spec/fixtures/wsdl/bookt/bookt1.xsd +42 -0
  58. data/spec/fixtures/wsdl/bookt/bookt10.xsd +38 -0
  59. data/spec/fixtures/wsdl/bookt/bookt11.xsd +17 -0
  60. data/spec/fixtures/wsdl/bookt/bookt12.xsd +18 -0
  61. data/spec/fixtures/wsdl/bookt/bookt13.xsd +22 -0
  62. data/spec/fixtures/wsdl/bookt/bookt14.xsd +27 -0
  63. data/spec/fixtures/wsdl/bookt/bookt15.xsd +28 -0
  64. data/spec/fixtures/wsdl/bookt/bookt2.wsdl +243 -0
  65. data/spec/fixtures/wsdl/bookt/bookt2.xsd +81 -0
  66. data/spec/fixtures/wsdl/bookt/bookt3.wsdl +286 -0
  67. data/spec/fixtures/wsdl/bookt/bookt3.xsd +61 -0
  68. data/spec/fixtures/wsdl/bookt/bookt4.xsd +35 -0
  69. data/spec/fixtures/wsdl/bookt/bookt5.xsd +22 -0
  70. data/spec/fixtures/wsdl/bookt/bookt6.xsd +26 -0
  71. data/spec/fixtures/wsdl/bookt/bookt7.xsd +18 -0
  72. data/spec/fixtures/wsdl/bookt/bookt8.xsd +22 -0
  73. data/spec/fixtures/wsdl/bookt/bookt9.xsd +29 -0
  74. data/spec/fixtures/wsdl/bronto.wsdl +3285 -0
  75. data/spec/fixtures/wsdl/bydexchange/bydexchange.wsdl +104 -0
  76. data/spec/fixtures/wsdl/bydexchange/bydexchange0.xsd +1 -0
  77. data/spec/fixtures/wsdl/bydexchange/bydexchange1.xsd +1 -0
  78. data/spec/fixtures/wsdl/bydexchange/bydexchange2.wsdl +119 -0
  79. data/spec/fixtures/wsdl/bydexchange/bydexchange2.xsd +1 -0
  80. data/spec/fixtures/wsdl/bydexchange/bydexchange3.xsd +1 -0
  81. data/spec/fixtures/wsdl/bydexchange/bydexchange4.xsd +1 -0
  82. data/spec/fixtures/wsdl/bydexchange/bydexchange5.xsd +1 -0
  83. data/spec/fixtures/wsdl/bydexchange/bydexchange6.xsd +1 -0
  84. data/spec/fixtures/wsdl/bydexchange/bydexchange7.xsd +1 -0
  85. data/spec/fixtures/wsdl/bydexchange/bydexchange8.xsd +1 -0
  86. data/spec/fixtures/wsdl/crowd.wsdl +2437 -0
  87. data/spec/fixtures/wsdl/data_exchange.wsdl +98 -0
  88. data/spec/fixtures/wsdl/document_literal_wrapped.wsdl +153 -0
  89. data/spec/fixtures/wsdl/economic.wsdl +65660 -0
  90. data/spec/fixtures/wsdl/edialog.wsdl +13148 -0
  91. data/spec/fixtures/wsdl/email_verification.wsdl +394 -0
  92. data/spec/fixtures/wsdl/equifax.wsdl +794 -0
  93. data/spec/fixtures/wsdl/geotrust.wsdl +156 -0
  94. data/spec/fixtures/wsdl/interhome.wsdl +2137 -0
  95. data/spec/fixtures/wsdl/iws.wsdl +695 -0
  96. data/spec/fixtures/wsdl/jetairways.wsdl +156 -0
  97. data/spec/fixtures/wsdl/jira.wsdl +3890 -0
  98. data/spec/fixtures/wsdl/juniper.wsdl +215 -0
  99. data/spec/fixtures/wsdl/namespaced_actions.wsdl +307 -0
  100. data/spec/fixtures/wsdl/oracle.wsdl +3629 -0
  101. data/spec/fixtures/wsdl/ratp.wsdl +955 -0
  102. data/spec/fixtures/wsdl/rio2/rio2.wsdl +74 -0
  103. data/spec/fixtures/wsdl/rio2/rio2_0.wsdl +55 -0
  104. data/spec/fixtures/wsdl/rio2/rio2_0.xsd +58 -0
  105. data/spec/fixtures/wsdl/rio2/rio2_1.xsd +41 -0
  106. data/spec/fixtures/wsdl/rio2/rio2_2.xsd +222 -0
  107. data/spec/fixtures/wsdl/rio2/rio2_3.xsd +10 -0
  108. data/spec/fixtures/wsdl/rpc_literal.wsdl +105 -0
  109. data/spec/fixtures/wsdl/spyne.wsdl +70 -0
  110. data/spec/fixtures/wsdl/stockquote.wsdl +124 -0
  111. data/spec/fixtures/wsdl/taxcloud.wsdl +934 -0
  112. data/spec/fixtures/wsdl/team_software/team_software.wsdl +542 -0
  113. data/spec/fixtures/wsdl/team_software/team_software0.xsd +448 -0
  114. data/spec/fixtures/wsdl/team_software/team_software1.xsd +41 -0
  115. data/spec/fixtures/wsdl/team_software/team_software2.xsd +258 -0
  116. data/spec/fixtures/wsdl/team_software/team_software3.xsd +14 -0
  117. data/spec/fixtures/wsdl/telefonkatalogen.wsdl +45 -0
  118. data/spec/fixtures/wsdl/temperature.wsdl +136 -0
  119. data/spec/fixtures/wsdl/wasmuth/wasmuth.wsdl +157 -0
  120. data/spec/fixtures/wsdl/wasmuth/wasmuth1.xsd +210 -0
  121. data/spec/fixtures/wsdl/wasmuth/wasmuth2.xsd +549 -0
  122. data/spec/fixtures/wsdl/xignite.wsdl +3470 -0
  123. data/spec/fixtures/wsdl/yahoo.wsdl +2425 -0
  124. data/spec/fixtures/wsdl/zanox_export_service.xml +520 -0
  125. data/spec/integration/amazon_spec.rb +51 -0
  126. data/spec/integration/authentication_spec.rb +38 -0
  127. data/spec/integration/awse_spec.rb +95 -0
  128. data/spec/integration/betfair_spec.rb +179 -0
  129. data/spec/integration/blz_service_spec.rb +46 -0
  130. data/spec/integration/bookt_spec.rb +59 -0
  131. data/spec/integration/bronto_spec.rb +178 -0
  132. data/spec/integration/bydexchange_spec.rb +40 -0
  133. data/spec/integration/crowd_spec.rb +44 -0
  134. data/spec/integration/data_exchange_spec.rb +27 -0
  135. data/spec/integration/document_literal_spec.rb +104 -0
  136. data/spec/integration/economic_spec.rb +64 -0
  137. data/spec/integration/email_verification_spec.rb +82 -0
  138. data/spec/integration/equifax_spec.rb +216 -0
  139. data/spec/integration/geotrust_spec.rb +17 -0
  140. data/spec/integration/interhome_spec.rb +156 -0
  141. data/spec/integration/iws_spec.rb +27 -0
  142. data/spec/integration/jetairways_spec.rb +142 -0
  143. data/spec/integration/jira_spec.rb +27 -0
  144. data/spec/integration/juniper_spec.rb +20 -0
  145. data/spec/integration/namespaced_actions_spec.rb +37 -0
  146. data/spec/integration/oracle_spec.rb +61 -0
  147. data/spec/integration/ratp_spec.rb +178 -0
  148. data/spec/integration/rio2_spec.rb +56 -0
  149. data/spec/integration/rpc_literal_spec.rb +101 -0
  150. data/spec/integration/spyne_spec.rb +60 -0
  151. data/spec/integration/stockquote_spec.rb +46 -0
  152. data/spec/integration/taxcloud_spec.rb +45 -0
  153. data/spec/integration/team_software_spec.rb +51 -0
  154. data/spec/integration/telefonkatalogen_spec.rb +42 -0
  155. data/spec/integration/temperature_spec.rb +71 -0
  156. data/spec/integration/wasmuth_spec.rb +47 -0
  157. data/spec/integration/xignite_spec.rb +112 -0
  158. data/spec/integration/yahoo_spec.rb +116 -0
  159. data/spec/sekken/httpclient_spec.rb +41 -0
  160. data/spec/sekken/operation/build_spec.rb +308 -0
  161. data/spec/sekken/operation/document_literal_spec.rb +53 -0
  162. data/spec/sekken/operation/example_body_spec.rb +95 -0
  163. data/spec/sekken/operation/rpc_literal_spec.rb +50 -0
  164. data/spec/sekken/operation_spec.rb +169 -0
  165. data/spec/sekken/resolver_spec.rb +38 -0
  166. data/spec/sekken/response_spec.rb +17 -0
  167. data/spec/sekken/wsdl/document_spec.rb +191 -0
  168. data/spec/sekken/wsdl_spec.rb +46 -0
  169. data/spec/sekken/xs/complex_type_spec.rb +197 -0
  170. data/spec/sekken/xs/element_spec.rb +82 -0
  171. data/spec/sekken/xs/simple_type_spec.rb +39 -0
  172. data/spec/sekken_spec.rb +128 -0
  173. data/spec/spec_helper.rb +37 -0
  174. data/spec/support/fixture.rb +19 -0
  175. data/spec/support/http_mock.rb +43 -0
  176. metadata +344 -0
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::Operation do
4
+
5
+ # namespace reference:
6
+ # http://www.ibm.com/developerworks/webservices/library/ws-tip-namespace/index.html
7
+ context 'with a document/literal wrapped document' do
8
+ it 'works for op1' do
9
+ client = Sekken.new fixture('wsdl/document_literal_wrapped')
10
+
11
+ op1 = client.operation('SampleService', 'Sample', 'op1')
12
+ expect(op1.input_style).to eq('document/literal')
13
+
14
+ expect(op1.body_parts).to eq([
15
+ [ ['op1'], { namespace: 'http://apiNamespace.com', form: 'qualified', singular: true } ],
16
+ [ ['op1', 'in'], { namespace: 'http://apiNamespace.com', form: 'unqualified', singular: true } ],
17
+ [ ['op1', 'in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
18
+ [ ['op1', 'in', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ]
19
+ ])
20
+ end
21
+
22
+ it 'works for op2' do
23
+ client = Sekken.new fixture('wsdl/document_literal_wrapped')
24
+
25
+ op2 = client.operation('SampleService', 'Sample', 'op2')
26
+ expect(op2.input_style).to eq('document/literal')
27
+
28
+ expect(op2.body_parts).to eq([
29
+ [ ['op2'], { namespace: 'http://apiNamespace.com', form: 'qualified', singular: true } ],
30
+ [ ['op2', 'in'], { namespace: 'http://apiNamespace.com', form: 'unqualified', singular: true } ],
31
+ [ ['op2', 'in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
32
+ [ ['op2', 'in', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ]
33
+ ])
34
+ end
35
+
36
+ it 'works for op3' do
37
+ client = Sekken.new fixture('wsdl/document_literal_wrapped')
38
+
39
+ op3 = client.operation('SampleService', 'Sample', 'op3')
40
+ expect(op3.input_style).to eq('document/literal')
41
+
42
+ expect(op3.body_parts).to eq([
43
+ [ ['op3'], { namespace: 'http://apiNamespace.com', form: 'qualified', singular: true } ],
44
+ [ ['op3', 'DataElem'], { namespace: 'http://dataNamespace.com', form: 'qualified', singular: true } ],
45
+ [ ['op3', 'DataElem', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
46
+ [ ['op3', 'DataElem', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
47
+ [ ['op3', 'in2'], { namespace: 'http://apiNamespace.com', form: 'unqualified', singular: true } ],
48
+ [ ['op3', 'in2', 'RefDataElem'], { namespace: 'http://refNamespace.com', form: 'qualified', singular: true, type: 'int' } ],
49
+ ])
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,95 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::Operation do
4
+
5
+ let(:add_logins) {
6
+ client = Sekken.new fixture('wsdl/bronto')
7
+
8
+ service_name = :BrontoSoapApiImplService
9
+ port_name = :BrontoSoapApiImplPort
10
+
11
+ client.operation(service_name, port_name, :addLogins)
12
+ }
13
+
14
+ let(:get_mu_bets_lite) {
15
+ client = Sekken.new fixture('wsdl/betfair')
16
+
17
+ service_name = port_name = :BFExchangeService
18
+ client.operation(service_name, port_name, :getMUBetsLite)
19
+ }
20
+
21
+ describe '#example_body' do
22
+ it 'returns an Array with a single Hash for Arrays of complex types' do
23
+ expect(add_logins.example_body).to eq(
24
+ addLogins: {
25
+
26
+ # array of complex types
27
+ accounts: [
28
+ {
29
+ username: 'string',
30
+ password: 'string',
31
+ contactInformation: {
32
+ organization: 'string',
33
+ firstName: 'string',
34
+ lastName: 'string',
35
+ email: 'string',
36
+ phone: 'string',
37
+ address: 'string',
38
+ address2: 'string',
39
+ city: 'string',
40
+ state: 'string',
41
+ zip: 'string',
42
+ country: 'string',
43
+ notes: 'string'
44
+ },
45
+ permissionAgencyAdmin: 'boolean',
46
+ permissionAdmin: 'boolean',
47
+ permissionApi: 'boolean',
48
+ permissionUpgrade: 'boolean',
49
+ permissionFatigueOverride: 'boolean',
50
+ permissionMessageCompose: 'boolean',
51
+ permissionMessageApprove: 'boolean',
52
+ permissionMessageDelete: 'boolean',
53
+ permissionAutomatorCompose: 'boolean',
54
+ permissionListCreateSend: 'boolean',
55
+ permissionListCreate: 'boolean',
56
+ permissionSegmentCreate: 'boolean',
57
+ permissionFieldCreate: 'boolean',
58
+ permissionFieldReorder: 'boolean',
59
+ permissionSubscriberCreate: 'boolean',
60
+ permissionSubscriberView: 'boolean'
61
+ }
62
+ ]
63
+ }
64
+ )
65
+ end
66
+
67
+ it 'returns an Array with a single simple type for Arrays of simple types' do
68
+ expect(get_mu_bets_lite.example_body).to eq(
69
+ getMUBetsLite: {
70
+ request: {
71
+ header: {
72
+ clientStamp: 'long',
73
+ sessionToken: 'string'
74
+ },
75
+ betStatus: 'string',
76
+ marketId: 'int',
77
+ betIds: {
78
+
79
+ # array of simple types
80
+ betId: ['long']
81
+
82
+ },
83
+ orderBy: 'string',
84
+ sortOrder: 'string',
85
+ recordCount: 'int',
86
+ startRecord: 'int',
87
+ matchedSince: 'dateTime',
88
+ excludeLastSecond: 'boolean'
89
+ }
90
+ }
91
+ )
92
+ end
93
+ end
94
+
95
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::Operation do
4
+
5
+ # namespace reference:
6
+ # http://www.ibm.com/developerworks/webservices/library/ws-tip-namespace/index.html
7
+ context 'with an rpc/literal document' do
8
+ it 'qualifies the RPC wrapper with the soap:body namespace' do
9
+ client = Sekken.new fixture('wsdl/rpc_literal')
10
+
11
+ op1 = client.operation('SampleService', 'Sample', 'op1')
12
+ expect(op1.input_style).to eq('rpc/literal')
13
+
14
+ expect(op1.body_parts).to eq([
15
+ [ ['in'], { namespace: nil, form: 'unqualified', singular: true } ],
16
+ [ ['in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
17
+ [ ['in', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ]
18
+ ])
19
+ end
20
+
21
+ it 'qualifies the RPC wrapper with the soap:body namespace (which differs from the tns)' do
22
+ client = Sekken.new fixture('wsdl/rpc_literal')
23
+
24
+ op2 = client.operation('SampleService', 'Sample', 'op2')
25
+ expect(op2.input_style).to eq('rpc/literal')
26
+
27
+ expect(op2.body_parts).to eq([
28
+ [ ['in'], { namespace: nil, form: 'unqualified', singular: true } ],
29
+ [ ['in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
30
+ [ ['in', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ]
31
+ ])
32
+ end
33
+
34
+ it 'does not qualify the RPC wrapper without a soap:body namespace and follows element refs' do
35
+ client = Sekken.new fixture('wsdl/rpc_literal')
36
+
37
+ op3 = client.operation('SampleService', 'Sample', 'op3')
38
+ expect(op3.input_style).to eq('rpc/literal')
39
+
40
+ expect(op3.body_parts).to eq([
41
+ [ ['DataElem'], { namespace: 'http://dataNamespace.com', form: 'qualified', singular: true } ],
42
+ [ ['DataElem', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
43
+ [ ['DataElem', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ],
44
+ [ ['in2'], { namespace: nil, form: 'unqualified', singular: true } ],
45
+ [ ['in2', 'RefDataElem'], { namespace: 'http://refNamespace.com', form: 'qualified', singular: true, type: 'int' } ],
46
+ ])
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,169 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::Operation do
4
+
5
+ subject(:operation) { Sekken::Operation.new(wsdl_operation, wsdl, http_mock) }
6
+
7
+ let(:wsdl) { Sekken::WSDL.new fixture('wsdl/temperature'), http_mock }
8
+ let(:wsdl_operation) { wsdl.operation('ConvertTemperature', 'ConvertTemperatureSoap12', 'ConvertTemp') }
9
+
10
+ describe '#endpoint' do
11
+ it 'returns the SOAP endpoint' do
12
+ expect(operation.endpoint).to eq('http://www.webservicex.net/ConvertTemperature.asmx')
13
+ end
14
+
15
+ it 'can be overwritten' do
16
+ operation.endpoint = 'http://example.com'
17
+ expect(operation.endpoint).to eq('http://example.com')
18
+ end
19
+ end
20
+
21
+ describe '#soap_version' do
22
+ it 'returns the SOAP version determined by the service and port' do
23
+ expect(operation.soap_version).to eq('1.2')
24
+ end
25
+
26
+ it 'can be overwritten' do
27
+ operation.soap_version = '1.1'
28
+ expect(operation.soap_version).to eq('1.1')
29
+ end
30
+ end
31
+
32
+ describe '#soap_action' do
33
+ it 'returns the SOAP action for the operation' do
34
+ expect(operation.soap_action).to eq('http://www.webserviceX.NET/ConvertTemp')
35
+ end
36
+
37
+ it 'can be overwritten' do
38
+ operation.soap_action = 'ConvertSomething'
39
+ expect(operation.soap_action).to eq('ConvertSomething')
40
+ end
41
+ end
42
+
43
+ describe '#encoding' do
44
+ it 'defaults to UTF-8' do
45
+ expect(operation.encoding).to eq('UTF-8')
46
+ end
47
+
48
+ it 'can be overwritten' do
49
+ operation.encoding = 'US-ASCII'
50
+ expect(operation.encoding).to eq('US-ASCII')
51
+ end
52
+ end
53
+
54
+ describe '#http_headers' do
55
+ it 'returns a Hash of HTTP headers for a SOAP 1.2 operation' do
56
+ expect(operation.http_headers).to eq(
57
+ 'SOAPAction' => '"http://www.webserviceX.NET/ConvertTemp"',
58
+ 'Content-Type' => 'application/soap+xml;charset=UTF-8'
59
+ )
60
+ end
61
+
62
+ it 'returns a Hash of HTTP headers for a SOAP 1.1 operation' do
63
+ wsdl_operation = wsdl.operation('ConvertTemperature', 'ConvertTemperatureSoap', 'ConvertTemp')
64
+ operation = Sekken::Operation.new(wsdl_operation, wsdl, http_mock)
65
+
66
+ expect(operation.http_headers).to eq(
67
+ 'SOAPAction' => '"http://www.webserviceX.NET/ConvertTemp"',
68
+ 'Content-Type' => 'text/xml;charset=UTF-8'
69
+ )
70
+ end
71
+
72
+ it 'can be overwritten' do
73
+ headers = { 'SecretToken' => 'abc'}
74
+ operation.http_headers = headers
75
+
76
+ expect(operation.http_headers).to eq(headers)
77
+ end
78
+ end
79
+
80
+ describe '#example_request' do
81
+ it 'returns an example request Hash following Sekken\'s conventions' do
82
+ expect(operation.example_body).to eq(
83
+ ConvertTemp: {
84
+ Temperature: 'double',
85
+ FromUnit: 'string',
86
+ ToUnit: 'string'
87
+ }
88
+ )
89
+ end
90
+ end
91
+
92
+ describe '#build' do
93
+ it 'returns an example request Hash following Sekken\'s conventions' do
94
+ operation.body = {
95
+ ConvertTemp: {
96
+ Temperature: 30,
97
+ FromUnit: 'degreeCelsius',
98
+ ToUnit: 'degreeFahrenheit'
99
+ }
100
+ }
101
+
102
+ expected = Nokogiri.XML(%{
103
+ <env:Envelope
104
+ xmlns:lol0="http://www.webserviceX.NET/"
105
+ xmlns:env="http://www.w3.org/2003/05/soap-envelope">
106
+ <env:Header/>
107
+ <env:Body>
108
+ <lol0:ConvertTemp>
109
+ <lol0:Temperature>30</lol0:Temperature>
110
+ <lol0:FromUnit>degreeCelsius</lol0:FromUnit>
111
+ <lol0:ToUnit>degreeFahrenheit</lol0:ToUnit>
112
+ </lol0:ConvertTemp>
113
+ </env:Body>
114
+ </env:Envelope>
115
+ })
116
+
117
+ expect(operation.build).
118
+ to be_equivalent_to(expected).respecting_element_order
119
+ end
120
+ end
121
+
122
+ describe '#xml_envelope' do
123
+ let(:xml) do
124
+ '<?xml version="1.0" encoding="UTF-8"?>
125
+ <Envelope>
126
+ <Body>
127
+ <VerifySignature>
128
+ <UrlEndPoint></UrlEndPoint>
129
+ <HttpParameters></HttpParameters>
130
+ </VerifySignature>
131
+ </Body>
132
+ </Envelope>'
133
+ end
134
+
135
+ it 'returns the xml request' do
136
+ http_mock.fake_request('http://www.webservicex.net/ConvertTemperature.asmx')
137
+ operation.xml_envelope = xml
138
+
139
+ expect(operation.xml_envelope).to eq(xml)
140
+ end
141
+
142
+ it 'returns a Sekken response object' do
143
+ http_mock.fake_request('http://www.webservicex.net/ConvertTemperature.asmx')
144
+ operation.xml_envelope = xml
145
+
146
+ response = operation.call
147
+ expect(response).to be_a(Sekken::Response)
148
+ end
149
+ end
150
+
151
+ describe '#call' do
152
+ it 'calls the operation with a Hash of options and returns a Response' do
153
+ http_mock.fake_request('http://www.webservicex.net/ConvertTemperature.asmx')
154
+
155
+ operation.body = {
156
+ ConvertTemp: {
157
+ Temperature: 30,
158
+ FromUnit: 'degreeCelsius',
159
+ ToUnit: 'degreeFahrenheit'
160
+ }
161
+ }
162
+
163
+ response = operation.call
164
+
165
+ expect(response).to be_a(Sekken::Response)
166
+ end
167
+ end
168
+
169
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::Resolver do
4
+
5
+ subject(:resolver) { Sekken::Resolver.new(http_test_client) }
6
+
7
+ let(:http_test_client) {
8
+ Class.new {
9
+
10
+ def get(url)
11
+ "raw_response for #{url}"
12
+ end
13
+
14
+ }.new
15
+ }
16
+
17
+ it 'resolves remote files using a simple HTTP client interface' do
18
+ url = 'http://example.com?wsdl'
19
+
20
+ xml = resolver.resolve(url)
21
+ expect(xml).to eq("raw_response for #{url}")
22
+ end
23
+
24
+ it 'resolves local files' do
25
+ fixture = fixture('wsdl/authentication')
26
+
27
+ xml = resolver.resolve(fixture)
28
+ expect(xml).to eq(File.read(fixture))
29
+ end
30
+
31
+ it 'simply returns any raw input' do
32
+ string = '<xml/>'
33
+
34
+ xml = resolver.resolve(string)
35
+ expect(xml).to eq(string)
36
+ end
37
+
38
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::Response do
4
+ subject(:response) do
5
+ response = Sekken::Response.new(nil)
6
+ response.send(:instance_variable_set, :@hash, {
7
+ :envelope => {:header => 'the-spice-must-flow'}
8
+ })
9
+ response
10
+ end
11
+
12
+ describe '#headers' do
13
+ it 'returns the headers for the underlying response' do
14
+ expect(response.header).to eq('the-spice-must-flow')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,191 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sekken::WSDL::Document do
4
+
5
+ describe '#messages' do
6
+ it 'works with single element parts' do
7
+ document = get_documents('wsdl/oracle').first
8
+
9
+ expect(document.messages.keys).to include(
10
+ 'addReportToPageIn', 'addReportToPageOut', 'applyReportDefaultsIn', 'applyReportDefaultsOut'
11
+ )
12
+
13
+ # message
14
+
15
+ message = document.messages['addReportToPageIn']
16
+ expect(message.name).to eq('addReportToPageIn')
17
+
18
+ namespaces = {
19
+ 'xmlns:sawsoap' => 'urn://oracle.bi.webservices/v7',
20
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
21
+ 'xmlns:wsdl' => 'http://schemas.xmlsoap.org/wsdl/',
22
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'
23
+ }
24
+
25
+ expect(message.parts).to eq([
26
+ { :name => 'parameters', :namespaces => namespaces,
27
+ :type => nil, :element => 'sawsoap:addReportToPage' }
28
+ ])
29
+ end
30
+
31
+ it 'works with multiple type parts' do
32
+ document = get_documents('wsdl/telefonkatalogen').first
33
+
34
+ expect(document.messages.keys).to include(
35
+ 'sendsmsRequest', 'sendsmsResponse'
36
+ )
37
+
38
+ # message
39
+
40
+ message = document.messages['sendsmsRequest']
41
+ expect(message.name).to eq('sendsmsRequest')
42
+
43
+ namespaces = {
44
+ 'xmlns:tns' => 'http://bedrift.telefonkatalogen.no',
45
+ 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
46
+ 'xmlns:soap' => 'http://schemas.xmlsoap.org/wsdl/soap/',
47
+ 'xmlns' => 'http://schemas.xmlsoap.org/wsdl/'
48
+ }
49
+
50
+ expect(message.parts).to eq([
51
+ { :name => 'sender', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
52
+ { :name => 'cellular', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
53
+ { :name => 'msg', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
54
+ { :name => 'smsnumgroup', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
55
+ { :name => 'emailaddr', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
56
+ { :name => 'udh', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
57
+ { :name => 'datetime', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
58
+ { :name => 'format', :namespaces => namespaces, :type => 'xsd:string', :element => nil },
59
+ { :name => 'dlrurl', :namespaces => namespaces, :type => 'xsd:string', :element => nil }
60
+ ])
61
+ end
62
+ end
63
+
64
+ describe '#port_types' do
65
+ it 'works with multiple bindings' do
66
+ document = get_documents('wsdl/oracle').first
67
+
68
+ expect(document.port_types.keys).to match_array([
69
+ 'ConditionServiceSoap', 'HtmlViewServiceSoap', 'IBotServiceSoap',
70
+ 'JobManagementServiceSoap', 'MetadataServiceSoap', 'ReplicationServiceSoap',
71
+ 'ReportEditingServiceSoap', 'SAWSessionServiceSoap', 'SecurityServiceSoap',
72
+ 'WebCatalogServiceSoap', 'XmlViewServiceSoap'
73
+ ])
74
+
75
+ # port type
76
+
77
+ port_type = document.port_types['IBotServiceSoap']
78
+ expect(port_type.name).to eq('IBotServiceSoap')
79
+
80
+ expect(port_type.operations.keys).to match_array([
81
+ "deleteIBot", "executeIBotNow", "moveIBot", "sendMessage",
82
+ "subscribe", "unsubscribe", "writeIBot"
83
+ ])
84
+
85
+ # port type operation
86
+
87
+ port_type_operation = port_type.operations['moveIBot']
88
+ expect(port_type_operation.name).to eq('moveIBot')
89
+
90
+ expect(port_type_operation.input).to eq(:name => nil, :message => 'sawsoap:moveIBotIn')
91
+ expect(port_type_operation.output).to eq(:name => nil, :message => 'sawsoap:moveIBotOut')
92
+ end
93
+ end
94
+
95
+ describe '#bindings' do
96
+ it 'works with multiple bindings' do
97
+ document = get_documents('wsdl/oracle').first
98
+
99
+ expect(document.bindings.keys).to match_array([
100
+ 'ConditionService', 'HtmlViewService', 'IBotService', 'JobManagementService',
101
+ 'MetadataService', 'ReplicationService', 'ReportEditingService', 'SAWSessionService',
102
+ 'SecurityService', 'WebCatalogService', 'XmlViewService'
103
+ ])
104
+
105
+ # binding
106
+
107
+ binding = document.bindings['SecurityService']
108
+
109
+ expect(binding.name).to eq('SecurityService')
110
+ expect(binding.port_type).to eq('sawsoap:SecurityServiceSoap')
111
+ expect(binding.style).to eq('document')
112
+ expect(binding.transport).to eq('http://schemas.xmlsoap.org/soap/http')
113
+
114
+ expect(binding.operations.keys).to match_array([
115
+ 'forgetAccounts', 'getAccountTenantID', 'getAccounts', 'getGlobalPrivilegeACL',
116
+ 'getGlobalPrivileges', 'getGroups', 'getMembers', 'getPermissions', 'getPrivilegesStatus',
117
+ 'isMember', 'joinGroups', 'leaveGroups', 'renameAccounts', 'updateGlobalPrivilegeACL'
118
+ ])
119
+
120
+ # binding operation
121
+
122
+ binding_operation = binding.operations['getAccounts']
123
+ expect(binding_operation.name).to eq('getAccounts')
124
+
125
+ expect(binding_operation.soap_action).to eq('#getAccounts')
126
+ expect(binding_operation.style).to eq('document')
127
+ end
128
+ end
129
+
130
+ describe '#services' do
131
+ it 'works with multiple services' do
132
+ document = get_documents('wsdl/oracle').first
133
+
134
+ expect(document.services.keys).to match_array([
135
+ 'SAWSessionService', 'WebCatalogService', 'XmlViewService', 'SecurityService',
136
+ 'ConditionService', 'HtmlViewService', 'IBotService', 'JobManagementService',
137
+ 'MetadataService', 'ReplicationService', 'ReportEditingService'
138
+ ])
139
+
140
+ service = document.services['ConditionService']
141
+ expect(service.ports.keys).to eq(['ConditionServiceSoap'])
142
+
143
+ # soap 1.1 port
144
+
145
+ soap_port = service.ports['ConditionServiceSoap']
146
+
147
+ expect(soap_port.name).to eq('ConditionServiceSoap')
148
+ expect(soap_port.binding).to eq('sawsoap:ConditionService')
149
+
150
+ expect(soap_port.type).to eq(Sekken::NS_SOAP_1_1)
151
+ expect(soap_port.location).to eq('https://fap0023-bi.oracleads.com/analytics-ws/saw.dll?SoapImpl=conditionService')
152
+ end
153
+
154
+ it 'only knows about the SOAP ports of each service' do
155
+ document = get_documents('wsdl/email_verification').first
156
+
157
+ expect(document.services.keys).to eq(['EmailVerNoTestEmail'])
158
+
159
+ service = document.services['EmailVerNoTestEmail']
160
+ expect(service.ports.keys).to match_array([
161
+ 'EmailVerNoTestEmailSoap', 'EmailVerNoTestEmailSoap12'
162
+ ])
163
+
164
+ # soap 1.1 port
165
+
166
+ soap_1_1_port = service.ports['EmailVerNoTestEmailSoap']
167
+
168
+ expect(soap_1_1_port.name).to eq('EmailVerNoTestEmailSoap')
169
+ expect(soap_1_1_port.binding).to eq('tns:EmailVerNoTestEmailSoap')
170
+
171
+ expect(soap_1_1_port.type).to eq(Sekken::NS_SOAP_1_1)
172
+ expect(soap_1_1_port.location).to eq('http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx')
173
+
174
+ # soap 1.2 port
175
+
176
+ soap_1_2_port = service.ports['EmailVerNoTestEmailSoap12']
177
+
178
+ expect(soap_1_2_port.name).to eq('EmailVerNoTestEmailSoap12')
179
+ expect(soap_1_2_port.binding).to eq('tns:EmailVerNoTestEmailSoap12')
180
+
181
+ expect(soap_1_2_port.type).to eq(Sekken::NS_SOAP_1_2)
182
+ expect(soap_1_2_port.location).to eq('http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx')
183
+ end
184
+ end
185
+
186
+ def get_documents(fixture)
187
+ client = Sekken.new fixture(fixture)
188
+ client.wsdl.documents
189
+ end
190
+
191
+ end