rb-net_http-client 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/client/client.rb +51 -0
- data/lib/client/ext.rb +120 -0
- data/lib/client/schema.rb +38 -0
- data/lib/core/core.rb +75 -0
- data/lib/core/utilities.rb +243 -0
- data/lib/rb-net_http-client.rb +4 -0
- data/lib/request/ext.rb +87 -0
- data/lib/request/schema.rb +20 -0
- data/lib/response/ext.rb +111 -0
- data/lib/version.rb +5 -0
- data/spec/integration/net_http/client/client_ext_spec.rb +7 -0
- data/spec/integration/net_http/client/client_spec.rb +7 -0
- data/spec/integration/net_http/net_http_core_spec.rb +18 -0
- data/spec/integration/net_http/request/request_ext_spec.rb +342 -0
- data/spec/integration/net_http/response/response_ext_spec.rb +7 -0
- data/spec/integration/net_http/version_spec.rb +10 -0
- data/spec/unit/net_http/client/client_ext_spec.rb +7 -0
- data/spec/unit/net_http/client/client_schema_spec.rb +8 -0
- data/spec/unit/net_http/client/client_spec.rb +232 -0
- data/spec/unit/net_http/net_http_core_spec.rb +433 -0
- data/spec/unit/net_http/request/request_ext_spec.rb +603 -0
- data/spec/unit/net_http/request/request_schema_spec.rb +8 -0
- data/spec/unit/net_http/response/response_ext_spec.rb +97 -0
- data/spec/unit/net_http/version_spec.rb +10 -0
- metadata +252 -0
@@ -0,0 +1,603 @@
|
|
1
|
+
require 'webmock/rspec'
|
2
|
+
require_relative '../../../spec_helper'
|
3
|
+
|
4
|
+
describe NetHTTP::Request::Ext do
|
5
|
+
it 'adds NetHTTP::Request::Ext methods to NetHTTP client instances' do
|
6
|
+
client_opts = {}
|
7
|
+
client_opts[:uri] = 'https://www.host.com/path'
|
8
|
+
|
9
|
+
client = NetHTTP.client(client_opts)
|
10
|
+
expect(client.methods.include?(:call_web_service)).to eq(true)
|
11
|
+
expect(client.methods.include?(:call_service)).to eq(true)
|
12
|
+
expect(client.methods.include?(:execute_request)).to eq(true)
|
13
|
+
expect(client.methods.include?(:submit_request)).to eq(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
# delete
|
17
|
+
it 'performs a DELETE request' do
|
18
|
+
stub_request(:any, 'https://www.host.com/path').
|
19
|
+
with(headers: { 'Accept' => '*/*',
|
20
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
21
|
+
'User-Agent' => 'Ruby' }).
|
22
|
+
to_return(status: 200,
|
23
|
+
body: successful_delete_resp_body,
|
24
|
+
headers: { 'Accept' => '*/*',
|
25
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
26
|
+
'User-Agent' => 'Ruby' })
|
27
|
+
|
28
|
+
client = NetHTTP.client(delete_client_opts)
|
29
|
+
resp = client.call_web_service(delete_req_opts)
|
30
|
+
|
31
|
+
expect(resp.code).to eq('200')
|
32
|
+
expect(resp.resp_code).to eq('200')
|
33
|
+
expect(resp.headers.empty?).to eq(false)
|
34
|
+
expect(resp.resp_headers.empty?).to eq(false)
|
35
|
+
expect(resp.headers_hash.empty?).to eq(false)
|
36
|
+
expect(resp.headers_hash.class).to eq(Hash)
|
37
|
+
expect(resp.resp_headers_hash.empty?).to eq(false)
|
38
|
+
expect(resp.resp_headers_hash.class).to eq(Hash)
|
39
|
+
expect(resp.body.empty?).to eq(false)
|
40
|
+
expect(resp.resp_body.empty?).to eq(false)
|
41
|
+
expect(resp.body_hash.empty?).to eq(false)
|
42
|
+
expect(resp.body_hash.class).to eq(Hash)
|
43
|
+
expect(resp.resp_body_hash.empty?).to eq(false)
|
44
|
+
expect(resp.resp_body_hash.class).to eq(Hash)
|
45
|
+
end
|
46
|
+
|
47
|
+
# get
|
48
|
+
it 'performs a GET request' do
|
49
|
+
stub_request(:get, 'http://eelslap.com/').
|
50
|
+
with(headers: { 'Accept' => '*/*',
|
51
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
52
|
+
'User-Agent' => 'Ruby' }).
|
53
|
+
to_return(status: 200,
|
54
|
+
body: successful_get_resp_body,
|
55
|
+
headers: { 'date' => ['Thu, 10 Aug 2017 16:09:56 GMT'],
|
56
|
+
'server' => ['Apache/2.2.22'],
|
57
|
+
'last-modified' => ['Mon, 23 Feb 2015 07:50:04 GMT'],
|
58
|
+
'etag' => ['\'5a06343-d2e-50fbca66d4300\''],
|
59
|
+
'accept-ranges' => ['bytes'],
|
60
|
+
'content-length' => ['3374'],
|
61
|
+
'vary' => ['Accept-Encoding,User-Agent'],
|
62
|
+
'content-type' => ['text/html'],
|
63
|
+
'connection' => ['close'] })
|
64
|
+
|
65
|
+
client = NetHTTP.client(get_client_opts)
|
66
|
+
resp = client.call_web_service(get_req_opts)
|
67
|
+
|
68
|
+
expect(resp.code).to eq('200')
|
69
|
+
expect(resp.resp_code).to eq('200')
|
70
|
+
expect(resp.headers.empty?).to eq(false)
|
71
|
+
expect(resp.resp_headers.empty?).to eq(false)
|
72
|
+
expect(resp.headers_hash.empty?).to eq(false)
|
73
|
+
expect(resp.headers_hash.class).to eq(Hash)
|
74
|
+
expect(resp.resp_headers_hash.empty?).to eq(false)
|
75
|
+
expect(resp.resp_headers_hash.class).to eq(Hash)
|
76
|
+
expect(resp.body).to eq(successful_get_resp_body)
|
77
|
+
expect(resp.valid_html?).to eq(true)
|
78
|
+
expect(resp.body.empty?).to eq(false)
|
79
|
+
expect(resp.resp_body.empty?).to eq(false)
|
80
|
+
expect(resp.body_hash.empty?).to eq(true)
|
81
|
+
expect(resp.body_hash.class).to eq(Hash)
|
82
|
+
expect(resp.resp_body_hash.empty?).to eq(true)
|
83
|
+
expect(resp.resp_body_hash.class).to eq(Hash)
|
84
|
+
end
|
85
|
+
|
86
|
+
# post
|
87
|
+
it 'performs a POST request for a valid oAuth token from ESG' do
|
88
|
+
stub_request(:post, 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner').
|
89
|
+
with(body: successful_post_request_token_req_body,
|
90
|
+
headers: { 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' }).
|
91
|
+
to_return(status: 200,
|
92
|
+
body: successful_post_request_token_resp_body,
|
93
|
+
headers: { 'date' => ['Thu, 10 Aug 2017 14:09:19 GMT'],
|
94
|
+
'server' => [''],
|
95
|
+
'connection' => ['close'],
|
96
|
+
'x-correlationid' => ['Id-0f698c59b97c8df3c572145c 0'],
|
97
|
+
'accept' => ['*/*'],
|
98
|
+
'host' => ['esg-qa-oauth2-internal.fmr.com'],
|
99
|
+
'user-agent' => ['Ruby'],
|
100
|
+
'cache-control' => ['no-store'],
|
101
|
+
'content-type' => ['application/json'],
|
102
|
+
'pragma' => ['no-cache'] })
|
103
|
+
|
104
|
+
client = NetHTTP.client(post_request_token_client_opts)
|
105
|
+
resp = client.call_web_service(post_request_token_req_opts)
|
106
|
+
|
107
|
+
expect(resp.code).to eq('200')
|
108
|
+
expect(resp.resp_code).to eq('200')
|
109
|
+
expect(resp.headers.empty?).to eq(false)
|
110
|
+
expect(resp.resp_headers.empty?).to eq(false)
|
111
|
+
expect(resp.headers_hash.empty?).to eq(false)
|
112
|
+
expect(resp.headers_hash.class).to eq(Hash)
|
113
|
+
expect(resp.resp_headers_hash.empty?).to eq(false)
|
114
|
+
expect(resp.resp_headers_hash.class).to eq(Hash)
|
115
|
+
expect(resp.body).to eq(successful_post_request_token_resp_body)
|
116
|
+
expect(resp.valid_json?).to eq(true)
|
117
|
+
expect(resp.body.empty?).to eq(false)
|
118
|
+
expect(resp.resp_body.empty?).to eq(false)
|
119
|
+
expect(resp.body_hash.empty?).to eq(false)
|
120
|
+
expect(resp.body_hash.class).to eq(Hash)
|
121
|
+
expect(resp.resp_body_hash.empty?).to eq(false)
|
122
|
+
expect(resp.resp_body_hash.class).to eq(Hash)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'performs a POST request to MAUI to retrieve account users using ssl and cert' do
|
126
|
+
stub_request(:post, 'https://alpha-mmk.fmr.com:9980/XML_FEB_S_A').
|
127
|
+
with(body: successful_post_retrieve_account_users_req_body,
|
128
|
+
headers: { 'Content-Type' => 'application/xml' }).
|
129
|
+
to_return(status: 200,
|
130
|
+
body: successful_post_retrieve_account_users_resp_body,
|
131
|
+
headers: { 'date' => ['Fri, 11 Aug 2017 20:03:17 GMT'],
|
132
|
+
'x-powered-by' => ['Servlet/3.0'],
|
133
|
+
'x-maui-client-ip' => ['10.92.2.6'],
|
134
|
+
'x-start-time' => ['[2017 08 11 20:03:17:877]'],
|
135
|
+
'x-view-name' => ['DCLCUST0'],
|
136
|
+
'x-service-name' => ['XML_FEB_S_A'],
|
137
|
+
'x-service-type' => ['SSL'],
|
138
|
+
'x-hostname' => ['mauieart11'],
|
139
|
+
'x-product-code' => ['W'],
|
140
|
+
'x-symbolic-viewname' => ['1DCC060B'],
|
141
|
+
'x-psl-status' => ['1'],
|
142
|
+
'x-inbound-transform-time' => ['0'],
|
143
|
+
'x-request-size' => ['646'],
|
144
|
+
'x-backend-transport-time' => ['1'],
|
145
|
+
'x-backend-processing-time' => ['11'],
|
146
|
+
'x-outbound-transform-time' => ['1'],
|
147
|
+
'x-core-size' => ['1924'],
|
148
|
+
'x-total-request-time' => ['13'],
|
149
|
+
'x-target-plex' => ['DAL_PERSISTENT'],
|
150
|
+
'x-execution-plex' => ['DAL_PERSISTENT'],
|
151
|
+
'x-routing-id' => ['18'],
|
152
|
+
'x-psl-company-number' => ['-'],
|
153
|
+
'x-cross-site-failover' => ['-'],
|
154
|
+
'x-fpsl-sense-code' => ['0000'],
|
155
|
+
'x-cics-exec-region-name' => ['CICFIG1'],
|
156
|
+
'content-length' => ['809'],
|
157
|
+
'content-type' => ['text/xml'],
|
158
|
+
'content-language' => ['en-US'],
|
159
|
+
'connection' => ['close'] })
|
160
|
+
|
161
|
+
client = NetHTTP.client(post_retrieve_account_users_client_opts)
|
162
|
+
resp = client.call_web_service(post_retrieve_account_users_req_opts)
|
163
|
+
|
164
|
+
expect(resp.code).to eq('200')
|
165
|
+
expect(resp.resp_code).to eq('200')
|
166
|
+
expect(resp.headers.empty?).to eq(false)
|
167
|
+
expect(resp.resp_headers.empty?).to eq(false)
|
168
|
+
expect(resp.headers_hash.empty?).to eq(false)
|
169
|
+
expect(resp.headers_hash.class).to eq(Hash)
|
170
|
+
expect(resp.resp_headers_hash.empty?).to eq(false)
|
171
|
+
expect(resp.resp_headers_hash.class).to eq(Hash)
|
172
|
+
expect(resp.body).to eq(successful_post_retrieve_account_users_resp_body)
|
173
|
+
expect(resp.valid_xml?).to eq(true)
|
174
|
+
expect(resp.body.empty?).to eq(false)
|
175
|
+
expect(resp.resp_body.empty?).to eq(false)
|
176
|
+
expect(resp.body_hash.empty?).to eq(false)
|
177
|
+
expect(resp.body_hash.class).to eq(Hash)
|
178
|
+
expect(resp.resp_body_hash.empty?).to eq(false)
|
179
|
+
expect(resp.resp_body_hash.class).to eq(Hash)
|
180
|
+
end
|
181
|
+
|
182
|
+
# post_form
|
183
|
+
it 'performs a POST_FORM request' do
|
184
|
+
stub_request(:post, 'https://www.host.com/path').
|
185
|
+
with(body: successful_post_form_req_body,
|
186
|
+
headers: { 'Accept' => '*/*',
|
187
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
188
|
+
'User-Agent' => 'Ruby' }).
|
189
|
+
to_return(status: 200,
|
190
|
+
body: successful_post_form_resp_body,
|
191
|
+
headers: { 'Accept' => '*/*',
|
192
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
193
|
+
'User-Agent' => 'Ruby' })
|
194
|
+
|
195
|
+
client = NetHTTP.client(post_form_client_opts)
|
196
|
+
resp = client.call_web_service(post_form_req_opts)
|
197
|
+
|
198
|
+
expect(resp.code).to eq('200')
|
199
|
+
expect(resp.resp_code).to eq('200')
|
200
|
+
expect(resp.headers.empty?).to eq(false)
|
201
|
+
expect(resp.resp_headers.empty?).to eq(false)
|
202
|
+
expect(resp.headers_hash.empty?).to eq(false)
|
203
|
+
expect(resp.headers_hash.class).to eq(Hash)
|
204
|
+
expect(resp.resp_headers_hash.empty?).to eq(false)
|
205
|
+
expect(resp.resp_headers_hash.class).to eq(Hash)
|
206
|
+
expect(resp.body.empty?).to eq(false)
|
207
|
+
expect(resp.resp_body.empty?).to eq(false)
|
208
|
+
expect(resp.body_hash.empty?).to eq(false)
|
209
|
+
expect(resp.body_hash.class).to eq(Hash)
|
210
|
+
expect(resp.resp_body_hash.empty?).to eq(false)
|
211
|
+
expect(resp.resp_body_hash.class).to eq(Hash)
|
212
|
+
end
|
213
|
+
|
214
|
+
# put
|
215
|
+
it 'performs a PUT request' do
|
216
|
+
stub_request(:put, 'https://www.host.com/path').
|
217
|
+
with(body: successful_put_req_body,
|
218
|
+
headers: { 'Accept' => '*/*',
|
219
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
220
|
+
'User-Agent' => 'Ruby' }).
|
221
|
+
to_return(status: 200,
|
222
|
+
body: successful_put_resp_body,
|
223
|
+
headers: { 'Accept' => '*/*',
|
224
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
225
|
+
'User-Agent' => 'Ruby' })
|
226
|
+
|
227
|
+
client = NetHTTP.client(put_client_opts)
|
228
|
+
resp = client.call_web_service(put_req_opts)
|
229
|
+
|
230
|
+
expect(resp.code).to eq('200')
|
231
|
+
expect(resp.resp_code).to eq('200')
|
232
|
+
expect(resp.headers.empty?).to eq(false)
|
233
|
+
expect(resp.resp_headers.empty?).to eq(false)
|
234
|
+
expect(resp.headers_hash.empty?).to eq(false)
|
235
|
+
expect(resp.headers_hash.class).to eq(Hash)
|
236
|
+
expect(resp.resp_headers_hash.empty?).to eq(false)
|
237
|
+
expect(resp.resp_headers_hash.class).to eq(Hash)
|
238
|
+
expect(resp.body.empty?).to eq(false)
|
239
|
+
expect(resp.resp_body.empty?).to eq(false)
|
240
|
+
expect(resp.body_hash.empty?).to eq(false)
|
241
|
+
expect(resp.body_hash.class).to eq(Hash)
|
242
|
+
expect(resp.resp_body_hash.empty?).to eq(false)
|
243
|
+
expect(resp.resp_body_hash.class).to eq(Hash)
|
244
|
+
end
|
245
|
+
|
246
|
+
# other
|
247
|
+
it 'performs a LOCK request' do
|
248
|
+
stub_request(:any, 'https://www.host.com/path').
|
249
|
+
with(body: successful_lock_req_body,
|
250
|
+
headers: { 'Accept' => '*/*',
|
251
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
252
|
+
'User-Agent' => 'Ruby' }).
|
253
|
+
to_return(status: 200,
|
254
|
+
body: successful_lock_resp_body,
|
255
|
+
headers: { 'Accept' => '*/*',
|
256
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
257
|
+
'User-Agent' => 'Ruby' })
|
258
|
+
|
259
|
+
client = NetHTTP.client(lock_client_opts)
|
260
|
+
|
261
|
+
begin
|
262
|
+
client.call_web_service(lock_req_opts)
|
263
|
+
rescue RuntimeError => err
|
264
|
+
expect(err.message).to eq("Request method => 'LOCK' not yet supported.")
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
private
|
269
|
+
|
270
|
+
# delete
|
271
|
+
def delete_client_opts
|
272
|
+
opts = {}
|
273
|
+
opts[:uri] = 'https://www.host.com/path'
|
274
|
+
opts
|
275
|
+
end
|
276
|
+
|
277
|
+
def delete_req_opts
|
278
|
+
opts = {}
|
279
|
+
opts[:req_method] = 'delete'
|
280
|
+
opts[:req_path] = '/path'
|
281
|
+
opts
|
282
|
+
end
|
283
|
+
|
284
|
+
def successful_delete_resp_body
|
285
|
+
'<resp_body>sample</resp_body>'
|
286
|
+
end
|
287
|
+
|
288
|
+
# get
|
289
|
+
def get_client_opts
|
290
|
+
opts = {}
|
291
|
+
opts[:uri] = 'http://eelslap.com/'
|
292
|
+
opts[:use_ssl] = false
|
293
|
+
opts
|
294
|
+
end
|
295
|
+
|
296
|
+
def get_req_opts
|
297
|
+
opts = {}
|
298
|
+
opts[:req_headers] = {}
|
299
|
+
opts[:req_method] = 'get'
|
300
|
+
opts[:req_path] = '/'
|
301
|
+
opts
|
302
|
+
end
|
303
|
+
|
304
|
+
def successful_get_resp_body
|
305
|
+
%(<!DOCTYPE html>
|
306
|
+
<html>
|
307
|
+
<head>
|
308
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
309
|
+
<title>Eel slap!</title>
|
310
|
+
<meta property="og:title" content="Eel slap!" />
|
311
|
+
<meta property="og:type" content="website" />
|
312
|
+
<meta property="og:url" content="http://www.eelslap.com" />
|
313
|
+
<meta property="og:image" content="http://www.eelslap.com/facebook.png" />
|
314
|
+
<meta property="og:site_name" content="Eel slap!" />
|
315
|
+
<meta property="fb:admins" content="543574574" />
|
316
|
+
<META NAME="keywords" CONTENT="eel slap, eelslap, eel slapping, eelslapping, eel, eal, eal slapping, eal slap, fish slapping, fishslapping, slap this guy with an eel, slap a guy with an eel slap a man with an eel, slap a dude with an eel, slap a guy with eel, slap a man with eel, slap a dude with eel, slap someone with an eel, slap someone with eel, eal slap, ell slap, per hansson, per stenius, fimpen">
|
317
|
+
<META NAME="description" CONTENT="Ever wanted to slap someone in the face with an eel? Well, today is your lucky day.">
|
318
|
+
<META NAME="author" CONTENT="Per Stenius - http://www.perstenius.com">
|
319
|
+
<link rel="SHORTCUT ICON" href="favicon.ico"/>
|
320
|
+
<script type="text/javascript">
|
321
|
+
var _gaq = _gaq || [];
|
322
|
+
_gaq.push(['_setAccount', 'UA-114693-12']);
|
323
|
+
_gaq.push(['_trackPageview']);
|
324
|
+
|
325
|
+
(function() {
|
326
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
327
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
328
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
329
|
+
})();
|
330
|
+
</script>
|
331
|
+
<link rel="stylesheet" href="css/normalize.css" type="text/css">
|
332
|
+
<link rel="stylesheet" type="text/css" href="css/eelslap.css"/>
|
333
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
334
|
+
<script src="js/eelslap.js"></script>
|
335
|
+
|
336
|
+
</head>
|
337
|
+
<body>
|
338
|
+
<div id="eelcontainer" class="eel">
|
339
|
+
<div id="loader">LOADING...</div>
|
340
|
+
<div id="introtext">yo</div>
|
341
|
+
<div id="allimages">
|
342
|
+
<img class="eelimages" id="eelimage1" src="" width="15360" height="480">
|
343
|
+
<img class="eelimages" id="eelimage2" src="" width="14720" height="480">
|
344
|
+
<img class="eelimages" id="eelimage3" src="" width="15360" height="480">
|
345
|
+
<img class="eelimages" id="eelimage4" src="" width="14720" height="480">
|
346
|
+
</div>
|
347
|
+
</div>
|
348
|
+
<div class="footer">
|
349
|
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.eelslap.com" data-count="vertical">Tweet</a>
|
350
|
+
<script type="text/javascript" src="http://platform.twitter.com/widgets.js">
|
351
|
+
</script>
|
352
|
+
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.eelslap.com&send=false&layout=box_count&width=55&show_faces=false&action=like&colorscheme=light&font&height=62" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:55px; height:62px;">
|
353
|
+
</iframe><br>
|
354
|
+
|
355
|
+
<a href="http://actnormal.co" target="_blank">made by</a>
|
356
|
+
</div>
|
357
|
+
</body>
|
358
|
+
</html>)
|
359
|
+
end
|
360
|
+
|
361
|
+
# post
|
362
|
+
def post_request_token_client_opts
|
363
|
+
opts = {}
|
364
|
+
opts[:uri] = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
365
|
+
opts
|
366
|
+
end
|
367
|
+
|
368
|
+
def post_request_token_req_opts
|
369
|
+
opts = {}
|
370
|
+
|
371
|
+
user_id = ENV['USER_ID']
|
372
|
+
password = ENV['PASSWORD']
|
373
|
+
client_id = 'd6bcd5e1-29d7-4ec0-9b96-215b3a317fd6'
|
374
|
+
client_secret = 'e391e6aa-4d60-4470-b351-0f84f11495a8'
|
375
|
+
grant_type = 'password'
|
376
|
+
scope = 'AppIdClaimsTrust'
|
377
|
+
|
378
|
+
opts[:req_method] = 'post'
|
379
|
+
opts[:req_headers] = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' }
|
380
|
+
opts[:req_body] = "username=#{user_id}&password=#{password}&client_id=#{client_id}&client_secret=#{client_secret}&grant_type=#{grant_type}&scope=#{scope}"
|
381
|
+
opts[:req_path] = '/as/resourceOwner'
|
382
|
+
opts
|
383
|
+
end
|
384
|
+
|
385
|
+
def successful_post_request_token_req_body
|
386
|
+
"username=#{ENV['USER_ID']}&password=#{ENV['PASSWORD']}&client_id=d6bcd5e1-29d7-4ec0-9b96-215b3a317fd6&client_secret=e391e6aa-4d60-4470-b351-0f84f11495a8&grant_type=password&scope=AppIdClaimsTrust"
|
387
|
+
end
|
388
|
+
|
389
|
+
def successful_post_request_token_resp_body
|
390
|
+
'{"access_token":"l3k0QJfU3k6L0XXyfe5MJBjy5672hgau6aJA1BMAwYDwmVkeK00M7h","token_type":"Bearer","expires_in":43201,"refresh_token":"x9gvXcGF1zKD4ZpwYA6T9n9vHdc5CB1xednEPPIqU6yWic","scope":"AppIdClaimsTrust","Environment":"QA","secondLvlAuthzId":"","webAuthAppID":"AP118499"}'
|
391
|
+
end
|
392
|
+
|
393
|
+
def post_retrieve_account_users_client_opts
|
394
|
+
opts = {}
|
395
|
+
opts[:uri] = 'https://alpha-mmk.fmr.com:9980/XML_FEB_S_A'
|
396
|
+
opts[:ssl_path] = 'config/certs'
|
397
|
+
opts[:ca_file] = 'cacert.pem'
|
398
|
+
opts[:pkcs12_file] = 'dev-b2b-fidcom.p12'
|
399
|
+
opts[:pkcs12_passphrase] = 'Summer100'
|
400
|
+
opts
|
401
|
+
end
|
402
|
+
|
403
|
+
def post_retrieve_account_users_req_opts
|
404
|
+
opts = {}
|
405
|
+
opts[:req_method] = 'post'
|
406
|
+
opts[:req_headers] = { 'Content-Type' => 'application/xml' }
|
407
|
+
opts[:req_body] = '<?xml version="1.0" encoding="utf-16"?>
|
408
|
+
<DCLCUST0_REQUEST>
|
409
|
+
<PSL_VIEW>DCLCUST0.VIEW</PSL_VIEW>
|
410
|
+
<REQUESTOR_ID>024300218</REQUESTOR_ID>
|
411
|
+
<PRODUCT_ID>W</PRODUCT_ID>
|
412
|
+
<MESSAGE_TYPE>F</MESSAGE_TYPE>
|
413
|
+
<FUNCTION_INDICATOR>V</FUNCTION_INDICATOR>
|
414
|
+
<PARTITION_ID>RETAIL</PARTITION_ID>
|
415
|
+
<RELATIONSHIP_TYPE/>
|
416
|
+
<INCLUDE_4P_REL>Y</INCLUDE_4P_REL>
|
417
|
+
<PRM_KEY_TYPE>B</PRM_KEY_TYPE>
|
418
|
+
<PRIMARY_KEY>X01000833</PRIMARY_KEY>
|
419
|
+
<RETURN_PRODUCT_G_NBR_IND/>
|
420
|
+
<INPUT_VIEW>
|
421
|
+
<PAGING>
|
422
|
+
<PAGING_MAX_COUNT>All</PAGING_MAX_COUNT>
|
423
|
+
<PAGING_DIRECTION>F</PAGING_DIRECTION>
|
424
|
+
<PAGING_CONTINUATION_KEY/>
|
425
|
+
</PAGING>
|
426
|
+
</INPUT_VIEW>
|
427
|
+
</DCLCUST0_REQUEST>'
|
428
|
+
opts
|
429
|
+
end
|
430
|
+
|
431
|
+
def successful_post_retrieve_account_users_req_body
|
432
|
+
'<?xml version="1.0" encoding="utf-16"?>
|
433
|
+
<DCLCUST0_REQUEST>
|
434
|
+
<PSL_VIEW>DCLCUST0.VIEW</PSL_VIEW>
|
435
|
+
<REQUESTOR_ID>024300218</REQUESTOR_ID>
|
436
|
+
<PRODUCT_ID>W</PRODUCT_ID>
|
437
|
+
<MESSAGE_TYPE>F</MESSAGE_TYPE>
|
438
|
+
<FUNCTION_INDICATOR>V</FUNCTION_INDICATOR>
|
439
|
+
<PARTITION_ID>RETAIL</PARTITION_ID>
|
440
|
+
<RELATIONSHIP_TYPE/>
|
441
|
+
<INCLUDE_4P_REL>Y</INCLUDE_4P_REL>
|
442
|
+
<PRM_KEY_TYPE>B</PRM_KEY_TYPE>
|
443
|
+
<PRIMARY_KEY>X01000833</PRIMARY_KEY>
|
444
|
+
<RETURN_PRODUCT_G_NBR_IND/>
|
445
|
+
<INPUT_VIEW>
|
446
|
+
<PAGING>
|
447
|
+
<PAGING_MAX_COUNT>All</PAGING_MAX_COUNT>
|
448
|
+
<PAGING_DIRECTION>F</PAGING_DIRECTION>
|
449
|
+
<PAGING_CONTINUATION_KEY/>
|
450
|
+
</PAGING>
|
451
|
+
</INPUT_VIEW>
|
452
|
+
</DCLCUST0_REQUEST>'
|
453
|
+
end
|
454
|
+
|
455
|
+
def successful_post_retrieve_account_users_resp_body
|
456
|
+
'<?xml version="1.0"?>
|
457
|
+
<DCLCUST0_RESPONSE>
|
458
|
+
<PSL_RESPONSE>
|
459
|
+
<PSL_STATUS>1</PSL_STATUS>
|
460
|
+
<PSL_SERVER>mauieart11</PSL_SERVER>
|
461
|
+
<PSL_STATISTICS> Total:00000013; Parse_XML:00000000; To_XML:00000001; Eci:00000012; Q:000012; Skt:000012; GOR:000011; MF:00000011;</PSL_STATISTICS>
|
462
|
+
<PSL_SIZE_STATISTICS> In_XML:00000646; In_Comm:00000434; Out_Comm:00031418; Out_XML:00001924;</PSL_SIZE_STATISTICS>
|
463
|
+
</PSL_RESPONSE>
|
464
|
+
<DCLCUST0O_VIEW>
|
465
|
+
<FDRB_BLOCK>
|
466
|
+
<SYMBOLIC_VIEWNAME>0DCC060B</SYMBOLIC_VIEWNAME>
|
467
|
+
<SIZE_OF_DATA>031325</SIZE_OF_DATA>
|
468
|
+
<RECORD_COUNT>000002</RECORD_COUNT>
|
469
|
+
<SENSE_CODE>0000</SENSE_CODE>
|
470
|
+
</FDRB_BLOCK>
|
471
|
+
<FDRB_EXT_BLOCK>
|
472
|
+
<PRODUCT_ID>W</PRODUCT_ID>
|
473
|
+
</FDRB_EXT_BLOCK>
|
474
|
+
<STATUS>
|
475
|
+
<ERROR_CODE>035000</ERROR_CODE>
|
476
|
+
<ERROR_TEXT>The ICS Business Function has completed successfully.</ERROR_TEXT>
|
477
|
+
</STATUS>
|
478
|
+
<SERVER_RESPONSE_BLOCK>
|
479
|
+
<PARTITION_ID>RETAIL</PARTITION_ID>
|
480
|
+
<PRM_KEY_TYPE>B</PRM_KEY_TYPE>
|
481
|
+
<PRIMARY_KEY>X01000833</PRIMARY_KEY>
|
482
|
+
</SERVER_RESPONSE_BLOCK>
|
483
|
+
<OBJECT_VIEW>
|
484
|
+
<REGISTRATION_TYPE_CODE>I</REGISTRATION_TYPE_CODE>
|
485
|
+
<PRIMARY_CUSTOMER_DATA>
|
486
|
+
<PRIMARY_CUS_ID>024300218</PRIMARY_CUS_ID>
|
487
|
+
<PRIMARY_NAME_FORMAT_CODE>F</PRIMARY_NAME_FORMAT_CODE>
|
488
|
+
<PRIMARY_FIRST_NAME>RUFUS</PRIMARY_FIRST_NAME>
|
489
|
+
<PRIMARY_LAST_NAME>AGAR</PRIMARY_LAST_NAME>
|
490
|
+
</PRIMARY_CUSTOMER_DATA>
|
491
|
+
<CUSTOMER_COUNT>00002</CUSTOMER_COUNT>
|
492
|
+
<CUSTOMER_DATA_GROUP>
|
493
|
+
<CUSTOMER_DATA>
|
494
|
+
<CUS_REL_TYPE>INDV</CUS_REL_TYPE>
|
495
|
+
<REL_SOUCE_CODE>O</REL_SOUCE_CODE>
|
496
|
+
<CUS_ID>024300218</CUS_ID>
|
497
|
+
<NAME_FORMAT_CODE>F</NAME_FORMAT_CODE>
|
498
|
+
<FIRST_NAME>RUFUS</FIRST_NAME>
|
499
|
+
<LAST_NAME>AGAR</LAST_NAME>
|
500
|
+
<TAX_NUM_CODE>S</TAX_NUM_CODE>
|
501
|
+
<TAX_NUM>024300218</TAX_NUM>
|
502
|
+
<DATE_OF_BIRTH>1967-03-15</DATE_OF_BIRTH>
|
503
|
+
<SERVICE_LEVEL_CODE>009</SERVICE_LEVEL_CODE>
|
504
|
+
<PRINCIPAL_NAME_CODE>1</PRINCIPAL_NAME_CODE>
|
505
|
+
<PAS_VIEWING_INDICATOR>N</PAS_VIEWING_INDICATOR>
|
506
|
+
</CUSTOMER_DATA>
|
507
|
+
<CUSTOMER_DATA>
|
508
|
+
<CUS_REL_TYPE>FTA</CUS_REL_TYPE>
|
509
|
+
<REL_SOUCE_CODE>T</REL_SOUCE_CODE>
|
510
|
+
<CUS_ID>234567890</CUS_ID>
|
511
|
+
<NAME_FORMAT_CODE>F</NAME_FORMAT_CODE>
|
512
|
+
<FIRST_NAME>CHRISTIAN</FIRST_NAME>
|
513
|
+
<LAST_NAME>PULISIC</LAST_NAME>
|
514
|
+
<TAX_NUM_CODE>S</TAX_NUM_CODE>
|
515
|
+
<TAX_NUM>234567890</TAX_NUM>
|
516
|
+
<DATE_OF_BIRTH>1983-01-01</DATE_OF_BIRTH>
|
517
|
+
<SERVICE_LEVEL_CODE>009</SERVICE_LEVEL_CODE>
|
518
|
+
<PRINCIPAL_NAME_CODE>8</PRINCIPAL_NAME_CODE>
|
519
|
+
<REL_ROLE_TYPE_CODE>CUST</REL_ROLE_TYPE_CODE>
|
520
|
+
<LINE_OF_BUSINESS>R</LINE_OF_BUSINESS>
|
521
|
+
<PAS_VIEWING_INDICATOR>N</PAS_VIEWING_INDICATOR>
|
522
|
+
</CUSTOMER_DATA>
|
523
|
+
</CUSTOMER_DATA_GROUP>
|
524
|
+
</OBJECT_VIEW>
|
525
|
+
</DCLCUST0O_VIEW>
|
526
|
+
</DCLCUST0_RESPONSE>'
|
527
|
+
end
|
528
|
+
|
529
|
+
# post_form
|
530
|
+
def post_form_client_opts
|
531
|
+
opts = {}
|
532
|
+
opts[:uri] = 'https://www.host.com/path'
|
533
|
+
opts
|
534
|
+
end
|
535
|
+
|
536
|
+
def post_form_req_opts
|
537
|
+
opts = {}
|
538
|
+
opts[:uri] = 'https://www.host.com/path'
|
539
|
+
opts[:req_method] = 'post_form'
|
540
|
+
opts[:req_body] = { email_address: 'bpa_team@fidtest.com' }
|
541
|
+
opts[:req_path] = '/path'
|
542
|
+
opts
|
543
|
+
end
|
544
|
+
|
545
|
+
def successful_post_form_req_body
|
546
|
+
{ email_address: 'bpa_team@fidtest.com' }
|
547
|
+
end
|
548
|
+
|
549
|
+
def successful_post_form_resp_body
|
550
|
+
'<resp_body>sample</resp_body>'
|
551
|
+
end
|
552
|
+
|
553
|
+
# put
|
554
|
+
def put_client_opts
|
555
|
+
opts = {}
|
556
|
+
opts[:uri] = 'https://www.host.com/path'
|
557
|
+
opts
|
558
|
+
end
|
559
|
+
|
560
|
+
def put_req_opts
|
561
|
+
opts = {}
|
562
|
+
opts[:req_method] = 'put'
|
563
|
+
opts[:req_headers] = { 'Accept' => '*/*',
|
564
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
565
|
+
'User-Agent' => 'Ruby' }
|
566
|
+
opts[:req_body] = '<req_body>sample</req_body>'
|
567
|
+
opts[:req_path] = '/path'
|
568
|
+
opts
|
569
|
+
end
|
570
|
+
|
571
|
+
def successful_put_req_body
|
572
|
+
'<req_body>sample</req_body>'
|
573
|
+
end
|
574
|
+
|
575
|
+
def successful_put_resp_body
|
576
|
+
'<resp_body>sample</resp_body>'
|
577
|
+
end
|
578
|
+
|
579
|
+
# other - lock
|
580
|
+
def lock_client_opts
|
581
|
+
opts = {}
|
582
|
+
opts[:uri] = 'https://www.host.com/path'
|
583
|
+
opts
|
584
|
+
end
|
585
|
+
|
586
|
+
def lock_req_opts
|
587
|
+
opts = {}
|
588
|
+
opts[:req_method] = 'lock'
|
589
|
+
opts[:req_headers] = { 'Accept' => '*/*',
|
590
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
591
|
+
'User-Agent' => 'Ruby' }
|
592
|
+
opts[:req_body] = '<req_body>sample</req_body>'
|
593
|
+
opts
|
594
|
+
end
|
595
|
+
|
596
|
+
def successful_lock_req_body
|
597
|
+
'<req_body>sample</req_body>'
|
598
|
+
end
|
599
|
+
|
600
|
+
def successful_lock_resp_body
|
601
|
+
'<resp_body>sample</resp_body>'
|
602
|
+
end
|
603
|
+
end
|