From cfd3ba94d182cb94d004653fe82d3d112224b5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Garc=C3=ADa=20Jim=C3=A9nez?= Date: Tue, 12 Nov 2024 15:11:38 +0100 Subject: [PATCH] LPD-41574 make tls1.0/1.1 launch exceptions and cover tls v1.3 too --- .../JSONWebServiceClientImplSSLGetTest.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/modules/apps/portal/portal-json-web-service-client/src/test/java/com/liferay/portal/json/web/service/client/internal/JSONWebServiceClientImplSSLGetTest.java b/modules/apps/portal/portal-json-web-service-client/src/test/java/com/liferay/portal/json/web/service/client/internal/JSONWebServiceClientImplSSLGetTest.java index 7f59d29ff199e8..2001e867bbd4e4 100644 --- a/modules/apps/portal/portal-json-web-service-client/src/test/java/com/liferay/portal/json/web/service/client/internal/JSONWebServiceClientImplSSLGetTest.java +++ b/modules/apps/portal/portal-json-web-service-client/src/test/java/com/liferay/portal/json/web/service/client/internal/JSONWebServiceClientImplSSLGetTest.java @@ -30,11 +30,13 @@ public class JSONWebServiceClientImplSSLGetTest LiferayUnitTestRule.INSTANCE; @Test - public void test200OKOnGetIfTLS11() throws Exception { + public void test200OKOnGetIfTLS12() throws Exception { + System.setProperty("https.protocols", "TLSv1.2"); + JSONWebServiceClientImpl jsonWebServiceClientImpl = _createJsonWebServiceClient(); - HTTPSServerSimulator.start("TLSv1.1"); + HTTPSServerSimulator.start("TLSv1.2"); String json = jsonWebServiceClientImpl.doGet( "/testGet/", getParameters("200")); @@ -48,11 +50,13 @@ public void test200OKOnGetIfTLS11() throws Exception { } @Test - public void test200OKOnGetIfTLS12() throws Exception { + public void test200OKOnGetIfTLS13() throws Exception { + System.setProperty("https.protocols", "TLSv1.3"); + JSONWebServiceClientImpl jsonWebServiceClientImpl = _createJsonWebServiceClient(); - HTTPSServerSimulator.start("TLSv1.2"); + HTTPSServerSimulator.start("TLSv1.3"); String json = jsonWebServiceClientImpl.doGet( "/testGet/", getParameters("200")); @@ -88,6 +92,27 @@ public void testJSONWebServiceExceptionOnGetIfTLS10() throws Exception { } } + @Test(expected = JSONWebServiceException.class) + public void testJSONWebServiceExceptionOnGetIfTLS11() throws Exception { + JSONWebServiceClientImpl jsonWebServiceClientImpl = + _createJsonWebServiceClient(); + + HTTPSServerSimulator.start("TLSv1.1"); + + try { + String json = jsonWebServiceClientImpl.doGet( + "/testGet/", getParameters("200")); + + Assert.assertTrue( + json, + json.contains( + SimulatorConstants.HTTP_PARAMETER_RESPOND_WITH_STATUS)); + } + finally { + HTTPSServerSimulator.stop(); + } + } + private JSONWebServiceClientImpl _createJsonWebServiceClient() throws Exception {