rb-net_http-client 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,97 +0,0 @@
1
- require 'webmock/rspec'
2
- require_relative '../../../spec_helper'
3
-
4
- describe NetHTTP::Response::Ext do
5
- it 'performs a POST request for a valid oAuth token from ESG' do
6
- stub_request(:post, 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner').
7
- with(body: successful_post_request_token_req_body,
8
- headers: { 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' }).
9
- to_return(status: 200,
10
- body: successful_post_request_token_resp_body,
11
- headers: { 'date' => ['Thu, 10 Aug 2017 14:09:19 GMT'],
12
- 'server' => [''],
13
- 'connection' => ['close'],
14
- 'x-correlationid' => ['Id-0f698c59b97c8df3c572145c 0'],
15
- 'accept' => ['*/*'],
16
- 'host' => ['esg-qa-oauth2-internal.fmr.com'],
17
- 'user-agent' => ['Ruby'],
18
- 'cache-control' => ['no-store'],
19
- 'content-type' => ['application/json'],
20
- 'pragma' => ['no-cache'] })
21
-
22
- client = NetHTTP.client(post_request_token_client_opts)
23
- resp = client.call_web_service(post_request_token_req_opts)
24
-
25
- expect(resp.methods.include?(:logger)).to eq(true)
26
- expect(resp.methods.include?(:resp_body)).to eq(true)
27
- expect(resp.methods.include?(:resp_code)).to eq(true)
28
- expect(resp.methods.include?(:headers)).to eq(true)
29
- expect(resp.methods.include?(:headers_hash)).to eq(true)
30
- expect(resp.methods.include?(:body_hash)).to eq(true)
31
- expect(resp.methods.include?(:valid_json?)).to eq(true)
32
- expect(resp.methods.include?(:valid_xml?)).to eq(true)
33
- expect(resp.methods.include?(:valid_html?)).to eq(true)
34
- expect(resp.methods.include?(:resp_headers)).to eq(true)
35
- expect(resp.methods.include?(:resp_headers_hash)).to eq(true)
36
- expect(resp.methods.include?(:resp_body_hash)).to eq(true)
37
- end
38
-
39
- it 'the logger object is maintained from client to core object' do
40
- stub_request(:post, 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner').
41
- with(body: successful_post_request_token_req_body,
42
- headers: { 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' }).
43
- to_return(status: 200,
44
- body: successful_post_request_token_resp_body,
45
- headers: { 'date' => ['Thu, 10 Aug 2017 14:09:19 GMT'],
46
- 'server' => [''],
47
- 'connection' => ['close'],
48
- 'x-correlationid' => ['Id-0f698c59b97c8df3c572145c 0'],
49
- 'accept' => ['*/*'],
50
- 'host' => ['esg-qa-oauth2-internal.fmr.com'],
51
- 'user-agent' => ['Ruby'],
52
- 'cache-control' => ['no-store'],
53
- 'content-type' => ['application/json'],
54
- 'pragma' => ['no-cache'] })
55
-
56
- client = NetHTTP.client(post_request_token_client_opts)
57
- resp = client.call_web_service(post_request_token_req_opts)
58
-
59
- expect(client.logger == resp.logger).to eq(false)
60
- expect(client.logger.class).to eq(Logger)
61
- expect(resp.logger.class).to eq(Logger)
62
- end
63
-
64
- private
65
-
66
- # post
67
- def post_request_token_client_opts
68
- opts = {}
69
- opts[:uri] = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
70
- opts
71
- end
72
-
73
- def post_request_token_req_opts
74
- opts = {}
75
-
76
- user_id = ENV['USER_ID']
77
- password = ENV['PASSWORD']
78
- client_id = 'd6bcd5e1-29d7-4ec0-9b96-215b3a317fd6'
79
- client_secret = 'e391e6aa-4d60-4470-b351-0f84f11495a8'
80
- grant_type = 'password'
81
- scope = 'AppIdClaimsTrust'
82
-
83
- opts[:req_method] = 'post'
84
- opts[:req_headers] = { 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8' }
85
- opts[:req_body] = "username=#{user_id}&password=#{password}&client_id=#{client_id}&client_secret=#{client_secret}&grant_type=#{grant_type}&scope=#{scope}"
86
- opts[:req_path] = '/as/resourceOwner'
87
- opts
88
- end
89
-
90
- def successful_post_request_token_req_body
91
- "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"
92
- end
93
-
94
- def successful_post_request_token_resp_body
95
- '{"access_token":"l3k0QJfU3k6L0XXyfe5MJBjy5672hgau6aJA1BMAwYDwmVkeK00M7h","token_type":"Bearer","expires_in":43201,"refresh_token":"x9gvXcGF1zKD4ZpwYA6T9n9vHdc5CB1xednEPPIqU6yWic","scope":"AppIdClaimsTrust","Environment":"QA","secondLvlAuthzId":"","webAuthAppID":"AP118499"}'
96
- end
97
- end
@@ -1,10 +0,0 @@
1
- require_relative '../../spec_helper'
2
-
3
- describe NetHTTP::VERSION do
4
- it 'should have a valid version' do
5
- expect(NetHTTP::VERSION.nil?).to eq(false)
6
- expect(NetHTTP::VERSION.empty?).to eq(false)
7
- expect(NetHTTP::VERSION.class).to eq(String)
8
- expect(NetHTTP::VERSION.frozen?).to eq(true)
9
- end
10
- end