Get method of frisby does not work with https

会有一股神秘感。 提交于 2019-12-23 16:34:11

问题


I am new to frisby test. today i found I can't access https://ip address from friby api

for example:

frisby.create('my test').get("https://199.59.148.20")
output: connect error

frisby.create('my test').get("https://api.twitter.com")
this one works

please advise!


回答1:


This is beacuse the unsafe connection (non-trusted SSL certificate). If you open same URL in a browser, it will ask for confirmation before to continue with the insecure connection.

To do the same thing in frisby, add a second param to .get(...) method to specify strictSSL = false as follows:

var frisby = require('frisby');

frisby.create('Get a https resource')
      .get('https://199.59.148.20', { strictSSL: false })
      .expectStatus(200) // For this case/IP-address this fails as it returns a 404
      .inspectBody()
      .toss();



回答2:


This is due to non-trusted SSL certificate. you can include this line at the beginning of your firsby test:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"

This will direct non-rejection of SSL cert.



来源:https://stackoverflow.com/questions/32219794/get-method-of-frisby-does-not-work-with-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!