Docker-selenium: HttpOnly cookie not being sent

Created on 5 May 2017  路  6Comments  路  Source: SeleniumHQ/docker-selenium

Not entirely sure if this is a bug or not or if I have not set something up incorrectly. Anyway, I am running standalone-chrome:3.4.0-chromium in docker. I am using Webdriver.io to run selenium tests and I have Wiremock docker container running to record and playback requests.

When a user logs in a HttpOnly cookie is set in the browser and then subsequently sent after each additional request i.e. searching, editing etc. If I do these actions through the browser manually I can see that in the Wiremock logs it is capturing this HTTPonly cookie being sent after each request post login. However, if I run a selenium test that does the exact same steps I don't see Wiremock capturing this which makes me think that there is something wrong with the browser not sending the HttpOnly cookie.

Example log from Wiremock logs (MY_TOKEN is the HttpOnly cookie):

Running through my browser:

172.17.0.1 - GET /api/example

Origin: [http://localhost:9999]
Cookie: [MY_TOKEN=somevalue;]
Accept: [*/*]
Connection: [keep-alive]
User-Agent: [Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36]
Referer: [http://localhost:9999/]
Host: [localhost:8090]
Accept-Encoding: [gzip, deflate, sdch, br]
Accept-Language: [en-GB,en-US;q=0.8,en;q=0.6]

Running through selenium:

172.17.0.10 - GET /api/example

Origin: [http://172.17.0.12:9999]
Accept: [*/*]
Connection: [keep-alive]
User-Agent: [Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36]
Referer: [http://172.17.0.12:9999/login]
Host: [172.17.0.11:8090]
Accept-Encoding: [gzip, deflate, sdch]
Accept-Language: [en-US,en;q=0.8]

Apologies if this is not the correct place to post this.

Thanks.

Most helpful comment

Thanks for your help. Discovered that it is something to do with our rest API setting the domain based on default parameters. I'll take it from there and close this as I don't believe it is an issue here.

All 6 comments

Do you also have his issue also when running selenium jar? i.e. selenium without docker?

I think it has to do with how the containers are being linked.
Are you using a docker-compose file? How do you start them?

@elgalu I haven't tried the selenium jar on it's own but I will have a go.

@diemol Not using docker-compose. We run the containers using phing to run docker run commands. As for links: I have Wiremock linked to our rest API docker and the front docker is linked to the back. Wiremock is run to proxy all requests based on the rest API container name. I have also tried removing the docker link between the API and Wiremock and using the IP of the docker container instead but it's the same result.

@elgalu I have tried with selenium jar but the same result. I think I know what the problem is. I have managed to keep the browser open long enough when running the test so that I can see the cookies and the request. When the cookie is being set it is being set for domain=localhost rather than containing the IP address of front container.

I see, thanks for trying, if it happens with selenium jar then is not a docker-selenium issue therefore doesn't belong to this repo

Perhaps you can open the issue at Selenium and reference it here to keep the discussion there.

Thanks for your help. Discovered that it is something to do with our rest API setting the domain based on default parameters. I'll take it from there and close this as I don't believe it is an issue here.

Was this page helpful?
0 / 5 - 0 ratings