jhthorsen / json-validator

:cop: Validate data against a JSON schema
https://metacpan.org/release/JSON-Validator
56 stars 57 forks source link

t/load-from-app.t fails with restrictive firewall #265

Closed dboehmer closed 2 years ago

dboehmer commented 2 years ago

At my current client there’s a restrictive firewall which can be bypassed by using a HTTP+HTTPS proxy. The proxy URL is provided by the usual environment vars but not honored and this makes the test fail.

Steps to reproduce the behavior

cpanm -v JSON::Validator

Expected behavior

Test passes or is skipped even without direct HTTP connections to the Internet.

Actual behavior

t/load-from-app.t ...................... 1/? 
#   Failed test 'loaded schema from app'
#   at t/load-from-app.t line 22.
#          got: 'GET /spec: Forbidden at /private/var/root/.cpan/build/JSON-Validator-5.03-0/blib/lib/JSON/Validator/Store.pm line 127.
# '
#     expected: ''

#   Failed test 'loaded schema structure'
#   at t/load-from-app.t line 23.
#          got: undef
#     expected: '2.0'

#   Failed test 'schemas in store'
#   at t/load-from-app.t line 25.
#     Structures begin differing at:
#          $got->[0] = 'urn:uuid:7897d6c0-e5fb-57fb-81e3-cdf28a438c70'
#     $expected->[0] = '/spec'
GET /spec: Forbidden at /private/var/root/.cpan/build/JSON-Validator-5.03-0/blib/lib/JSON/Validator/Store.pm line 127.

The exception should be handled at https://github.com/jhthorsen/json-validator/blob/f3263540c8b472d082f9a3f98f59160bc59f7896/t/load-from-app.t#L19

I don’t know which error messages lead to this code but going from our error message the regex is wrong.

My ideas how to solve this:

jhthorsen commented 2 years ago

I just changed it to /\bGET\b/i. Hope that fixes the issue 👍

dboehmer commented 2 years ago

Fix confirmed. :+1: Thanks!