Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a request header in behat tests?

I am developing a Rest API and testing it with Behat and mink-selenium2-driver (for the first time) . For security purposes, every call needs to contain a apikey in the request header.

My Problem is, i cannot set the header. My test looks like this:

Given I add "X_ApiKey" header equal to "test"
When I send a GET request to "/notice"
Then the response status code should be 200

But I keep getting a 403.

Any solutions?

like image 696
user3210460 Avatar asked Oct 31 '22 16:10

user3210460


1 Answers

In selenium it is imposible. Need to test this on other driver, like guzzle

To my knowledge, selenium driver lead chrome, but not how it is working. Proposition to check of use others drivers like guzzle, where you can set headers is a answer, in my opinion.

No i found you could additionally other option. It's recommended you use a proxy to inject additional headers to the requests generated by the browser.

To do this i found * http://wiremock.org/

like image 152
timiTao Avatar answered Jan 04 '23 15:01

timiTao