I'm trying to create mock request for integration test (@SpringBootTest).
//given
MockHttpServletRequestBuilder requestBuilder = get("/users/register/user1");
What I want to check is the remote of this request. In my controller Im getting this information from HttpServletRequest
HttpServletRequest request;
request.getRemoteHost();
request.getRemoteAddr();
Unfortunately right now getRemoteHost()
will always return localhost.
I would like to change it in my mock request to something else eg:
remoteHost:
localhost
-->mockhostdomain
remoteAddr:
127.0.0.1
-->10.32.120.7
(anything different)
I cannot find proper method for that. Is it even possible?