webspicy 0.14.0 → 0.15.0.pre.rc1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5b78ed1d162fe75c83bd7bffa819b61ec7153dab
4
- data.tar.gz: c5a6ba9ee1d76e1e861d1952fd135664a5e1b408
2
+ SHA256:
3
+ metadata.gz: 510691d8141022c21d24de399e71457354d6ef9852463459245c66aae49cf8c7
4
+ data.tar.gz: a95593328ab9190d8f58b63308e31671528d4a9ef8b464772f4b80a74fee07b6
5
5
  SHA512:
6
- metadata.gz: 31da61f468c86496d77f1eb659e17e4b02ec4de80ba14e6a6220a26cde324c9b0113099c4457f45a05be378ccd2acbaba172268fe60000172704c992623a8554
7
- data.tar.gz: a347f32c634c884cfdb29ee92e5a4b0d6ca5134b9f9ec95ac8ee604e244ac3f332fc71b846e47c9a3744febcf63fcc631c0f7a0cf1cc452f880f25370c2a3406
6
+ metadata.gz: 6c2be87c7977f92f5855f3d9f8d45efe5824c30e634136df977f8c77f020725eb1b7750ec176c7f8e75313000a71b0dbc2e108a08a529db2830c0eeefb2381b6
7
+ data.tar.gz: 7d476d7a3ccd38f998ed54e132fb58324634de107144e858d4847918a493bf2acfc6d7aed1c6527a1056b9af5073e62d9e70cc5822b1955ada39471ab1c048fd
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- webspicy (0.14.0)
4
+ webspicy (0.15.0.pre.rc1)
5
5
  finitio (>= 0.8.0)
6
6
  http (~> 2)
7
7
  mustermann (~> 1.0)
@@ -33,14 +33,15 @@ GEM
33
33
  domain_name (~> 0.5)
34
34
  http-form_data (1.0.3)
35
35
  http_parser.rb (0.6.0)
36
- mustermann (1.0.3)
37
- mustermann-contrib (1.0.3)
36
+ mustermann (1.1.1)
37
+ ruby2_keywords (~> 0.0.1)
38
+ mustermann-contrib (1.1.1)
38
39
  hansi (~> 0.2.0)
39
- mustermann (= 1.0.3)
40
+ mustermann (= 1.1.1)
40
41
  path (1.3.3)
41
42
  public_suffix (4.0.3)
42
- rack (2.0.7)
43
- rack-protection (2.0.7)
43
+ rack (2.2.2)
44
+ rack-protection (2.0.8.1)
44
45
  rack
45
46
  rack-robustness (1.1.0)
46
47
  rack-test (0.6.3)
@@ -61,10 +62,11 @@ GEM
61
62
  rspec-support (3.9.2)
62
63
  rspec_junit_formatter (0.4.1)
63
64
  rspec-core (>= 2, < 4, != 2.12.0)
64
- sinatra (2.0.7)
65
+ ruby2_keywords (0.0.2)
66
+ sinatra (2.0.8.1)
65
67
  mustermann (~> 1.0)
66
68
  rack (~> 2.0)
67
- rack-protection (= 2.0.7)
69
+ rack-protection (= 2.0.8.1)
68
70
  tilt (~> 2.0)
69
71
  tilt (2.0.10)
70
72
  unf (0.1.4)
@@ -80,4 +82,4 @@ DEPENDENCIES
80
82
  webspicy!
81
83
 
82
84
  BUNDLED WITH
83
- 2.1.0.pre.1
85
+ 2.0.2
data/lib/webspicy.rb CHANGED
@@ -18,8 +18,6 @@ module Webspicy
18
18
  require 'webspicy/file_upload'
19
19
  require 'webspicy/scope'
20
20
  require 'webspicy/client'
21
- require 'webspicy/client/http_client'
22
- require 'webspicy/client/rack_test_client'
23
21
  require 'webspicy/resource'
24
22
  require 'webspicy/precondition'
25
23
  require 'webspicy/postcondition'
@@ -132,6 +130,9 @@ module Webspicy
132
130
 
133
131
  LOGGER = ::Logger.new(STDOUT)
134
132
  LOGGER.level = Logger.const_get(ENV['LOG_LEVEL'] || 'WARN')
133
+ LOGGER.formatter = proc { |severity, datetime, progname, msg|
134
+ " " + msg + "\n"
135
+ }
135
136
 
136
137
  def info(*args, &bl)
137
138
  LOGGER && LOGGER.info(*args, &bl)
@@ -56,3 +56,6 @@ module Webspicy
56
56
 
57
57
  end
58
58
  end
59
+ require_relative 'client/support'
60
+ require_relative 'client/http_client'
61
+ require_relative 'client/rack_test_client'
@@ -40,33 +40,32 @@ module Webspicy
40
40
  end
41
41
 
42
42
  class Api
43
+ include Client::Support
43
44
 
44
45
  attr_reader :last_response
45
46
 
46
47
  def options(url, params = {}, headers = nil, body = nil)
