diff --git a/test/client.js b/test/client.js index 0fbe30c79..50c8f9b7a 100644 --- a/test/client.js +++ b/test/client.js @@ -226,4 +226,18 @@ describe('http', () => { done(err) }) }) + + it('should err gracefully when requesting https from an http server', () => { + return Swagger({ + url: 'http://localhost:8000/petstore.json', + requestInterceptor: (req) => { + const u = url.parse(req.url) + u.protocol = 'https' + req.url = u.format() + return req + } + }).catch((err) => { + expect(err.message).toEqual('request to https://localhost:8000/petstore.json failed, reason: socket hang up') + }) + }) })