getgauge / taiko

A node.js library for testing modern web applications
https://taiko.dev
MIT License
3.58k stars 453 forks source link

Request interception does not pass original request headers #2545

Open arijit91 opened 2 years ago

arijit91 commented 2 years ago

Describe the bug Request interception when headers passed as navigation options does not pass on original request headers

Server uses basic http auth and another endpoint requires Accept headers. I passed the Authorization headers for basic auth, future requests were missing the Accept header that should be set automatically by the browser

To Reproduce Created a simple HTTP server with basic auth and verify that Taiko does not receive the Accept header passed by the browser

Expected behavior Taiko should pass on original request headers in addition to the headers passed as navigation options

Versions: Taiko: 1.28

Additional context Was able to get my workflow passing with this patch in the fetch handler:

ubuntu@ip-172-31-17-108:~/relicx$ diff ts/node_modules/taiko/lib/handlers/fetchHandler.js /usr/local/lib/node_modules/taiko/lib/handlers/fetchHandler.js 44a45,48

options.headers = {} for (const headerName in p.request.headers) { options.headers[headerName] = p.request.headers[headerName]; } 47d50 < options.headers = options.headers || {};

Can send a fix for this if this is not the intended behaviour

zabil commented 2 years ago

The patch to pass original parameters makes sense. Please feel free to raise a pull request (and a test to cover this scenario)

florarao2022 commented 1 year ago

@arijit91 could you raise a pr to fix this issue?