MKay
MKay

Reputation: 836

Connection refused in rest assured for HTTPS request

I am trying to test a REST API having an ELB similar to below: https://systemtest-inventory.com/v1/inventory/getInventory

When I tried the URL with postman chrome, it is giving me valid response. But when I try to use it in Java program as below:

RestAssured.baseURI="https://systemtest-inventory.com/";
        RestAssured.get("v1/inventory/getInventory").then().assertThat().contentType(ContentType.JSON);

It gives this error:

org.apache.http.conn.HttpHostConnectException: Connection to https://systemtest-inventory.com refused

I am aware that I am using HTTPS and need to have security certificate trusted. However, I am not sure how to do it. Is there any way in Rest assured to test with HTTPS and not HTTP.

Upvotes: 3

Views: 3342

Answers (2)

Madhusudhan R
Madhusudhan R

Reputation: 321

To ignore the HTTPS Connection you can use:

RestAssured.useRelaxedHTTPSValidation();

Upvotes: 0

Amit
Amit

Reputation: 136

You could do something as below for ignoring HTTPS Validation:

given().config(RestAssured.config().sslConfig( new SSLConfig().relaxedHTTPSValidation());

Upvotes: 1

Related Questions