From f1757470df95a22dd092aad4be998aa48e82f466 Mon Sep 17 00:00:00 2001 From: Mohanachandran S Date: Mon, 1 Jul 2024 11:08:08 +0530 Subject: [PATCH 1/2] MOSIP-34152 Signed-off-by: Mohanachandran S --- .../testrig/apirig/utils/RestClient.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java index f50f4b6acc..0cc5d00f66 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java @@ -13,6 +13,7 @@ import io.mosip.testrig.apirig.testrunner.MosipTestRunner; import io.restassured.RestAssured; +import io.restassured.config.EncoderConfig; import io.restassured.config.HttpClientConfig; import io.restassured.config.RestAssuredConfig; import io.restassured.http.Cookie; @@ -1763,4 +1764,23 @@ public static Response postRequestWithQueryParamBodyAndCookie(String url, Object return postResponse; } -} + + public static byte[] postRequestWithFormDataBodyForPdf(String url, Map formData) { + byte[] pdf; + + EncoderConfig encoderConfig = new EncoderConfig().encodeContentTypeAs("application/x-www-form-urlencoded", + io.restassured.http.ContentType.URLENC); + RESTCLIENT_LOGGER.info("REST-ASSURED: Sending a POST request to " + url); + + if (ConfigManager.IsDebugEnabled()) { + pdf = given().config(config.encoderConfig(encoderConfig)).relaxedHTTPSValidation().formParams(formData) + .contentType("application/x-www-form-urlencoded").log().all().when().post(url).then().extract() + .asByteArray(); + } else { + pdf = given().config(config.encoderConfig(encoderConfig)).relaxedHTTPSValidation().formParams(formData) + .contentType("application/x-www-form-urlencoded").when().post(url).then().extract().asByteArray(); + } + + return pdf; + } +} \ No newline at end of file From 2de49c5d5b7f27f975ba323b97edf4619ef0d2bb Mon Sep 17 00:00:00 2001 From: Mohanachandran S Date: Mon, 1 Jul 2024 11:18:17 +0530 Subject: [PATCH 2/2] MOSIP-34152 Signed-off-by: Mohanachandran S --- .../src/main/java/io/mosip/testrig/apirig/utils/RestClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java index 0cc5d00f66..43f706f58c 100644 --- a/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java +++ b/apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/RestClient.java @@ -1767,6 +1767,7 @@ public static Response postRequestWithQueryParamBodyAndCookie(String url, Object public static byte[] postRequestWithFormDataBodyForPdf(String url, Map formData) { byte[] pdf; + GlobalMethods.addToServerEndPointMap(url); EncoderConfig encoderConfig = new EncoderConfig().encodeContentTypeAs("application/x-www-form-urlencoded", io.restassured.http.ContentType.URLENC);