Proxy Server Settings
In this lesson, we will learn how to set proxy server settings to a Rest Assured client.
We'll cover the following
What is a proxy server?
A proxy server is an intermediary server that is virtually located between the client and the server. All the service requests are sent to the actual server via proxy servers.
Adding proxy server settings
We can set proxy settings to a Rest Assured
client in the following ways:
-
Rest Assured
contains static variableproxy
which can be set with the proxy details like so:RestAssured.proxy = RestAssured.proxy.withHost("<proxy-host>").withPort(<proxy-port>)
By doing this, all the requests globally using the
Rest Assured
client, will be using the same proxy settings -
We can also set a proxy for one certain request using the following code:
RestAssured.given() .proxy("<proxy-host>", <proxy-port>) .get(...) .andReturn();
By doing this, only this particular request will have the proxy settings.
With this lesson, we conclude the REST API automation with the Rest Assured
chapter. Let’s take a quick quiz to understand how much you have learned.
Get hands-on with 1200+ tech skills courses.