vlucas / frisby

Frisby is a REST API testing framework built on Jest that makes testing API endpoints easy, fast, and fun.
http://frisbyjs.com
1.53k stars 201 forks source link

inconsistency result between postman an frisby #543

Closed amrsa1 closed 4 years ago

amrsa1 commented 4 years ago

Im trying to simulate same post call on postman on frisby but never got the expected result (302)

image

here some tries but no use frisby.globalSetup({ request: { url: 'https://example.example.com/EAI/Login', method: 'POST', // redirect: 'manual', body:{ redirect: 'https://mc.test.att.com/', reprompt: 'https://example.test.example.com/login?redirect=https://example.example.att.com/', username: 'example@example.com', password: '1234', }, headers: { origin: 'https://example.example.att.com', 'Upgrade-Insecure-Requests': 1, 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36', 'Sec-Fetch-User': '?1', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' } } });'

it('Verify login into mnc Test', () => { return frisby.post('https://cisiot.test.att.com/EAI/Login', { body: JSON.stringify({ password: '123', redirect: 'https://examplet.com/', reprompt: 'https://examplet.test.com/login?redirect=https://test.examplet.com/', username: 'examplet@examplet.com'}) }) .expect('status', 302); });

` it('2- Verify all user comapny service can be fetched', function (done) { return frisby .post('https://example.test.com/EAI/Login', { request: { method: 'POST', redirect: 'manual' }, body: { redirect: 'https://mc.example.com/', reprompt: 'https://example.test.com/login?redirect=https://mc.example.com/', username: 'example@example.com', password: '1234' } }) .expect('status', 302) .then(function (res) { frisby .get('https://exampe.test..com/mcapi/users/current', { headers: { // // "Content-Type": "application/json", // // "Accept": "application/json", // cookie: res.headers.get('set-cookie'), Origin: 'https://mc.example.com', } }) .expect('status', 200) .inspectBody(); done(); }); });

});`

amrsa1 commented 4 years ago

@vlucas

vlucas commented 4 years ago

It looks like Frisby is following redirects, so it never results in the 302 you are expecting.

amrsa1 commented 4 years ago

It looks like Frisby is following redirects, so it never results in the 302 you are expecting.

so how i can stop this redirect, i add redirect:'manual' in request and no use

Note : in postman i disabled the automatic redirect

vlucas commented 4 years ago

I will have to look into this more when I have some time. Any ideas, @H1Gdev?

H1Gdev commented 4 years ago

@Amrkamel1

Behavior may change due to differences in headers. First, please tell us raw headers of request in Postman.

amrsa1 commented 4 years ago

@Amrkamel1

Behavior may change due to differences in headers. First, please tell us raw headers of request in Postman.

yes you are right, it was two things actually stringfy the query strings save the cookies for next est by setting global variables