Hello,
I have the following situation:
I construct a request using the following code:
1. the properties are set in rest-assured statically
RestAssured.port = Integer.parseInt(property.getProperty("appPort"));
RestAssured.baseURI = property.getProperty("appBaseURI");
RestAssured.basePath = property.getProperty("appBasePath");
2. the request is made as follows:
given().filter(new CustomRequestFilter())
.contentType(ContentType.JSON)
.body(json)
.post("/groups");
3. The filter is:
public class CustomRequestFilter implements Filter{
public static Map<String, String> loginCookies;
@Override
public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) {
if(loginCookies!= null){
requestSpec.baseUri(httpsUri)
.port(443)
.cookies(loginCookies)
.redirects().follow(true)
.config(config().sslConfig(new SSLConfig().relaxedHTTPSValidation()));
}
return ctx.next(requestSpec, responseSpec);
}
}
Running the above scenario doesn't change the URI and port even if the loginCookies are not null. The cookies are put in the request and all the remaining config, like redirect and sslConfig.
What can I do to be able to change the static URI and port in the filter?