razorrisk-razor-connectivity 0.14.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +89 -0
- data/lib/razor_risk/razor/connectivity/clarite_2/config_maker.rb +162 -0
- data/lib/razor_risk/razor/connectivity/exceptions.rb +101 -0
- data/lib/razor_risk/razor/connectivity/razor_3/body_maker.rb +126 -0
- data/lib/razor_risk/razor/connectivity/razor_3/header_maker.rb +273 -0
- data/lib/razor_risk/razor/connectivity/razor_3/message_map.rb +156 -0
- data/lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb +559 -0
- data/lib/razor_risk/razor/connectivity/razor_3/response.rb +224 -0
- data/lib/razor_risk/razor/connectivity/razor_3.rb +5 -0
- data/lib/razor_risk/razor/connectivity/version.rb +40 -0
- data/test/bin/razor_request_exe_empty_response.rb +28 -0
- data/test/unit/connectivity/clarite_2/tc_config_maker.rb +399 -0
- data/test/unit/connectivity/razor_3/tc_body_maker.rb +164 -0
- data/test/unit/connectivity/razor_3/tc_header_maker.rb +652 -0
- data/test/unit/connectivity/razor_3/tc_message_map.rb +125 -0
- data/test/unit/connectivity/razor_3/tc_razor_requester.rb +244 -0
- data/test/unit/connectivity/razor_3/tc_razor_requester_executable.rb +176 -0
- data/test/unit/connectivity/razor_3/tc_response.rb +239 -0
- metadata +158 -0
@@ -0,0 +1,239 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
# ##########################################################################
|
5
|
+
#
|
6
|
+
# Copyright (c) 2017 Razor Risk Technologies Pty Limited. All rights reserved.
|
7
|
+
#
|
8
|
+
# ##########################################################################
|
9
|
+
|
10
|
+
|
11
|
+
# ##########################################################
|
12
|
+
# load path
|
13
|
+
|
14
|
+
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 4), 'lib')
|
15
|
+
|
16
|
+
|
17
|
+
# ##########################################################
|
18
|
+
# diagnostics
|
19
|
+
|
20
|
+
unless $DEBUG
|
21
|
+
|
22
|
+
require 'pantheios/globals'
|
23
|
+
require 'pantheios/services/null_log_service'
|
24
|
+
|
25
|
+
::Pantheios::Globals.INITIAL_SERVICE_CLASSES = [ ::Pantheios::Services::NullLogService ]
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
# ##########################################################
|
30
|
+
# code coverage
|
31
|
+
|
32
|
+
require 'simplecov'
|
33
|
+
|
34
|
+
|
35
|
+
# ##########################################################
|
36
|
+
# requires
|
37
|
+
|
38
|
+
require 'razor_risk/razor/connectivity/razor_3/response'
|
39
|
+
|
40
|
+
require 'nokogiri'
|
41
|
+
require 'xqsr3/extensions/test/unit'
|
42
|
+
|
43
|
+
require 'test/unit'
|
44
|
+
require 'time'
|
45
|
+
|
46
|
+
|
47
|
+
# ##########################################################
|
48
|
+
# tests
|
49
|
+
|
50
|
+
class Test_Response < Test::Unit::TestCase
|
51
|
+
|
52
|
+
include ::RazorRisk::Razor::Connectivity::Razor3
|
53
|
+
|
54
|
+
def test_type_exists_and_is_a_class
|
55
|
+
|
56
|
+
assert defined? ::RazorRisk
|
57
|
+
assert defined? ::RazorRisk::Razor
|
58
|
+
assert defined? ::RazorRisk::Razor::Connectivity
|
59
|
+
assert defined? ::RazorRisk::Razor::Connectivity::Razor3
|
60
|
+
assert defined? ::RazorRisk::Razor::Connectivity::Razor3::Response
|
61
|
+
assert Response.is_a? ::Class
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_construct_from_nil
|
65
|
+
|
66
|
+
assert_raise(::ArgumentError) { Response.new nil }
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_construct_from_string
|
70
|
+
|
71
|
+
assert_raise(::TypeError) { Response.new '' }
|
72
|
+
assert_raise(::TypeError) { Response.new '<?xml version="1.0" encoding=utf-8" ?>' }
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_construct_from_simplest
|
76
|
+
|
77
|
+
input = <<END_OF_xml
|
78
|
+
<razorOutbound environment="QA_TRUNK_PROD" request="razorLog" server="CreditRiskServer">
|
79
|
+
<returnCode>ack</returnCode>
|
80
|
+
<requestReceivedTime>2017-03-16 10:50:54.927</requestReceivedTime>
|
81
|
+
<responseSentTime>2017-03-16 10:50:55.005</responseSentTime>
|
82
|
+
<responseReceivedTime>2017-03-16 10:51:01.543</responseReceivedTime>
|
83
|
+
<caller>RazorRequest</caller>
|
84
|
+
<body/>
|
85
|
+
</razorOutbound>
|
86
|
+
END_OF_xml
|
87
|
+
|
88
|
+
xml = Nokogiri::XML input
|
89
|
+
|
90
|
+
response = Response.new xml
|
91
|
+
|
92
|
+
assert_kind_of Nokogiri::XML::Element, response.body
|
93
|
+
assert_equal %Q<<?xml version=\"1.0\"?>\n#{input}>, response.to_s
|
94
|
+
assert_empty response.body.text.to_s
|
95
|
+
assert_empty response.body.children
|
96
|
+
assert_nil response.errors
|
97
|
+
assert_equal 'RazorRequest', response.caller
|
98
|
+
assert_equal DateTime.new(2017, 3, 16, 10, 50, 54.927), response.request_received_time
|
99
|
+
assert_equal DateTime.new(2017, 3, 16, 10, 50, 55.005), response.response_sent_time
|
100
|
+
assert_equal DateTime.new(2017, 3, 16, 10, 51, 1.543), response.response_received_time
|
101
|
+
|
102
|
+
assert_equal 'ack', response.result_code
|
103
|
+
assert_equal '', response.razor_code
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
def test_construct_from_complex
|
108
|
+
|
109
|
+
input = <<END_OF_xml
|
110
|
+
<razorOutbound environment="QA_TRUNK_PROD" request="batchSummaries" server="CreditRiskServer">
|
111
|
+
<returnCode>ack</returnCode>
|
112
|
+
<requestReceivedTime>2017-03-16 10:48:50.939</requestReceivedTime>
|
113
|
+
<responseSentTime>2017-03-16 10:48:50.955</responseSentTime>
|
114
|
+
<responseReceivedTime>2017-03-16 10:48:59.779</responseReceivedTime>
|
115
|
+
<caller>RazorRequest</caller>
|
116
|
+
<body><batchSummary sysId="4"><batchNumber>0</batchNumber><processedTradeCount>875</processedTradeCount><rejectedTradeCount>0</rejectedTradeCount><excludedTradeCount>0</excludedTradeCount><errorCount>3</errorCount><beginTime>2017-02-17 16:17:05</beginTime><endTime>2017-02-17 16:17:26</endTime></batchSummary></body></razorOutbound>
|
117
|
+
END_OF_xml
|
118
|
+
|
119
|
+
xml = Nokogiri::XML input
|
120
|
+
|
121
|
+
response = Response.new xml
|
122
|
+
|
123
|
+
assert_kind_of Nokogiri::XML::Element, response.body
|
124
|
+
assert_equal %Q<<?xml version=\"1.0\"?>\n#{input}>, response.to_s
|
125
|
+
assert_not_empty response.body.text.to_s
|
126
|
+
assert_not_empty response.body.children
|
127
|
+
assert_nil response.errors
|
128
|
+
assert_equal 'RazorRequest', response.caller
|
129
|
+
assert_equal DateTime.new(2017, 3, 16, 10, 48, 50.939), response.request_received_time
|
130
|
+
assert_equal DateTime.new(2017, 3, 16, 10, 48, 50.955), response.response_sent_time
|
131
|
+
assert_equal DateTime.new(2017, 3, 16, 10, 48, 59.779), response.response_received_time
|
132
|
+
|
133
|
+
assert_equal 'ack', response.result_code
|
134
|
+
assert_equal '', response.razor_code
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_construct_from_nack_response
|
138
|
+
|
139
|
+
input = <<END_OF_xml
|
140
|
+
<razorOutbound>
|
141
|
+
<returnCode>nack</returnCode>
|
142
|
+
</razorOutbound>
|
143
|
+
END_OF_xml
|
144
|
+
|
145
|
+
xml = Nokogiri::XML input
|
146
|
+
|
147
|
+
response = Response.new xml
|
148
|
+
|
149
|
+
assert_nil response.body
|
150
|
+
assert_equal %Q<<?xml version=\"1.0\"?>\n#{input}>, response.to_s
|
151
|
+
assert_nil response.errors
|
152
|
+
assert_nil response.caller
|
153
|
+
assert_nil response.request_received_time
|
154
|
+
assert_nil response.response_sent_time
|
155
|
+
assert_nil response.response_received_time
|
156
|
+
|
157
|
+
assert_equal 'nack', response.result_code
|
158
|
+
assert_equal '', response.razor_code
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_construct_from_nack_response_with_one_error
|
162
|
+
|
163
|
+
input = <<END_OF_xml
|
164
|
+
<razorOutbound environment="RZ01" request="insertPortfolios" server="PortfolioExposureServer">
|
165
|
+
<returnCode>nack</returnCode>
|
166
|
+
<requestReceivedTime>2018-04-10 11:16:17.192</requestReceivedTime>
|
167
|
+
<responseSentTime>2018-04-10 11:16:17.232</responseSentTime>
|
168
|
+
<responseReceivedTime>2018-04-10 11:16:16.539</responseReceivedTime>
|
169
|
+
<caller>RazorRequest</caller>
|
170
|
+
<errors>
|
171
|
+
<error>
|
172
|
+
<code>RZ0010</code>
|
173
|
+
<message>Duplicate record</message>
|
174
|
+
<details>Found duplicate portfolio 50 (Portfolio Name Newly Added Portfolios (by Matt))</details>
|
175
|
+
</error>
|
176
|
+
</errors>
|
177
|
+
</razorOutbound>
|
178
|
+
END_OF_xml
|
179
|
+
|
180
|
+
xml = Nokogiri.XML(input)
|
181
|
+
|
182
|
+
response = Response.new xml
|
183
|
+
|
184
|
+
assert_nil response.body
|
185
|
+
assert_equal 1, response.reasons.size
|
186
|
+
assert_equal 'RZ0010', response.reasons[0].code
|
187
|
+
assert_equal 'Duplicate record', response.reasons[0].message
|
188
|
+
assert response.reasons.lookup?('RZ0010')
|
189
|
+
assert response.reasons.lookup?(response.reasons[0])
|
190
|
+
assert !response.reasons.lookup?('RZ0011')
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_construct_from_nack_response_with_two_errors
|
195
|
+
|
196
|
+
input = <<END_OF_xml
|
197
|
+
<razorOutbound environment="RZ01" request="insertPortfolios" server="PortfolioExposureServer">
|
198
|
+
<returnCode>nack</returnCode>
|
199
|
+
<requestReceivedTime>2018-04-10 11:16:17.192</requestReceivedTime>
|
200
|
+
<responseSentTime>2018-04-10 11:16:17.232</responseSentTime>
|
201
|
+
<responseReceivedTime>2018-04-10 11:16:16.539</responseReceivedTime>
|
202
|
+
<caller>RazorRequest</caller>
|
203
|
+
<errors>
|
204
|
+
<error>
|
205
|
+
<code>RZ0010</code>
|
206
|
+
<message>Duplicate record</message>
|
207
|
+
<details>Found duplicate portfolio 50 (Portfolio Name Newly Added Portfolios (by Matt))</details>
|
208
|
+
</error>
|
209
|
+
<error>
|
210
|
+
<code>RZ0011</code>
|
211
|
+
<message>Operation on non-existent record</message>
|
212
|
+
<details>Found duplicate portfolio 50 (Portfolio Name Newly Added Portfolios (by Matt))</details>
|
213
|
+
</error>
|
214
|
+
</errors>
|
215
|
+
</razorOutbound>
|
216
|
+
END_OF_xml
|
217
|
+
|
218
|
+
xml = Nokogiri.XML(input)
|
219
|
+
|
220
|
+
response = Response.new xml
|
221
|
+
|
222
|
+
assert_nil response.body
|
223
|
+
assert_equal 2, response.reasons.size
|
224
|
+
assert_equal 'RZ0010', response.reasons[0].code
|
225
|
+
assert_equal 'Duplicate record', response.reasons[0].message
|
226
|
+
assert_equal 'RZ0011', response.reasons[1].code
|
227
|
+
assert_equal 'Operation on non-existent record', response.reasons[1].message
|
228
|
+
assert response.reasons.lookup?('RZ0010')
|
229
|
+
assert response.reasons.lookup?('RZ0011')
|
230
|
+
assert response.reasons.lookup?(response.reasons[0])
|
231
|
+
assert response.reasons.lookup?(response.reasons[1])
|
232
|
+
assert !response.reasons.lookup?('RZ0012')
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# ############################## end of file ############################# #
|
238
|
+
|
239
|
+
|
metadata
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: razorrisk-razor-connectivity
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.14.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Razor Risk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: razorrisk-core-baseutilities
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: razorrisk-core-diagnostics
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: razorrisk-core-system
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pantheios-ruby
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.20.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.20.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: recls-ruby
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.9'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.9'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: xqsr3
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.30'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.30'
|
111
|
+
description: Razor Risk's Razor Connectivity library
|
112
|
+
email: operations@razor-risk.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- Rakefile
|
118
|
+
- lib/razor_risk/razor/connectivity/clarite_2/config_maker.rb
|
119
|
+
- lib/razor_risk/razor/connectivity/exceptions.rb
|
120
|
+
- lib/razor_risk/razor/connectivity/razor_3.rb
|
121
|
+
- lib/razor_risk/razor/connectivity/razor_3/body_maker.rb
|
122
|
+
- lib/razor_risk/razor/connectivity/razor_3/header_maker.rb
|
123
|
+
- lib/razor_risk/razor/connectivity/razor_3/message_map.rb
|
124
|
+
- lib/razor_risk/razor/connectivity/razor_3/razor_requester.rb
|
125
|
+
- lib/razor_risk/razor/connectivity/razor_3/response.rb
|
126
|
+
- lib/razor_risk/razor/connectivity/version.rb
|
127
|
+
- test/bin/razor_request_exe_empty_response.rb
|
128
|
+
- test/unit/connectivity/clarite_2/tc_config_maker.rb
|
129
|
+
- test/unit/connectivity/razor_3/tc_body_maker.rb
|
130
|
+
- test/unit/connectivity/razor_3/tc_header_maker.rb
|
131
|
+
- test/unit/connectivity/razor_3/tc_message_map.rb
|
132
|
+
- test/unit/connectivity/razor_3/tc_razor_requester.rb
|
133
|
+
- test/unit/connectivity/razor_3/tc_razor_requester_executable.rb
|
134
|
+
- test/unit/connectivity/razor_3/tc_response.rb
|
135
|
+
homepage: https://razor-risk.com/
|
136
|
+
licenses: []
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.6.14
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: RazorRisk.Ruby.Razor.Connectivity
|
158
|
+
test_files: []
|