rb-net_http-client 0.0.4
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.
- 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,10 @@
|
|
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
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require_relative '../../../spec_helper'
|
2
|
+
|
3
|
+
describe 'NetHTTP.client' do
|
4
|
+
it 'returns a valid Net::HTTP client instance' do
|
5
|
+
client_opts = {}
|
6
|
+
client_opts[:uri] = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
7
|
+
|
8
|
+
client = NetHTTP.client(client_opts)
|
9
|
+
|
10
|
+
expect(client.class).to eq(Net::HTTP)
|
11
|
+
expect(client.logger.class).to eq(Logger)
|
12
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
13
|
+
expect(client.uri.to_s).to eq(client_opts[:uri])
|
14
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
15
|
+
expect(client.port).to eq(443)
|
16
|
+
expect(client.path).to eq('/as/resourceOwner')
|
17
|
+
expect(client.proxy_uri.to_s).to eq('http://http.proxy.fmr.com:8000/')
|
18
|
+
expect(client.use_proxy).to eq(true)
|
19
|
+
expect(client.use_ssl).to eq(true)
|
20
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
21
|
+
expect(client.open_timeout).to eq(60)
|
22
|
+
expect(client.read_timeout).to eq(60)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns a valid Net::HTTP client instance' do
|
26
|
+
client_opts = {}
|
27
|
+
client_opts[:uri] = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
28
|
+
client_opts[:use_ssl] = true
|
29
|
+
client_opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
|
30
|
+
|
31
|
+
client = NetHTTP.client(client_opts)
|
32
|
+
|
33
|
+
expect(client.class).to eq(Net::HTTP)
|
34
|
+
expect(client.logger.class).to eq(Logger)
|
35
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
36
|
+
expect(client.uri.to_s).to eq(client_opts[:uri])
|
37
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
38
|
+
expect(client.port).to eq(443)
|
39
|
+
expect(client.path).to eq('/as/resourceOwner')
|
40
|
+
expect(client.proxy_uri.to_s).to eq('http://http.proxy.fmr.com:8000/')
|
41
|
+
expect(client.use_proxy).to eq(true)
|
42
|
+
expect(client.use_ssl).to eq(true)
|
43
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
44
|
+
expect(client.open_timeout).to eq(60)
|
45
|
+
expect(client.read_timeout).to eq(60)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns a valid Net::HTTP client instance when uri is eelslap.com:80/' do
|
49
|
+
client_opts = {}
|
50
|
+
client_opts[:uri] = 'eelslap.com:80/'
|
51
|
+
|
52
|
+
client = NetHTTP.client(client_opts)
|
53
|
+
|
54
|
+
expect(client.class).to eq(Net::HTTP)
|
55
|
+
expect(client.logger.class).to eq(Logger)
|
56
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
57
|
+
expect(client.uri.to_s).to eq('http://eelslap.com/')
|
58
|
+
expect(client.host).to eq('eelslap.com')
|
59
|
+
expect(client.port).to eq(80)
|
60
|
+
expect(client.path).to eq('/')
|
61
|
+
expect(client.proxy_uri.to_s).to eq('http://http.proxy.fmr.com:8000/')
|
62
|
+
expect(client.use_proxy).to eq(true)
|
63
|
+
expect(client.use_ssl).to eq(false)
|
64
|
+
expect(client.verify_mode).to eq(nil)
|
65
|
+
expect(client.open_timeout).to eq(60)
|
66
|
+
expect(client.read_timeout).to eq(60)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'returns a valid Net::HTTP client instance when no uri / url is provided' do
|
70
|
+
client_opts = {}
|
71
|
+
client_opts[:scheme] = 'https'
|
72
|
+
client_opts[:host] = 'esg-qa-oauth2-internal.fmr.com'
|
73
|
+
client_opts[:port] = 443
|
74
|
+
client_opts[:path] = '/as/resourceOwner'
|
75
|
+
|
76
|
+
client = NetHTTP.client(client_opts)
|
77
|
+
|
78
|
+
expect(client.class).to eq(Net::HTTP)
|
79
|
+
expect(client.logger.class).to eq(Logger)
|
80
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
81
|
+
expect(client.uri.to_s).to eq('https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner')
|
82
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
83
|
+
expect(client.port).to eq(443)
|
84
|
+
expect(client.path).to eq('/as/resourceOwner')
|
85
|
+
expect(client.proxy_uri.to_s).to eq('http://http.proxy.fmr.com:8000/')
|
86
|
+
expect(client.use_proxy).to eq(true)
|
87
|
+
expect(client.use_ssl).to eq(true)
|
88
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
89
|
+
expect(client.open_timeout).to eq(60)
|
90
|
+
expect(client.read_timeout).to eq(60)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'returns a valid Net::HTTP client instance when only host, port, and path are provided' do
|
94
|
+
client_opts = {}
|
95
|
+
client_opts[:host] = 'esg-qa-oauth2-internal.fmr.com'
|
96
|
+
client_opts[:port] = 443
|
97
|
+
client_opts[:path] = '/as/resourceOwner'
|
98
|
+
|
99
|
+
client = NetHTTP.client(client_opts)
|
100
|
+
|
101
|
+
expect(client.class).to eq(Net::HTTP)
|
102
|
+
expect(client.logger.class).to eq(Logger)
|
103
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
104
|
+
expect(client.uri.to_s).to eq('https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner')
|
105
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
106
|
+
expect(client.port).to eq(443)
|
107
|
+
expect(client.path).to eq('/as/resourceOwner')
|
108
|
+
expect(client.proxy_uri.to_s).to eq('http://http.proxy.fmr.com:8000/')
|
109
|
+
expect(client.use_proxy).to eq(true)
|
110
|
+
expect(client.use_ssl).to eq(true)
|
111
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
112
|
+
expect(client.open_timeout).to eq(60)
|
113
|
+
expect(client.read_timeout).to eq(60)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'returns a valid Net::HTTP client instance when only host and path are provided' do
|
117
|
+
client_opts = {}
|
118
|
+
client_opts[:host] = 'esg-qa-oauth2-internal.fmr.com'
|
119
|
+
client_opts[:path] = '/as/resourceOwner'
|
120
|
+
client_opts[:enforce_schema_validation] = false
|
121
|
+
|
122
|
+
client = NetHTTP.client(client_opts)
|
123
|
+
|
124
|
+
expect(client.class).to eq(Net::HTTP)
|
125
|
+
expect(client.logger.class).to eq(Logger)
|
126
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
127
|
+
expect(client.uri.to_s).to eq('https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner')
|
128
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
129
|
+
expect(client.port).to eq(443)
|
130
|
+
expect(client.path).to eq('/as/resourceOwner')
|
131
|
+
expect(client.proxy_uri.to_s).to eq('http://http.proxy.fmr.com:8000/')
|
132
|
+
expect(client.use_proxy).to eq(true)
|
133
|
+
expect(client.use_ssl).to eq(true)
|
134
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
135
|
+
expect(client.open_timeout).to eq(60)
|
136
|
+
expect(client.read_timeout).to eq(60)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'returns a valid Net::HTTP client instance when use_proxy & use_ssl are false' do
|
140
|
+
client_opts = {}
|
141
|
+
client_opts[:uri] = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
142
|
+
client_opts[:use_proxy] = false
|
143
|
+
client_opts[:use_ssl] = false
|
144
|
+
|
145
|
+
client = NetHTTP.client(client_opts)
|
146
|
+
|
147
|
+
expect(client.class).to eq(Net::HTTP)
|
148
|
+
expect(client.logger.class).to eq(Logger)
|
149
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
150
|
+
expect(client.uri.to_s).to eq(client_opts[:uri])
|
151
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
152
|
+
expect(client.port).to eq(443)
|
153
|
+
expect(client.path).to eq('/as/resourceOwner')
|
154
|
+
# expect(client.proxy_uri.to_s).to eq((ENV['http_proxy'] ||= 'http://http.proxy.fmr.com:8000/'))
|
155
|
+
expect(client.use_proxy).to eq(false)
|
156
|
+
expect(client.use_ssl).to eq(false)
|
157
|
+
expect(client.verify_mode).to eq(nil)
|
158
|
+
expect(client.open_timeout).to eq(60)
|
159
|
+
expect(client.read_timeout).to eq(60)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'returns a valid Net::HTTP client instance use_ssl and scheme are nil' do
|
163
|
+
client_opts = {}
|
164
|
+
client_opts[:uri] = 'esg-qa-oauth2-internal.fmr.com:443/as/resourceOwner'
|
165
|
+
client_opts[:enforce_schema_validation] = false
|
166
|
+
client_opts[:use_ssl] = nil
|
167
|
+
|
168
|
+
client = NetHTTP.client(client_opts)
|
169
|
+
|
170
|
+
expect(client.class).to eq(Net::HTTP)
|
171
|
+
expect(client.logger.class).to eq(Logger)
|
172
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
173
|
+
expect(client.uri.to_s).to eq('https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner')
|
174
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
175
|
+
expect(client.port).to eq(443)
|
176
|
+
expect(client.path).to eq('/as/resourceOwner')
|
177
|
+
# expect(client.proxy_uri.to_s).to eq((ENV['http_proxy'] ||= 'http://http.proxy.fmr.com:8000/'))
|
178
|
+
expect(client.use_proxy).to eq(true)
|
179
|
+
expect(client.use_ssl).to eq(true)
|
180
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
181
|
+
expect(client.open_timeout).to eq(60)
|
182
|
+
expect(client.read_timeout).to eq(60)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'returns a valid Net::HTTP client instance use_ssl, scheme, and port are nil' do
|
186
|
+
client_opts = {}
|
187
|
+
client_opts[:uri] = 'esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
188
|
+
client_opts[:enforce_schema_validation] = false
|
189
|
+
client_opts[:use_ssl] = nil
|
190
|
+
|
191
|
+
client = NetHTTP.client(client_opts)
|
192
|
+
|
193
|
+
expect(client.class).to eq(Net::HTTP)
|
194
|
+
expect(client.logger.class).to eq(Logger)
|
195
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
196
|
+
expect(client.uri.to_s).to eq('https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner')
|
197
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
198
|
+
expect(client.port).to eq(443)
|
199
|
+
expect(client.path).to eq('/as/resourceOwner')
|
200
|
+
# expect(client.proxy_uri.to_s).to eq((ENV['http_proxy'] ||= 'http://http.proxy.fmr.com:8000/'))
|
201
|
+
expect(client.use_proxy).to eq(true)
|
202
|
+
expect(client.use_ssl).to eq(true)
|
203
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
204
|
+
expect(client.open_timeout).to eq(60)
|
205
|
+
expect(client.read_timeout).to eq(60)
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'returns a valid Net::HTTP client instance when use_proxy & use_ssl are true' do
|
209
|
+
client_opts = {}
|
210
|
+
client_opts[:uri] = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
211
|
+
client_opts[:use_proxy] = true
|
212
|
+
client_opts[:use_ssl] = true
|
213
|
+
|
214
|
+
client = NetHTTP.client(client_opts)
|
215
|
+
|
216
|
+
expect(client.class).to eq(Net::HTTP)
|
217
|
+
expect(client.logger.class).to eq(Logger)
|
218
|
+
expect(client.logger.level).to eq(Logger::INFO)
|
219
|
+
expect(client.uri.to_s).to eq(client_opts[:uri])
|
220
|
+
expect(client.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
221
|
+
expect(client.port).to eq(443)
|
222
|
+
expect(client.path).to eq('/as/resourceOwner')
|
223
|
+
# expect(client.proxy_uri.to_s).to eq((ENV['http_proxy'] ||= 'http://http.proxy.fmr.com:8000/'))
|
224
|
+
expect(client.use_proxy).to eq(true)
|
225
|
+
expect(client.use_ssl).to eq(true)
|
226
|
+
expect(client.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
227
|
+
expect(client.open_timeout).to eq(60)
|
228
|
+
expect(client.read_timeout).to eq(60)
|
229
|
+
end
|
230
|
+
|
231
|
+
# TODO: Add in the unit tests for the cert based scenarios (i.e. MAUI)
|
232
|
+
end
|
@@ -0,0 +1,433 @@
|
|
1
|
+
require_relative '../../spec_helper'
|
2
|
+
|
3
|
+
describe NetHTTP::Core do
|
4
|
+
Schema = Dry::Validation.Schema do
|
5
|
+
required(:required).filled(:type? => String)
|
6
|
+
end
|
7
|
+
|
8
|
+
# NetHTTP::Core.assign_logger(logger = nil)
|
9
|
+
it 'assigns logger by default when no logger is provided' do
|
10
|
+
logger = NetHTTP::Core.assign_logger
|
11
|
+
expect(logger.class).to eq(Logger)
|
12
|
+
expect(logger.level).to eq(Logger::INFO)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'assigns logger by default when logger is nil' do
|
16
|
+
logger = nil
|
17
|
+
logger = NetHTTP::Core.assign_logger(logger)
|
18
|
+
expect(logger.class).to eq(Logger)
|
19
|
+
expect(logger.level).to eq(Logger::INFO)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'assigns logger by default when logger is empty' do
|
23
|
+
logger = ''
|
24
|
+
logger = NetHTTP::Core.assign_logger(logger)
|
25
|
+
expect(logger.class).to eq(Logger)
|
26
|
+
expect(logger.level).to eq(Logger::INFO)
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns logger when valid logger is provided' do
|
30
|
+
logger = Logger.new(STDOUT)
|
31
|
+
logger.level = Logger::FATAL
|
32
|
+
|
33
|
+
logger = NetHTTP::Core.assign_logger(logger)
|
34
|
+
expect(logger.class).to eq(Logger)
|
35
|
+
expect(logger.level).to eq(Logger::FATAL)
|
36
|
+
end
|
37
|
+
|
38
|
+
# NetHTTP::Core.parse_uri(uri)
|
39
|
+
it 'should return nil if nil uri is provided' do
|
40
|
+
uri = nil
|
41
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
42
|
+
expect(uri).to eq(nil)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should return nil if empty uri is provided' do
|
46
|
+
uri = ''
|
47
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
48
|
+
expect(uri).to eq(nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should return valid URI object if valid uri is provided' do
|
52
|
+
uri = 'https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
53
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
54
|
+
expect(uri.scheme).to eq('https')
|
55
|
+
expect(uri.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
56
|
+
expect(uri.port).to eq(443)
|
57
|
+
expect(uri.path).to eq('/as/resourceOwner')
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should return valid URI object if uri with no scheme is provided' do
|
61
|
+
uri = 'esg-qa-oauth2-internal.fmr.com:443/as/resourceOwner'
|
62
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
63
|
+
expect(uri.scheme).to eq('https')
|
64
|
+
expect(uri.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
65
|
+
expect(uri.port).to eq(443)
|
66
|
+
expect(uri.path).to eq('/as/resourceOwner')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return valid URI object if uri with no scheme or port is provided' do
|
70
|
+
uri = 'esg-qa-oauth2-internal.fmr.com/as/resourceOwner'
|
71
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
72
|
+
expect(uri.scheme).to eq('https')
|
73
|
+
expect(uri.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
74
|
+
expect(uri.port).to eq(443)
|
75
|
+
expect(uri.path).to eq('/as/resourceOwner')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should return valid URI object if uri is a URI object provided' do
|
79
|
+
uri = URI('https://esg-qa-oauth2-internal.fmr.com/as/resourceOwner')
|
80
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
81
|
+
expect(uri.scheme).to eq('https')
|
82
|
+
expect(uri.host).to eq('esg-qa-oauth2-internal.fmr.com')
|
83
|
+
expect(uri.port).to eq(443)
|
84
|
+
expect(uri.path).to eq('/as/resourceOwner')
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should successfully parse the Fidelity proxy uri' do
|
88
|
+
uri = 'http://http.proxy.fmr.com:8000'
|
89
|
+
uri = NetHTTP::Core.parse_uri(uri)
|
90
|
+
expect(uri.scheme).to eq('http')
|
91
|
+
expect(uri.host).to eq('http.proxy.fmr.com')
|
92
|
+
expect(uri.port).to eq(8000)
|
93
|
+
expect(uri.path).to eq('')
|
94
|
+
end
|
95
|
+
|
96
|
+
# NetHTTP::Core.schema_validation(opts, schema, logger = nil)
|
97
|
+
it 'should execute schema validation (pass) with no logger provided' do
|
98
|
+
opts = {}
|
99
|
+
opts[:required] = 'hello'
|
100
|
+
NetHTTP::Core.schema_validation(opts, Schema)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should execute schema validation (pass) with logger provided' do
|
104
|
+
logger = Logger.new(STDOUT)
|
105
|
+
logger.level = Logger::INFO
|
106
|
+
|
107
|
+
opts = {}
|
108
|
+
opts[:required] = 'hello'
|
109
|
+
NetHTTP::Core.schema_validation(opts, Schema, logger)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should execute schema validation (fail) with no logger provided' do
|
113
|
+
opts = {}
|
114
|
+
begin
|
115
|
+
NetHTTP::Core.schema_validation(opts, Schema)
|
116
|
+
rescue RuntimeError => err
|
117
|
+
expect(err.message.include?('NetHTTP::Core::Error - schema input validation failed.')).to eq(true)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should execute schema validation (fail) with logger provided' do
|
122
|
+
logger = Logger.new(STDOUT)
|
123
|
+
logger.level = Logger::DEBUG
|
124
|
+
|
125
|
+
opts = {}
|
126
|
+
begin
|
127
|
+
NetHTTP::Core.schema_validation(opts, Schema, logger)
|
128
|
+
rescue RuntimeError => err
|
129
|
+
expect(err.message.include?('NetHTTP::Core::Error - schema input validation failed.')).to eq(true)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# NetHTTP::Core.valid_json?(string)
|
134
|
+
it 'should return true for valid json string' do
|
135
|
+
valid_json_string = '{"key":"value"}'
|
136
|
+
|
137
|
+
expect(NetHTTP::Core.valid_json?(valid_json_string)).to eq(true)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should return true for valid json string passing in logger' do
|
141
|
+
logger = Logger.new(STDOUT)
|
142
|
+
logger.level = Logger::DEBUG
|
143
|
+
valid_json_string = '{"key":"value"}'
|
144
|
+
|
145
|
+
expect(NetHTTP::Core.valid_json?(valid_json_string, logger)).to eq(true)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should return false for invalid json string' do
|
149
|
+
invalid_json_string = ':'
|
150
|
+
|
151
|
+
expect(NetHTTP::Core.valid_json?(invalid_json_string)).to eq(false)
|
152
|
+
end
|
153
|
+
|
154
|
+
it 'should return false for invalid json string passing in logger' do
|
155
|
+
logger = Logger.new(STDOUT)
|
156
|
+
logger.level = Logger::DEBUG
|
157
|
+
invalid_json_string = ':'
|
158
|
+
|
159
|
+
expect(NetHTTP::Core.valid_json?(invalid_json_string, logger)).to eq(false)
|
160
|
+
end
|
161
|
+
|
162
|
+
# NetHTTP::Core.valid_xml?(string)
|
163
|
+
it 'should return true for valid xml string' do
|
164
|
+
valid_xml_string = '<key>value</key>'
|
165
|
+
|
166
|
+
expect(NetHTTP::Core.valid_xml?(valid_xml_string)).to eq(true)
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'should return true for valid xml string passing in logger' do
|
170
|
+
logger = Logger.new(STDOUT)
|
171
|
+
logger.level = Logger::DEBUG
|
172
|
+
valid_xml_string = '<key>value</key>'
|
173
|
+
|
174
|
+
expect(NetHTTP::Core.valid_xml?(valid_xml_string, logger)).to eq(true)
|
175
|
+
end
|
176
|
+
|
177
|
+
it 'should return false for invalid xml string' do
|
178
|
+
invalid_xml_string = '<key>value</key'
|
179
|
+
|
180
|
+
expect(NetHTTP::Core.valid_xml?(invalid_xml_string)).to eq(false)
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'should return false for invalid xml string passing in logger' do
|
184
|
+
logger = Logger.new(STDOUT)
|
185
|
+
logger.level = Logger::DEBUG
|
186
|
+
invalid_xml_string = '<key>value</key'
|
187
|
+
|
188
|
+
expect(NetHTTP::Core.valid_xml?(invalid_xml_string, logger)).to eq(false)
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should return false for an invalid xml string (html) but fails strict parsing passing in logger' do
|
192
|
+
logger = Logger.new(STDOUT)
|
193
|
+
logger.level = Logger::DEBUG
|
194
|
+
invalid_xml_string = %(<!DOCTYPE html>
|
195
|
+
<html>
|
196
|
+
<head>
|
197
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
198
|
+
<title>Eel slap!</title>
|
199
|
+
<meta property="og:title" content="Eel slap!" />
|
200
|
+
<meta property="og:type" content="website" />
|
201
|
+
<meta property="og:url" content="http://www.eelslap.com" />
|
202
|
+
<meta property="og:image" content="http://www.eelslap.com/facebook.png" />
|
203
|
+
<meta property="og:site_name" content="Eel slap!" />
|
204
|
+
<meta property="fb:admins" content="543574574" />
|
205
|
+
<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">
|
206
|
+
<META NAME="description" CONTENT="Ever wanted to slap someone in the face with an eel? Well, today is your lucky day.">
|
207
|
+
<META NAME="author" CONTENT="Per Stenius - http://www.perstenius.com">
|
208
|
+
<link rel="SHORTCUT ICON" href="favicon.ico"/>
|
209
|
+
<script type="text/javascript">
|
210
|
+
var _gaq = _gaq || [];
|
211
|
+
_gaq.push(['_setAccount', 'UA-114693-12']);
|
212
|
+
_gaq.push(['_trackPageview']);
|
213
|
+
|
214
|
+
(function() {
|
215
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
216
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
217
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
218
|
+
})();
|
219
|
+
</script>
|
220
|
+
<link rel="stylesheet" href="css/normalize.css" type="text/css">
|
221
|
+
<link rel="stylesheet" type="text/css" href="css/eelslap.css"/>
|
222
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
223
|
+
<script src="js/eelslap.js"></script>
|
224
|
+
|
225
|
+
</head>
|
226
|
+
<body>
|
227
|
+
<div id="eelcontainer" class="eel">
|
228
|
+
<div id="loader">LOADING...</div>
|
229
|
+
<div id="introtext">yo</div>
|
230
|
+
<div id="allimages">
|
231
|
+
<img class="eelimages" id="eelimage1" src="" width="15360" height="480">
|
232
|
+
<img class="eelimages" id="eelimage2" src="" width="14720" height="480">
|
233
|
+
<img class="eelimages" id="eelimage3" src="" width="15360" height="480">
|
234
|
+
<img class="eelimages" id="eelimage4" src="" width="14720" height="480">
|
235
|
+
</div>
|
236
|
+
</div>
|
237
|
+
<div class="footer">
|
238
|
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.eelslap.com" data-count="vertical">Tweet</a>
|
239
|
+
<script type="text/javascript" src="http://platform.twitter.com/widgets.js">
|
240
|
+
</script>
|
241
|
+
<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;">
|
242
|
+
</iframe><br>
|
243
|
+
|
244
|
+
<a href="http://actnormal.co" target="_blank">made by</a>
|
245
|
+
</div>
|
246
|
+
</body>
|
247
|
+
</html>)
|
248
|
+
|
249
|
+
expect(NetHTTP::Core.valid_xml?(invalid_xml_string, logger)).to eq(false)
|
250
|
+
end
|
251
|
+
|
252
|
+
# NetHTTP::Core.valid_html?(string)
|
253
|
+
it 'should return true for valid html string' do
|
254
|
+
valid_html_string = '<!DOCTYPE html>
|
255
|
+
<html>
|
256
|
+
<body>
|
257
|
+
<h1>Heading</h1>
|
258
|
+
<p>Paragraph.</p>
|
259
|
+
</body>
|
260
|
+
</html>'
|
261
|
+
|
262
|
+
expect(NetHTTP::Core.valid_html?(valid_html_string)).to eq(true)
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'should return true for an invalid html string passing in logger' do
|
266
|
+
logger = Logger.new(STDOUT)
|
267
|
+
logger.level = Logger::DEBUG
|
268
|
+
valid_html_string = '<!DOCTYPE html>
|
269
|
+
<html>
|
270
|
+
<body>
|
271
|
+
<h1>Heading</h1>
|
272
|
+
<p>Paragraph.</p>
|
273
|
+
</body>
|
274
|
+
</html>'
|
275
|
+
|
276
|
+
expect(NetHTTP::Core.valid_html?(valid_html_string, logger)).to eq(true)
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'should return true for a valid html string which contains javascript but fails strict parsing' do
|
280
|
+
html_string = %(<!DOCTYPE html>
|
281
|
+
<html>
|
282
|
+
<head>
|
283
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
284
|
+
<title>Eel slap!</title>
|
285
|
+
<meta property="og:title" content="Eel slap!" />
|
286
|
+
<meta property="og:type" content="website" />
|
287
|
+
<meta property="og:url" content="http://www.eelslap.com" />
|
288
|
+
<meta property="og:image" content="http://www.eelslap.com/facebook.png" />
|
289
|
+
<meta property="og:site_name" content="Eel slap!" />
|
290
|
+
<meta property="fb:admins" content="543574574" />
|
291
|
+
<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">
|
292
|
+
<META NAME="description" CONTENT="Ever wanted to slap someone in the face with an eel? Well, today is your lucky day.">
|
293
|
+
<META NAME="author" CONTENT="Per Stenius - http://www.perstenius.com">
|
294
|
+
<link rel="SHORTCUT ICON" href="favicon.ico"/>
|
295
|
+
<script type="text/javascript">
|
296
|
+
var _gaq = _gaq || [];
|
297
|
+
_gaq.push(['_setAccount', 'UA-114693-12']);
|
298
|
+
_gaq.push(['_trackPageview']);
|
299
|
+
|
300
|
+
(function() {
|
301
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
302
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
303
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
304
|
+
})();
|
305
|
+
</script>
|
306
|
+
<link rel="stylesheet" href="css/normalize.css" type="text/css">
|
307
|
+
<link rel="stylesheet" type="text/css" href="css/eelslap.css"/>
|
308
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
309
|
+
<script src="js/eelslap.js"></script>
|
310
|
+
|
311
|
+
</head>
|
312
|
+
<body>
|
313
|
+
<div id="eelcontainer" class="eel">
|
314
|
+
<div id="loader">LOADING...</div>
|
315
|
+
<div id="introtext">yo</div>
|
316
|
+
<div id="allimages">
|
317
|
+
<img class="eelimages" id="eelimage1" src="" width="15360" height="480">
|
318
|
+
<img class="eelimages" id="eelimage2" src="" width="14720" height="480">
|
319
|
+
<img class="eelimages" id="eelimage3" src="" width="15360" height="480">
|
320
|
+
<img class="eelimages" id="eelimage4" src="" width="14720" height="480">
|
321
|
+
</div>
|
322
|
+
</div>
|
323
|
+
<div class="footer">
|
324
|
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.eelslap.com" data-count="vertical">Tweet</a>
|
325
|
+
<script type="text/javascript" src="http://platform.twitter.com/widgets.js">
|
326
|
+
</script>
|
327
|
+
<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;">
|
328
|
+
</iframe><br>
|
329
|
+
|
330
|
+
<a href="http://actnormal.co" target="_blank">made by</a>
|
331
|
+
</div>
|
332
|
+
</body>
|
333
|
+
</html>)
|
334
|
+
|
335
|
+
expect(NetHTTP::Core.valid_html?(html_string)).to eq(true)
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should return true for a valid html string which contains javascript but fails strict parsing passing in logger' do
|
339
|
+
logger = Logger.new(STDOUT)
|
340
|
+
logger.level = Logger::DEBUG
|
341
|
+
html_string = %(<!DOCTYPE html>
|
342
|
+
<html>
|
343
|
+
<head>
|
344
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
345
|
+
<title>Eel slap!</title>
|
346
|
+
<meta property="og:title" content="Eel slap!" />
|
347
|
+
<meta property="og:type" content="website" />
|
348
|
+
<meta property="og:url" content="http://www.eelslap.com" />
|
349
|
+
<meta property="og:image" content="http://www.eelslap.com/facebook.png" />
|
350
|
+
<meta property="og:site_name" content="Eel slap!" />
|
351
|
+
<meta property="fb:admins" content="543574574" />
|
352
|
+
<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">
|
353
|
+
<META NAME="description" CONTENT="Ever wanted to slap someone in the face with an eel? Well, today is your lucky day.">
|
354
|
+
<META NAME="author" CONTENT="Per Stenius - http://www.perstenius.com">
|
355
|
+
<link rel="SHORTCUT ICON" href="favicon.ico"/>
|
356
|
+
<script type="text/javascript">
|
357
|
+
var _gaq = _gaq || [];
|
358
|
+
_gaq.push(['_setAccount', 'UA-114693-12']);
|
359
|
+
_gaq.push(['_trackPageview']);
|
360
|
+
|
361
|
+
(function() {
|
362
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
363
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
364
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
365
|
+
})();
|
366
|
+
</script>
|
367
|
+
<link rel="stylesheet" href="css/normalize.css" type="text/css">
|
368
|
+
<link rel="stylesheet" type="text/css" href="css/eelslap.css"/>
|
369
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
|
370
|
+
<script src="js/eelslap.js"></script>
|
371
|
+
|
372
|
+
</head>
|
373
|
+
<body>
|
374
|
+
<div id="eelcontainer" class="eel">
|
375
|
+
<div id="loader">LOADING...</div>
|
376
|
+
<div id="introtext">yo</div>
|
377
|
+
<div id="allimages">
|
378
|
+
<img class="eelimages" id="eelimage1" src="" width="15360" height="480">
|
379
|
+
<img class="eelimages" id="eelimage2" src="" width="14720" height="480">
|
380
|
+
<img class="eelimages" id="eelimage3" src="" width="15360" height="480">
|
381
|
+
<img class="eelimages" id="eelimage4" src="" width="14720" height="480">
|
382
|
+
</div>
|
383
|
+
</div>
|
384
|
+
<div class="footer">
|
385
|
+
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.eelslap.com" data-count="vertical">Tweet</a>
|
386
|
+
<script type="text/javascript" src="http://platform.twitter.com/widgets.js">
|
387
|
+
</script>
|
388
|
+
<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;">
|
389
|
+
</iframe><br>
|
390
|
+
|
391
|
+
<a href="http://actnormal.co" target="_blank">made by</a>
|
392
|
+
</div>
|
393
|
+
</body>
|
394
|
+
</html>)
|
395
|
+
|
396
|
+
expect(NetHTTP::Core.valid_html?(html_string, logger)).to eq(true)
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'should return false for an invalid html string' do
|
400
|
+
invalid_html_string = '<!DOCTYPE html>
|
401
|
+
<html>
|
402
|
+
<body>
|
403
|
+
<h1>Heading</h1>
|
404
|
+
<p>Paragraph.</p>
|
405
|
+
</body'
|
406
|
+
|
407
|
+
expect(NetHTTP::Core.valid_html?(invalid_html_string)).to eq(false)
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'should return false for an invalid html string passing in logger' do
|
411
|
+
logger = Logger.new(STDOUT)
|
412
|
+
logger.level = Logger::DEBUG
|
413
|
+
invalid_html_string = '<!DOCTYPE html>
|
414
|
+
<html>
|
415
|
+
<body>
|
416
|
+
<h1>Heading</h1>
|
417
|
+
<p>Paragraph.</p>
|
418
|
+
</body'
|
419
|
+
|
420
|
+
expect(NetHTTP::Core.valid_html?(invalid_html_string, logger)).to eq(false)
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'should return false for an invalid html string' do
|
424
|
+
invalid_html_string = '<!DOCTYPE html>
|
425
|
+
<html>
|
426
|
+
<body>
|
427
|
+
<h1>Heading</h1>
|
428
|
+
<p>Paragraph.</p>
|
429
|
+
</body>'
|
430
|
+
|
431
|
+
expect(NetHTTP::Core.valid_html?(invalid_html_string)).to eq(false)
|
432
|
+
end
|
433
|
+
end
|