Skip to content

Commit

Permalink
LPD-41574 make tls1.0/1.1 launch exceptions and cover tls v1.3 too
Browse files Browse the repository at this point in the history
  • Loading branch information
jgarcialr authored and brianchandotcom committed Nov 13, 2024
1 parent 4aeea42 commit cfd3ba9
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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"));
Expand Down Expand Up @@ -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 {

Expand Down

0 comments on commit cfd3ba9

Please sign in to comment.