From 7cf00931901b54b916a9e25f957bf7904aa9b068 Mon Sep 17 00:00:00 2001 From: "a.sreekumar" Date: Tue, 3 Sep 2019 14:44:15 +0000 Subject: Enable https support in ApexRestServer Enable https support in ApexRestServer by using the RestServer from policy-common Change-Id: I3dc8d88a499dfa9f0a82585a083526e236420c6e Issue-ID: POLICY-2016 Signed-off-by: a.sreekumar --- .../restserver/ApexRestServerConsumerTest.java | 2 +- .../RestServerCarrierTechnologyParametersTest.java | 61 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test') diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java index 02daed02e..07f705cc6 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java @@ -93,7 +93,7 @@ public class ApexRestServerConsumerTest { incomingEventReceiver); } - @Test(expected = IllegalStateException.class) + @Test(expected = IllegalArgumentException.class) public void testInitWithSynchronousModeAndProperValues() throws ApexEventException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java index dbe20c960..2c8a764e8 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParametersTest.java @@ -86,4 +86,65 @@ public class RestServerCarrierTechnologyParametersTest { assertFalse(result.isValid()); } + @Test + public void testValidateWithValidValues() throws NoSuchFieldException, SecurityException, + IllegalArgumentException, IllegalAccessException { + + Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, true); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, "localhost"); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("port"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, 6969); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("userName"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, "username"); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("password"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, "password"); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("https"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, true); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("aaf"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, true); + result = restServerCarrierTechnologyParameters.validate(); + assertNotNull(result); + assertTrue(result.isValid()); + } + + @Test + public void testValidateWithInvalidValues() throws NoSuchFieldException, SecurityException, + IllegalArgumentException, IllegalAccessException { + + Field field = RestServerCarrierTechnologyParameters.class.getDeclaredField("standalone"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, false); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("host"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, "localhost"); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("port"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, 6969); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("userName"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, "username"); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("password"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, "password"); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("https"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, true); + field = RestServerCarrierTechnologyParameters.class.getDeclaredField("aaf"); + field.setAccessible(true); + field.set(restServerCarrierTechnologyParameters, true); + result = restServerCarrierTechnologyParameters.validate(); + assertNotNull(result); + assertFalse(result.isValid()); + assertTrue(result.getResult().contains("host is specified only in standalone mode")); + assertTrue(result.getResult().contains("port is specified only in standalone mode")); + } } -- cgit 1.2.3-korg