committee 5.6.1 → 5.6.3
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 +4 -4
- data/lib/committee/drivers/open_api_3/driver.rb +7 -1
- data/lib/committee/drivers.rb +2 -3
- data/lib/committee/errors.rb +11 -0
- data/lib/committee/middleware/base.rb +11 -5
- data/lib/committee/middleware/options/base.rb +107 -0
- data/lib/committee/middleware/options/request_validation.rb +80 -0
- data/lib/committee/middleware/options/response_validation.rb +46 -0
- data/lib/committee/middleware/options.rb +12 -0
- data/lib/committee/middleware/request_validation.rb +7 -1
- data/lib/committee/middleware/response_validation.rb +6 -2
- data/lib/committee/middleware.rb +1 -0
- data/lib/committee/schema_validator/hyper_schema/response_generator.rb +1 -3
- data/lib/committee/schema_validator/hyper_schema/response_validator.rb +14 -1
- data/lib/committee/schema_validator/hyper_schema/router.rb +1 -1
- data/lib/committee/schema_validator/hyper_schema.rb +3 -14
- data/lib/committee/schema_validator/open_api_3/operation_wrapper.rb +43 -13
- data/lib/committee/schema_validator/open_api_3/parameter_deserializer.rb +556 -0
- data/lib/committee/schema_validator/open_api_3/response_validator.rb +16 -2
- data/lib/committee/schema_validator/open_api_3.rb +19 -13
- data/lib/committee/schema_validator/option.rb +6 -17
- data/lib/committee/schema_validator.rb +12 -1
- data/lib/committee/test/except_parameter.rb +416 -0
- data/lib/committee/test/methods.rb +38 -2
- data/lib/committee/version.rb +1 -1
- data/lib/committee.rb +1 -1
- data/test/drivers/open_api_2/driver_test.rb +4 -16
- data/test/drivers/open_api_2/parameter_schema_builder_test.rb +4 -50
- data/test/drivers_test.rb +35 -21
- data/test/middleware/options/base_test.rb +120 -0
- data/test/middleware/options/request_validation_test.rb +177 -0
- data/test/middleware/options/response_validation_test.rb +121 -0
- data/test/middleware/request_validation_open_api_3_test.rb +200 -80
- data/test/middleware/request_validation_test.rb +13 -70
- data/test/middleware/response_validation_open_api_3_test.rb +40 -17
- data/test/middleware/response_validation_test.rb +3 -14
- data/test/request_unpacker_test.rb +2 -10
- data/test/schema_validator/hyper_schema/parameter_coercer_test.rb +1 -37
- data/test/schema_validator/hyper_schema/request_validator_test.rb +6 -30
- data/test/schema_validator/hyper_schema/router_test.rb +5 -0
- data/test/schema_validator/hyper_schema/string_params_coercer_test.rb +1 -37
- data/test/schema_validator/open_api_3/operation_wrapper_test.rb +58 -43
- data/test/schema_validator/open_api_3/parameter_deserializer_test.rb +457 -0
- data/test/schema_validator/open_api_3/request_validator_test.rb +1 -2
- data/test/schema_validator/open_api_3/response_validator_test.rb +3 -11
- data/test/schema_validator_test.rb +41 -0
- data/test/test/methods_test.rb +238 -105
- data/test/test/schema_coverage_test.rb +8 -155
- metadata +11 -1
data/test/test/methods_test.rb
CHANGED
|
@@ -151,6 +151,14 @@ describe Committee::Test::Methods do
|
|
|
151
151
|
assert_request_schema_confirm
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
+
it "increments the Minitest assertion count on success" do
|
|
155
|
+
@app = new_rack_app
|
|
156
|
+
get "/characters"
|
|
157
|
+
before_count = assertions
|
|
158
|
+
assert_request_schema_confirm
|
|
159
|
+
assert_equal before_count + 1, assertions
|
|
160
|
+
end
|
|
161
|
+
|
|
154
162
|
it "not exist required" do
|
|
155
163
|
@app = new_rack_app
|
|
156
164
|
get "/validate", { "query_string" => "query", "query_integer_list" => [1, 2] }
|
|
@@ -169,6 +177,225 @@ describe Committee::Test::Methods do
|
|
|
169
177
|
end
|
|
170
178
|
assert_match(/`GET \/undefined` undefined in schema/i, e.message)
|
|
171
179
|
end
|
|
180
|
+
|
|
181
|
+
describe "with except option" do
|
|
182
|
+
it "passes validation when required query parameter is excepted" do
|
|
183
|
+
@app = new_rack_app
|
|
184
|
+
# Missing required 'data' parameter, but except it
|
|
185
|
+
get "/get_endpoint_with_required_parameter"
|
|
186
|
+
assert_request_schema_confirm(except: { query: ['data'] })
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it "still validates other parameters when some are excepted" do
|
|
190
|
+
@app = new_rack_app
|
|
191
|
+
# Missing required 'data' parameter, but except it
|
|
192
|
+
# This test verifies that the except option works
|
|
193
|
+
get "/get_endpoint_with_required_parameter"
|
|
194
|
+
assert_request_schema_confirm(except: { query: ['data'] })
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
it "works without except option (backward compatibility)" do
|
|
198
|
+
@app = new_rack_app
|
|
199
|
+
get "/characters"
|
|
200
|
+
assert_request_schema_confirm
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it "supports multiple parameter types" do
|
|
204
|
+
@app = new_rack_app
|
|
205
|
+
# Can except headers, query, and body parameters
|
|
206
|
+
get "/get_endpoint_with_required_parameter"
|
|
207
|
+
assert_request_schema_confirm(except: { headers: ['authorization'], query: ['data'] })
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "supports multiple parameters in each type" do
|
|
211
|
+
@app = new_rack_app
|
|
212
|
+
# Can except multiple parameters in each type simultaneously
|
|
213
|
+
get "/get_endpoint_with_required_parameter"
|
|
214
|
+
assert_request_schema_confirm(except: { headers: ['content-type', 'authorization', 'accept'], query: ['data', 'page', 'limit'] })
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it "raises error when non-excepted required parameter is missing" do
|
|
218
|
+
@app = new_rack_app
|
|
219
|
+
# Except only 'required_param_a', but 'required_param_b' is also required and missing
|
|
220
|
+
# This should raise an error for 'required_param_b'
|
|
221
|
+
get "/test_except_validation"
|
|
222
|
+
|
|
223
|
+
e = assert_raises(Committee::InvalidRequest) do
|
|
224
|
+
assert_request_schema_confirm(except: { query: ['required_param_a'] })
|
|
225
|
+
end
|
|
226
|
+
# Verify error is about the non-excepted missing parameter
|
|
227
|
+
assert_match(/required_param_b/i, e.message)
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
describe "with body params" do
|
|
231
|
+
it "passes validation when required string body param is excepted" do
|
|
232
|
+
@app = new_rack_app
|
|
233
|
+
post "/test_except_body_params", JSON.generate({ "required_integer" => 1 }), { "CONTENT_TYPE" => "application/json" }
|
|
234
|
+
assert_request_schema_confirm(except: { body: ['required_string'] })
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
it "passes validation when required integer body param is excepted" do
|
|
238
|
+
@app = new_rack_app
|
|
239
|
+
post "/test_except_body_params", JSON.generate({ "required_string" => "foo" }), { "CONTENT_TYPE" => "application/json" }
|
|
240
|
+
assert_request_schema_confirm(except: { body: ['required_integer'] })
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it "passes validation when all required body params are excepted" do
|
|
244
|
+
@app = new_rack_app
|
|
245
|
+
post "/test_except_body_params", nil, { "CONTENT_TYPE" => "application/json" }
|
|
246
|
+
assert_request_schema_confirm(except: { body: ['required_string', 'required_integer'] })
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it "raises error when non-excepted required body param is missing" do
|
|
250
|
+
@app = new_rack_app
|
|
251
|
+
post "/test_except_body_params", nil, { "CONTENT_TYPE" => "application/json" }
|
|
252
|
+
e = assert_raises(Committee::InvalidRequest) do
|
|
253
|
+
assert_request_schema_confirm(except: { body: ['required_string'] })
|
|
254
|
+
end
|
|
255
|
+
assert_match(/required_integer/i, e.message)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
describe "non-string types and format constraints" do
|
|
259
|
+
it "passes validation when required integer query param is excepted" do
|
|
260
|
+
@app = new_rack_app
|
|
261
|
+
get "/get_endpoint_with_required_integer_query"
|
|
262
|
+
assert_request_schema_confirm(except: { query: ['count'] })
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
it "passes validation when required integer header is excepted" do
|
|
266
|
+
@app = new_rack_app
|
|
267
|
+
get "/header"
|
|
268
|
+
assert_request_schema_confirm(except: { headers: ['integer'] })
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
it "passes validation when required enum body param is excepted" do
|
|
272
|
+
@app = new_rack_app
|
|
273
|
+
post "/test_except_body_with_constraints", JSON.generate({ "created_at" => "2024-01-01T00:00:00Z" }), { "CONTENT_TYPE" => "application/json" }
|
|
274
|
+
assert_request_schema_confirm(except: { body: ['status'] })
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
it "passes validation when required date-time format body param is excepted" do
|
|
278
|
+
@app = new_rack_app
|
|
279
|
+
post "/test_except_body_with_constraints", JSON.generate({ "status" => "active" }), { "CONTENT_TYPE" => "application/json" }
|
|
280
|
+
assert_request_schema_confirm(except: { body: ['created_at'] })
|
|
281
|
+
end
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
describe "with form-encoded body params" do
|
|
285
|
+
it "passes validation when required string form param is excepted" do
|
|
286
|
+
@app = new_rack_app
|
|
287
|
+
post "/test_except_form_params", "required_integer=1", { "CONTENT_TYPE" => "application/x-www-form-urlencoded" }
|
|
288
|
+
assert_request_schema_confirm(except: { body: ['required_string'] })
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
it "passes validation when required integer form param is excepted" do
|
|
292
|
+
@app = new_rack_app
|
|
293
|
+
post "/test_except_form_params", "required_string=foo", { "CONTENT_TYPE" => "application/x-www-form-urlencoded" }
|
|
294
|
+
assert_request_schema_confirm(except: { body: ['required_integer'] })
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
it "passes validation when all required form params are excepted" do
|
|
298
|
+
@app = new_rack_app
|
|
299
|
+
post "/test_except_form_params", "", { "CONTENT_TYPE" => "application/x-www-form-urlencoded" }
|
|
300
|
+
assert_request_schema_confirm(except: { body: ['required_string', 'required_integer'] })
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
it "raises error when non-excepted required form param is missing" do
|
|
304
|
+
@app = new_rack_app
|
|
305
|
+
post "/test_except_form_params", "", { "CONTENT_TYPE" => "application/x-www-form-urlencoded" }
|
|
306
|
+
e = assert_raises(Committee::InvalidRequest) do
|
|
307
|
+
assert_request_schema_confirm(except: { body: ['required_string'] })
|
|
308
|
+
end
|
|
309
|
+
assert_match(/required_integer/i, e.message)
|
|
310
|
+
end
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
describe "with special rack headers" do
|
|
314
|
+
it "passes validation when required Content-Type header is excepted" do
|
|
315
|
+
@app = new_rack_app
|
|
316
|
+
post "/test_except_content_type_header", nil
|
|
317
|
+
assert_request_schema_confirm(except: { headers: ['Content-Type'] })
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
describe "does not overwrite existing values" do
|
|
322
|
+
it "leaves an existing query param value unchanged when it is excepted" do
|
|
323
|
+
@app = new_rack_app
|
|
324
|
+
get "/get_endpoint_with_required_parameter", "data" => "existing_value"
|
|
325
|
+
before_value = last_request.GET["data"]
|
|
326
|
+
assert_request_schema_confirm(except: { query: ['data'] })
|
|
327
|
+
assert_equal before_value, last_request.GET["data"]
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
describe "with vnd.api+json content type" do
|
|
332
|
+
it "treats application/vnd.api+json body as JSON and injects dummy values" do
|
|
333
|
+
@app = new_rack_app
|
|
334
|
+
post "/test_except_vnd_json_body", JSON.generate({}), { "CONTENT_TYPE" => "application/vnd.api+json" }
|
|
335
|
+
assert_request_schema_confirm(except: { body: ['required_string'] })
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
describe "with schema_path option" do
|
|
340
|
+
before do
|
|
341
|
+
@committee_options = { schema_path: open_api_3_schema_path }
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
it "passes validation when required integer query param is excepted" do
|
|
345
|
+
@app = new_rack_app
|
|
346
|
+
get "/get_endpoint_with_required_integer_query"
|
|
347
|
+
assert_request_schema_confirm(except: { query: ['count'] })
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
|
|
351
|
+
describe "with path item-level parameters" do
|
|
352
|
+
it "passes validation when required integer query param declared at path level is excepted" do
|
|
353
|
+
@app = new_rack_app
|
|
354
|
+
get "/test_path_level_required_integer"
|
|
355
|
+
assert_request_schema_confirm(except: { query: ['count'] })
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
describe "with multiple content-type body" do
|
|
360
|
+
it "uses the correct schema for form-urlencoded when excepting a body param" do
|
|
361
|
+
@app = new_rack_app
|
|
362
|
+
post "/test_multi_content_type_body", "", "CONTENT_TYPE" => "application/x-www-form-urlencoded"
|
|
363
|
+
assert_request_schema_confirm(except: { body: ['status'] })
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
describe "with non-hash JSON body" do
|
|
368
|
+
it "raises BadRequest when JSON body is an array" do
|
|
369
|
+
@app = new_rack_app
|
|
370
|
+
post "/test_except_body_params", "[1,2,3]", "CONTENT_TYPE" => "application/json"
|
|
371
|
+
assert_raises(Committee::BadRequest) do
|
|
372
|
+
assert_request_schema_confirm(except: { body: ['required_string'] })
|
|
373
|
+
end
|
|
374
|
+
end
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
describe "error recovery" do
|
|
378
|
+
it "restores partially-applied params when JSON body parsing raises mid-apply" do
|
|
379
|
+
# Scenario: HeaderHandler injects a dummy header, then BodyHandler fails
|
|
380
|
+
# to parse an invalid JSON body (JSON::ParserError). With apply() outside
|
|
381
|
+
# the ensure block the injected header would not be restored. This test
|
|
382
|
+
# verifies that all side-effects from apply() are rolled back even when
|
|
383
|
+
# apply() itself raises.
|
|
384
|
+
@app = new_rack_app
|
|
385
|
+
post "/test_except_body_params", 'invalid-json', { "CONTENT_TYPE" => "application/json" }
|
|
386
|
+
|
|
387
|
+
assert_nil last_request.env['HTTP_AUTHORIZATION']
|
|
388
|
+
|
|
389
|
+
assert_raises(JSON::ParserError) do
|
|
390
|
+
assert_request_schema_confirm(except: { headers: ['authorization'], body: ['required_string'] })
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
assert_nil last_request.env['HTTP_AUTHORIZATION']
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
end
|
|
398
|
+
end
|
|
172
399
|
end
|
|
173
400
|
|
|
174
401
|
describe "#assert_response_schema_confirm" do
|
|
@@ -178,6 +405,14 @@ describe Committee::Test::Methods do
|
|
|
178
405
|
assert_response_schema_confirm(200)
|
|
179
406
|
end
|
|
180
407
|
|
|
408
|
+
it "increments the Minitest assertion count on success" do
|
|
409
|
+
@app = new_rack_app(JSON.generate(@correct_response))
|
|
410
|
+
get "/characters"
|
|
411
|
+
before_count = assertions
|
|
412
|
+
assert_response_schema_confirm(200)
|
|
413
|
+
assert_equal before_count + 1, assertions
|
|
414
|
+
end
|
|
415
|
+
|
|
181
416
|
it "detects an invalid response Content-Type" do
|
|
182
417
|
@app = new_rack_app(JSON.generate([@correct_response]), {})
|
|
183
418
|
get "/characters"
|
|
@@ -227,122 +462,20 @@ describe Committee::Test::Methods do
|
|
|
227
462
|
it 'records openapi coverage' do
|
|
228
463
|
get "/posts"
|
|
229
464
|
assert_response_schema_confirm(200)
|
|
230
|
-
assert_equal({
|
|
231
|
-
'/threads/{id}' => {
|
|
232
|
-
'get' => {
|
|
233
|
-
'responses' => {
|
|
234
|
-
'200' => false,
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
'/posts' => {
|
|
239
|
-
'get' => {
|
|
240
|
-
'responses' => {
|
|
241
|
-
'200' => true,
|
|
242
|
-
'404' => false,
|
|
243
|
-
'default' => false,
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
|
-
'post' => {
|
|
247
|
-
'responses' => {
|
|
248
|
-
'200' => false,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
},
|
|
252
|
-
'/likes' => {
|
|
253
|
-
'post' => {
|
|
254
|
-
'responses' => {
|
|
255
|
-
'200' => false,
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
'delete' => {
|
|
259
|
-
'responses' => {
|
|
260
|
-
'200' => false,
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
}, @schema_coverage.report)
|
|
465
|
+
assert_equal({ '/threads/{id}' => { 'get' => { 'responses' => { '200' => false, }, }, }, '/posts' => { 'get' => { 'responses' => { '200' => true, '404' => false, 'default' => false, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => false, }, }, 'delete' => { 'responses' => { '200' => false, }, }, }, }, @schema_coverage.report)
|
|
265
466
|
end
|
|
266
467
|
|
|
267
468
|
it 'can record openapi coverage correctly when prefix is set' do
|
|
268
469
|
@committee_options.merge!(prefix: '/api')
|
|
269
470
|
post "/api/likes"
|
|
270
471
|
assert_response_schema_confirm(200)
|
|
271
|
-
assert_equal({
|
|
272
|
-
'/threads/{id}' => {
|
|
273
|
-
'get' => {
|
|
274
|
-
'responses' => {
|
|
275
|
-
'200' => false,
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
},
|
|
279
|
-
'/posts' => {
|
|
280
|
-
'get' => {
|
|
281
|
-
'responses' => {
|
|
282
|
-
'200' => false,
|
|
283
|
-
'404' => false,
|
|
284
|
-
'default' => false,
|
|
285
|
-
},
|
|
286
|
-
},
|
|
287
|
-
'post' => {
|
|
288
|
-
'responses' => {
|
|
289
|
-
'200' => false,
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
'/likes' => {
|
|
294
|
-
'post' => {
|
|
295
|
-
'responses' => {
|
|
296
|
-
'200' => true,
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
'delete' => {
|
|
300
|
-
'responses' => {
|
|
301
|
-
'200' => false,
|
|
302
|
-
},
|
|
303
|
-
},
|
|
304
|
-
},
|
|
305
|
-
}, @schema_coverage.report)
|
|
472
|
+
assert_equal({ '/threads/{id}' => { 'get' => { 'responses' => { '200' => false, }, }, }, '/posts' => { 'get' => { 'responses' => { '200' => false, '404' => false, 'default' => false, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => true, }, }, 'delete' => { 'responses' => { '200' => false, }, }, }, }, @schema_coverage.report)
|
|
306
473
|
end
|
|
307
474
|
|
|
308
475
|
it 'records openapi coverage correctly with path param' do
|
|
309
476
|
get "/threads/asd"
|
|
310
477
|
assert_response_schema_confirm(200)
|
|
311
|
-
assert_equal({
|
|
312
|
-
'/threads/{id}' => {
|
|
313
|
-
'get' => {
|
|
314
|
-
'responses' => {
|
|
315
|
-
'200' => true,
|
|
316
|
-
},
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
'/posts' => {
|
|
320
|
-
'get' => {
|
|
321
|
-
'responses' => {
|
|
322
|
-
'200' => false,
|
|
323
|
-
'404' => false,
|
|
324
|
-
'default' => false,
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
'post' => {
|
|
328
|
-
'responses' => {
|
|
329
|
-
'200' => false,
|
|
330
|
-
},
|
|
331
|
-
},
|
|
332
|
-
},
|
|
333
|
-
'/likes' => {
|
|
334
|
-
'post' => {
|
|
335
|
-
'responses' => {
|
|
336
|
-
'200' => false,
|
|
337
|
-
},
|
|
338
|
-
},
|
|
339
|
-
'delete' => {
|
|
340
|
-
'responses' => {
|
|
341
|
-
'200' => false,
|
|
342
|
-
},
|
|
343
|
-
},
|
|
344
|
-
},
|
|
345
|
-
}, @schema_coverage.report)
|
|
478
|
+
assert_equal({ '/threads/{id}' => { 'get' => { 'responses' => { '200' => true, }, }, }, '/posts' => { 'get' => { 'responses' => { '200' => false, '404' => false, 'default' => false, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => false, }, }, 'delete' => { 'responses' => { '200' => false, }, }, }, }, @schema_coverage.report)
|
|
346
479
|
end
|
|
347
480
|
end
|
|
348
481
|
end
|
|
@@ -22,182 +22,35 @@ describe Committee::Test::SchemaCoverage do
|
|
|
22
22
|
it 'can record and report coverage properly' do
|
|
23
23
|
@schema_coverage.update_response_coverage!('/posts', 'get', '200')
|
|
24
24
|
assert_equal(['/posts get 200',], covered_responses)
|
|
25
|
-
assert_equal([
|
|
26
|
-
'/threads/{id} get 200',
|
|
27
|
-
'/posts get 404',
|
|
28
|
-
'/posts get default',
|
|
29
|
-
'/posts post 200',
|
|
30
|
-
'/likes post 200',
|
|
31
|
-
'/likes delete 200',
|
|
32
|
-
], uncovered_responses)
|
|
25
|
+
assert_equal(['/threads/{id} get 200', '/posts get 404', '/posts get default', '/posts post 200', '/likes post 200', '/likes delete 200',], uncovered_responses)
|
|
33
26
|
|
|
34
27
|
@schema_coverage.update_response_coverage!('/likes', 'post', '200')
|
|
35
28
|
assert_equal(['/posts get 200', '/likes post 200',], covered_responses)
|
|
36
|
-
assert_equal([
|
|
37
|
-
'/threads/{id} get 200',
|
|
38
|
-
'/posts get 404',
|
|
39
|
-
'/posts get default',
|
|
40
|
-
'/posts post 200',
|
|
41
|
-
'/likes delete 200',
|
|
42
|
-
], uncovered_responses)
|
|
29
|
+
assert_equal(['/threads/{id} get 200', '/posts get 404', '/posts get default', '/posts post 200', '/likes delete 200',], uncovered_responses)
|
|
43
30
|
|
|
44
31
|
@schema_coverage.update_response_coverage!('/likes', 'delete', '200')
|
|
45
32
|
assert_equal(['/posts get 200', '/likes post 200', '/likes delete 200',], covered_responses)
|
|
46
|
-
assert_equal([
|
|
47
|
-
'/threads/{id} get 200',
|
|
48
|
-
'/posts get 404',
|
|
49
|
-
'/posts get default',
|
|
50
|
-
'/posts post 200',
|
|
51
|
-
], uncovered_responses)
|
|
33
|
+
assert_equal(['/threads/{id} get 200', '/posts get 404', '/posts get default', '/posts post 200',], uncovered_responses)
|
|
52
34
|
|
|
53
35
|
@schema_coverage.update_response_coverage!('/posts', 'get', '422')
|
|
54
|
-
assert_equal([
|
|
55
|
-
'/posts get 200',
|
|
56
|
-
'/posts get default',
|
|
57
|
-
'/likes post 200',
|
|
58
|
-
'/likes delete 200',
|
|
59
|
-
], covered_responses)
|
|
36
|
+
assert_equal(['/posts get 200', '/posts get default', '/likes post 200', '/likes delete 200',], covered_responses)
|
|
60
37
|
assert_equal(['/threads/{id} get 200', '/posts get 404', '/posts post 200',], uncovered_responses)
|
|
61
38
|
|
|
62
|
-
assert_equal({
|
|
63
|
-
'/threads/{id}' => {
|
|
64
|
-
'get' => {
|
|
65
|
-
'responses' => {
|
|
66
|
-
'200' => false,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
'/posts' => {
|
|
71
|
-
'get' => {
|
|
72
|
-
'responses' => {
|
|
73
|
-
'200' => true,
|
|
74
|
-
'404' => false,
|
|
75
|
-
'default' => true,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
'post' => {
|
|
79
|
-
'responses' => {
|
|
80
|
-
'200' => false,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
'/likes' => {
|
|
85
|
-
'post' => {
|
|
86
|
-
'responses' => {
|
|
87
|
-
'200' => true,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
'delete' => {
|
|
91
|
-
'responses' => {
|
|
92
|
-
'200' => true,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
}, @schema_coverage.report)
|
|
39
|
+
assert_equal({ '/threads/{id}' => { 'get' => { 'responses' => { '200' => false, }, }, }, '/posts' => { 'get' => { 'responses' => { '200' => true, '404' => false, 'default' => true, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => true, }, }, 'delete' => { 'responses' => { '200' => true, }, }, }, }, @schema_coverage.report)
|
|
97
40
|
|
|
98
41
|
@schema_coverage.update_response_coverage!('/posts', 'post', '200')
|
|
99
42
|
@schema_coverage.update_response_coverage!('/posts', 'get', '404')
|
|
100
43
|
@schema_coverage.update_response_coverage!('/threads/{id}', 'get', '200')
|
|
101
|
-
assert_equal([
|
|
102
|
-
'/threads/{id} get 200',
|
|
103
|
-
'/posts get 200',
|
|
104
|
-
'/posts get 404',
|
|
105
|
-
'/posts get default',
|
|
106
|
-
'/posts post 200',
|
|
107
|
-
'/likes post 200',
|
|
108
|
-
'/likes delete 200',
|
|
109
|
-
], covered_responses)
|
|
44
|
+
assert_equal(['/threads/{id} get 200', '/posts get 200', '/posts get 404', '/posts get default', '/posts post 200', '/likes post 200', '/likes delete 200',], covered_responses)
|
|
110
45
|
assert_equal([], uncovered_responses)
|
|
111
46
|
end
|
|
112
47
|
end
|
|
113
48
|
|
|
114
49
|
describe '.merge_report' do
|
|
115
50
|
it 'can merge 2 coverage reports together' do
|
|
116
|
-
report = Committee::Test::SchemaCoverage.merge_report(
|
|
117
|
-
{
|
|
118
|
-
'/posts' => {
|
|
119
|
-
'get' => {
|
|
120
|
-
'responses' => {
|
|
121
|
-
'200' => true,
|
|
122
|
-
'404' => false,
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
'post' => {
|
|
126
|
-
'responses' => {
|
|
127
|
-
'200' => false,
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
'/likes' => {
|
|
132
|
-
'post' => {
|
|
133
|
-
'responses' => {
|
|
134
|
-
'200' => true,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
'/posts' => {
|
|
141
|
-
'get' => {
|
|
142
|
-
'responses' => {
|
|
143
|
-
'200' => true,
|
|
144
|
-
'404' => true,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
'post' => {
|
|
148
|
-
'responses' => {
|
|
149
|
-
'200' => false,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
'/likes' => {
|
|
154
|
-
'post' => {
|
|
155
|
-
'responses' => {
|
|
156
|
-
'200' => false,
|
|
157
|
-
'400' => false,
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
'/users' => {
|
|
162
|
-
'get' => {
|
|
163
|
-
'responses' => {
|
|
164
|
-
'200' => true,
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
)
|
|
51
|
+
report = Committee::Test::SchemaCoverage.merge_report({ '/posts' => { 'get' => { 'responses' => { '200' => true, '404' => false, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => true, }, }, }, }, { '/posts' => { 'get' => { 'responses' => { '200' => true, '404' => true, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => false, '400' => false, }, }, }, '/users' => { 'get' => { 'responses' => { '200' => true, }, }, }, },)
|
|
170
52
|
|
|
171
|
-
assert_equal({
|
|
172
|
-
'/posts' => {
|
|
173
|
-
'get' => {
|
|
174
|
-
'responses' => {
|
|
175
|
-
'200' => true,
|
|
176
|
-
'404' => true,
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
'post' => {
|
|
180
|
-
'responses' => {
|
|
181
|
-
'200' => false,
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
'/likes' => {
|
|
186
|
-
'post' => {
|
|
187
|
-
'responses' => {
|
|
188
|
-
'200' => true,
|
|
189
|
-
'400' => false,
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
'/users' => {
|
|
194
|
-
'get' => {
|
|
195
|
-
'responses' => {
|
|
196
|
-
'200' => true,
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
}, report)
|
|
53
|
+
assert_equal({ '/posts' => { 'get' => { 'responses' => { '200' => true, '404' => true, }, }, 'post' => { 'responses' => { '200' => false, }, }, }, '/likes' => { 'post' => { 'responses' => { '200' => true, '400' => false, }, }, }, '/users' => { 'get' => { 'responses' => { '200' => true, }, }, }, }, report)
|
|
201
54
|
end
|
|
202
55
|
end
|
|
203
56
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: committee
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.6.
|
|
4
|
+
version: 5.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brandur
|
|
@@ -189,6 +189,10 @@ files:
|
|
|
189
189
|
- lib/committee/errors.rb
|
|
190
190
|
- lib/committee/middleware.rb
|
|
191
191
|
- lib/committee/middleware/base.rb
|
|
192
|
+
- lib/committee/middleware/options.rb
|
|
193
|
+
- lib/committee/middleware/options/base.rb
|
|
194
|
+
- lib/committee/middleware/options/request_validation.rb
|
|
195
|
+
- lib/committee/middleware/options/response_validation.rb
|
|
192
196
|
- lib/committee/middleware/request_validation.rb
|
|
193
197
|
- lib/committee/middleware/response_validation.rb
|
|
194
198
|
- lib/committee/middleware/stub.rb
|
|
@@ -203,10 +207,12 @@ files:
|
|
|
203
207
|
- lib/committee/schema_validator/hyper_schema/string_params_coercer.rb
|
|
204
208
|
- lib/committee/schema_validator/open_api_3.rb
|
|
205
209
|
- lib/committee/schema_validator/open_api_3/operation_wrapper.rb
|
|
210
|
+
- lib/committee/schema_validator/open_api_3/parameter_deserializer.rb
|
|
206
211
|
- lib/committee/schema_validator/open_api_3/request_validator.rb
|
|
207
212
|
- lib/committee/schema_validator/open_api_3/response_validator.rb
|
|
208
213
|
- lib/committee/schema_validator/open_api_3/router.rb
|
|
209
214
|
- lib/committee/schema_validator/option.rb
|
|
215
|
+
- lib/committee/test/except_parameter.rb
|
|
210
216
|
- lib/committee/test/methods.rb
|
|
211
217
|
- lib/committee/test/schema_coverage.rb
|
|
212
218
|
- lib/committee/utils.rb
|
|
@@ -224,6 +230,9 @@ files:
|
|
|
224
230
|
- test/drivers/open_api_3/driver_test.rb
|
|
225
231
|
- test/drivers_test.rb
|
|
226
232
|
- test/middleware/base_test.rb
|
|
233
|
+
- test/middleware/options/base_test.rb
|
|
234
|
+
- test/middleware/options/request_validation_test.rb
|
|
235
|
+
- test/middleware/options/response_validation_test.rb
|
|
227
236
|
- test/middleware/request_validation_open_api_3_test.rb
|
|
228
237
|
- test/middleware/request_validation_test.rb
|
|
229
238
|
- test/middleware/response_validation_open_api_3_test.rb
|
|
@@ -237,6 +246,7 @@ files:
|
|
|
237
246
|
- test/schema_validator/hyper_schema/router_test.rb
|
|
238
247
|
- test/schema_validator/hyper_schema/string_params_coercer_test.rb
|
|
239
248
|
- test/schema_validator/open_api_3/operation_wrapper_test.rb
|
|
249
|
+
- test/schema_validator/open_api_3/parameter_deserializer_test.rb
|
|
240
250
|
- test/schema_validator/open_api_3/request_validator_test.rb
|
|
241
251
|
- test/schema_validator/open_api_3/response_validator_test.rb
|
|
242
252
|
- test/schema_validator_test.rb
|