47
- Webspicy.info("OPTIONS #{url} -- #{params.inspect}")
48
+ info_request("OPTIONS", url, params, headers, body)
48
49
 
49
50
  @last_response = HTTP[headers || {}].options(url, params: params)
50
51
 
51
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
52
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
52
+ debug_response(@last_response)
53
53
 
54
54
  @last_response
55
55
  end
56
56
 
57
57
  def get(url, params = {}, headers = nil, body = nil)
58
- Webspicy.info("GET #{url} -- #{params.inspect}")
58
+ info_request("GET", url, params, headers, body)
59
59
 
60
60
  @last_response = HTTP[headers || {}].get(url, params: params)
61
61
 
62
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
63
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
62
+ debug_response(@last_response)
64
63
 
65
64
  @last_response
66
65
  end
67
66
 
68
67
  def post(url, params = {}, headers = nil, body = nil)
69
- Webspicy.info("POST #{url} -- #{params.inspect}")
68
+ info_request("POST", url, params, headers, body)
70
69
 
71
70
  url = url + "?" + Rack::Utils.build_query(params) if body && !params.empty?
72
71
 
@@ -87,43 +86,39 @@ module Webspicy
87
86
  @last_response = HTTP[headers].post(url, body: body)
88
87
  end
89
88
 
90
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
91
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
89
+ debug_response(@last_response)
92
90
 
93
91
  @last_response
94
92
  end
95
93
 
96
94
  def patch(url, params = {}, headers = nil, body = nil)
97
- Webspicy.info("PATCH #{url} -- #{params.inspect}")
95
+ info_request("PATCH", url, params, headers, body)
98
96
 
99
97
  headers ||= {}
100
98
  headers['Content-Type'] ||= 'application/json'
101
99
  @last_response = HTTP[headers].patch(url, body: params.to_json)
102
100
 
103
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
104
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
101
+ debug_response(@last_response)
105
102
 
106
103
  @last_response
107
104
  end
108
105
 
109
106
  def post_form(url, params = {}, headers = nil, body = nil)
110
- Webspicy.info("POST #{url} -- #{params.inspect}")
107
+ info_request("POST", url, params, headers, body)
111
108
 
112
109
  @last_response = HTTP[headers || {}].post(url, form: params)
113
110
 
114
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
115
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
111
+ debug_response(@last_response)
116
112
 
117
113
  @last_response
118
114
  end
119
115
 
120
116
  def delete(url, params = {}, headers = nil, body = nil)
121
- Webspicy.info("DELETE #{url} -- #{params.inspect}")
117
+ info_request("DELETE", url, params, headers, body)
122
118
 
123
119
  @last_response = HTTP[headers || {}].delete(url, body: params.to_json)
124
120
 
125
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
126
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
121
+ debug_response(@last_response)
127
122
 
128
123
  @last_response
129
124
  end
@@ -54,6 +54,7 @@ module Webspicy
54
54
  end # class RackHandler
55
55
 
56
56
  class Api
57
+ include Client::Support
57
58
 
58
59
  attr_reader :last_response
59
60
 
@@ -64,13 +65,12 @@ module Webspicy
64
65
  def options(url, params = {}, headers = nil, body = nil)
65
66
  handler = get_handler(headers)
66
67
 
67
- Webspicy.info("OPTIONS #{url} -- #{params.inspect} -- #{headers.inspect}")
68
+ info_request("OPTIONS", url, params, headers, body)
68
69
 
69
70
  handler.options(url, params)
70
71
  @last_response = handler.last_response
71
72
 
72
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
73
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
73
+ debug_response(@last_response)
74
74
 
75
75
  @last_response
76
76
  end
@@ -79,13 +79,12 @@ module Webspicy
79
79
  handler = get_handler(headers)
80
80
 
81
81
  params = Hash[params.map{|k,v| [k, v.nil? ? "" : v] }]
82
- Webspicy.info("GET #{url} -- #{params.inspect} -- #{headers.inspect}")
82
+ info_request("GET", url, params, headers, body)
83
83
 
84
84
  handler.get(url, params)
85
85
  @last_response = handler.last_response
86
86
 
87
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
88
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
87
+ debug_response(@last_response)
89
88
 
90
89
  @last_response
91
90
  end
@@ -97,20 +96,19 @@ module Webspicy
97
96
 
98
97
  case body
99
98
  when NilClass
100
- Webspicy.info("POST #{url} -- #{params.inspect} -- #{headers.inspect}")
99
+ info_request("POST", url, params, headers, body)
101
100
  handler.post(url, params.to_json, {"CONTENT_TYPE" => "application/json"})
102
101
  when FileUpload
103
102
  file = Rack::Test::UploadedFile.new(body.path, body.content_type)
104
- Webspicy.info("POST #{url} -- #{params.inspect} -- #{body}")
103
+ info_request("POST", url, params, headers, body)
105
104
  handler.post(url, body.param_name.to_sym => file)
106
105
  else
107
- Webspicy.info("POST #{url} -- #{params.inspect} -- #{body.inspect[0..25]}")
106
+ info_request("POST", url, params, headers, body)
108
107
  handler.post(url, body)
109
108
  end
110
109
  @last_response = handler.last_response
111
110
 
112
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
113
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
111
+ debug_response(@last_response)
114
112
 
115
113
  @last_response
116
114
  end
@@ -118,13 +116,12 @@ module Webspicy
118
116
  def patch(url, params = {}, headers = nil, body = nil)
119
117
  handler = get_handler(headers)
120
118
 
121
- Webspicy.info("PATCH #{url} -- #{params.inspect} -- #{headers.inspect}")
119
+ info_request("PATCH", url, params, headers, body)
122
120
 
123
121
  handler.patch(url, params.to_json, {"CONTENT_TYPE" => "application/json"})
124
122
  @last_response = handler.last_response
125
123
 
126
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
127
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
124
+ debug_response(@last_response)
128
125
 
129
126
  @last_response
130
127
  end
@@ -132,13 +129,12 @@ module Webspicy
132
129
  def post_form(url, params = {}, headers = nil, body = nil)
133
130
  handler = get_handler(headers)
134
131
 
135
- Webspicy.info("POST #{url} -- #{params.inspect} -- #{headers.inspect}")
132
+ info_request("POST", url, params, headers, body)
136
133
 
137
134
  handler.post(url, params)
138
135
  @last_response = handler.last_response
139
136
 
140
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
141
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
137
+ debug_response(@last_response)
142
138
 
143
139
  @last_response
144
140
  end
@@ -146,13 +142,12 @@ module Webspicy
146
142
  def delete(url, params = {}, headers = nil, body = nil)
147
143
  handler = get_handler(headers)
148
144
 
149
- Webspicy.info("DELETE #{url} -- #{params.inspect} -- #{headers.inspect}")
145
+ info_request("DELETE", url, params, headers, body)
150
146
 
151
147
  handler.delete(url, params.to_json, {"CONTENT_TYPE" => "application/json"})
152
148
  @last_response = handler.last_response
153
149
 
154
- Webspicy.debug("Headers: #{@last_response.headers.to_hash}")
155
- Webspicy.debug("Response (#{@last_response.status}): #{@last_response.body}")
150
+ debug_response(@last_response)
156
151
 
157
152
  @last_response
158
153
  end
@@ -0,0 +1,39 @@
1
+ module Webspicy
2
+ class Client
3
+ module Support
4
+
5
+ def info_request(kind, url, params, headers, body)
6
+ Webspicy.info("#{kind} #{url}")
7
+ debug("Req params", JSON.pretty_generate(params)) if params
8
+ debug("Req headers", JSON.pretty_generate(headers)) if headers
9
+ debug("Req body", JSON.pretty_generate(body)) if body
10
+ Webspicy.debug("")
11
+ end
12
+
13
+ def debug_response(response)
14
+ debug("Res status", @last_response.status)
15
+ debug("Res headers", JSON.pretty_generate(last_response.headers.to_h))
16
+ debug("Res body", response_body_to_s(last_response))
17
+ Webspicy.debug("")
18
+ end
19
+
20
+ def debug(what, value)
21
+ Webspicy.debug(" #{what}: " + value_to_s(value))
22
+ end
23
+
24
+ def response_body_to_s(response)
25
+ case response.content_type.to_s
26
+ when /json/
27
+ JSON.pretty_generate(JSON.load(response.body))
28
+ else
29
+ response.body.to_s
30
+ end
31
+ end
32
+
33
+ def value_to_s(value)
34
+ value.to_s.gsub(/\n/, "\n ")
35
+ end
36
+
37
+ end # module Support
38
+ end # class Client
39
+ end # module Webspicy
@@ -1,8 +1,8 @@
1
1
  module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 14
5
- TINY = 0
4
+ MINOR = 15
5
+ TINY = "0-rc1"
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webspicy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernard Lambeau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2020-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -210,6 +210,7 @@ files:
210
210
  - lib/webspicy/client.rb
211
211
  - lib/webspicy/client/http_client.rb
212
212
  - lib/webspicy/client/rack_test_client.rb
213
+ - lib/webspicy/client/support.rb
213
214
  - lib/webspicy/configuration.rb
214
215
  - lib/webspicy/file_upload.rb
215
216
  - lib/webspicy/formaldoc.fio
@@ -255,12 +256,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
255
256
  version: '0'
256
257
  required_rubygems_version: !ruby/object:Gem::Requirement
257
258
  requirements:
258
- - - ">="
259
+ - - ">"
259
260
  - !ruby/object:Gem::Version
260
- version: '0'
261
+ version: 1.3.1
261
262
  requirements: []
262
263
  rubyforge_project:
263
- rubygems_version: 2.6.11
264
+ rubygems_version: 2.7.6
264
265
  signing_key:
265
266
  specification_version: 4
266
267
  summary: Webspicy helps testing web services as software operation black boxes!