From e740b7c33217f8564849c523a3607c53bab6e3a8 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 14 Mar 2023 17:20:20 +0000 Subject: Update for SNI Chcecking SNI checking is now supported in Jersey Issue-ID: POLICY-4474 Change-Id: I6afc2d577493485f151887180ef152303c456f3a Signed-off-by: liamfallon --- .../onap/policy/apex/examples/acm/AcmTestServerDmaap.java | 4 ++-- .../onap/policy/apex/examples/grpc/GrpcTestServerSim.java | 4 ++-- .../org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java | 7 ++++--- .../plugins/context/schema/avro/AvroSchemaRecordTest.java | 2 +- .../event/carrier/restrequestor/RestRequestorTest.java | 4 ++-- .../event/carrier/restserver/ApexRestServerConsumer.java | 10 ++++++++-- .../restserver/RestServerCarrierTechnologyParameters.java | 3 ++- .../uservice/adapt/restclient/TestExecutionPropertyRest.java | 4 ++-- .../integration/uservice/adapt/restclient/TestFile2Rest.java | 4 ++-- .../integration/uservice/adapt/restclient/TestRest2File.java | 4 ++-- .../uservice/taskparameters/TestTaskParameters.java | 12 +++++++----- 11 files changed, 34 insertions(+), 24 deletions(-) diff --git a/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java b/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java index 1d9d56a4a..9e8b1b71d 100644 --- a/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java +++ b/examples/examples-acm/src/main/java/org/onap/policy/apex/examples/acm/AcmTestServerDmaap.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022 Nordix Foundation. + * Copyright (C) 2022-2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ public class AcmTestServerDmaap implements AutoCloseable { */ public AcmTestServerDmaap() { restServer = HttpServletServerFactoryInstance.getServerFactory().build("AcmTestRestDmaapEndpoint", false, HOST, - restServerPort, "/", false, false); + restServerPort, false, "/", false, false); restServer.addServletClass(null, AcmTestRestDmaapEndpoint.class.getName()); restServer.setSerializationProvider(GsonMessageBodyHandler.class.getName()); restServer.start(); diff --git a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java index cd9f11c41..46e0ea254 100644 --- a/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java +++ b/examples/examples-grpc/src/test/java/org/onap/policy/apex/examples/grpc/GrpcTestServerSim.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020,2023 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +45,7 @@ public class GrpcTestServerSim { public GrpcTestServerSim() throws InterruptedException, IOException { int restServerPort = 54321; restServer = HttpServletServerFactoryInstance.getServerFactory().build("GrpcTestRestSimEndpoint", false, HOST, - restServerPort, "/GrpcTestRestSim", false, false); + restServerPort, false, "/GrpcTestRestSim", false, false); restServer.addServletClass(null, GrpcTestRestSimEndpoint.class.getName()); restServer.setSerializationProvider(GsonMessageBodyHandler.class.getName()); restServer.start(); diff --git a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java index 2a6a2e8d0..c20fd9294 100644 --- a/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java +++ b/examples/examples-onap-vcpe/src/test/java/org/onap/policy/apex/domains/onap/vcpe/OnapVCpeSim.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019,2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,8 @@ public class OnapVCpeSim { */ public OnapVCpeSim(final String[] args) throws Exception { server = HttpServletServerFactoryInstance.getServerFactory().build( - "OnapVCpeSimEndpoint", false, args[0], Integer.valueOf(args[1]).intValue(), "/OnapVCpeSim", false, false); + "OnapVCpeSimEndpoint", false, args[0], Integer.valueOf(args[1]).intValue(), false, "/OnapVCpeSim", false, + false); server.addServletClass(null, OnapVCpeSimEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -74,7 +75,7 @@ public class OnapVCpeSim { for (int index = 0; index < MAX_LOOPS; index++) { ThreadUtilities.sleep(100); } - + sim.tearDown(); } } diff --git a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java index 2977059c6..3a81584f0 100644 --- a/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java +++ b/plugins/plugins-context/plugins-context-schema/plugins-context-schema-avro/src/test/java/org/onap/policy/apex/plugins/context/schema/avro/AvroSchemaRecordTest.java @@ -147,7 +147,7 @@ public class AvroSchemaRecordTest { assertThatThrownBy(() -> subRecord0.get("address")).hasMessage("Not a valid schema field: address"); final GenericRecord subRecord1 = (GenericRecord) schemaHelper.createNewSubInstance("EmailAddress"); - assertThatThrownBy(() -> subRecord0.get("address")).hasMessage("Not a valid schema field: address"); + assertThatThrownBy(() -> subRecord1.get("EmailAddress")).hasMessage("Not a valid schema field: EmailAddress"); assertThatThrownBy(() -> schemaHelper.createNewSubInstance("IDontExist")) .hasMessage("AvroTest:0.0.1: the schema \"User\" does not have a subtype of type \"IDontExist\""); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java index 40e900413..a7795a1b1 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restrequestor/src/test/java/org/onap/policy/apex/plugins/event/carrier/restrequestor/RestRequestorTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020,2023 Nordix Foundation. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -68,7 +68,7 @@ public class RestRequestorTest { */ @BeforeClass public static void setUp() throws Exception { - server = HttpServletServerFactoryInstance.getServerFactory().build(null, false, null, PORT, + server = HttpServletServerFactoryInstance.getServerFactory().build(null, false, null, PORT, false, "/TestRESTRequestor", false, false); server.addServletClass(null, SupportRestRequestorEndpoint.class.getName()); diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java index ad3d77bf1..8ed2504d9 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020,2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -133,7 +133,13 @@ public class ApexRestServerConsumer extends ApexPluginsEventConsumer { restConsumerProperties.getName(), restConsumerProperties.isHttps(), restConsumerProperties.getHost(), - restConsumerProperties.getPort(), null, true, false); + restConsumerProperties.getPort(), + restConsumerProperties.isSniHostCheck(), + null, + true, + false + ); + if (restConsumerProperties.isAaf()) { server.addFilterClass(null, ApexRestServerAafFilter.class.getName()); } diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java index bf24d2260..a77ec17a1 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/RestServerCarrierTechnologyParameters.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019,2023 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,6 +72,7 @@ public class RestServerCarrierTechnologyParameters extends CarrierTechnologyPara private String userName; private String password; private boolean https; + private boolean sniHostCheck; private boolean aaf; // @formatter:on diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java index 8596ceec9..d1488df86 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestExecutionPropertyRest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020,2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -77,7 +77,7 @@ public class TestExecutionPropertyRest { } server = HttpServletServerFactoryInstance.getServerFactory().build("TestExecutionPropertyRest", false, null, - PORT, "/TestExecutionRest", false, false); + PORT, false, "/TestExecutionRest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java index 04a1e6faf..5683b48b2 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestFile2Rest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020,2023 Nordix Foundation. * Modifications Copyright (C) 2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,7 +75,7 @@ public class TestFile2Rest { */ @BeforeClass public static void setUp() throws Exception { - server = HttpServletServerFactoryInstance.getServerFactory().build("TestFile2Rest", false, null, PORT, + server = HttpServletServerFactoryInstance.getServerFactory().build("TestFile2Rest", false, null, PORT, false, "/TestFile2Rest", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java index 0aeb196f0..34aaab802 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/adapt/restclient/TestRest2File.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2020,2023 Nordix Foundation. * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -78,7 +78,7 @@ public class TestRest2File { */ @Before public void setUp() throws Exception { - server = HttpServletServerFactoryInstance.getServerFactory().build("TestRest2File", false, null, PORT, + server = HttpServletServerFactoryInstance.getServerFactory().build("TestRest2File", false, null, PORT, false, "/TestRest2File", false, false); server.addServletClass(null, TestRestClientEndpoint.class.getName()); diff --git a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java index 9713bcb74..655538349 100644 --- a/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java +++ b/testsuites/integration/integration-uservice-test/src/test/java/org/onap/policy/apex/testsuites/integration/uservice/taskparameters/TestTaskParameters.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2020 Nordix Foundation. + * Copyright (C) 2020,2023 Nordix Foundation. * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -56,7 +56,6 @@ public class TestTaskParameters { private static final int PORT = 32801; private static final String HOST = "localhost"; - /** * Sets up a server for testing. * @@ -68,8 +67,9 @@ public class TestTaskParameters { throw new IllegalStateException("port " + PORT + " is still in use"); } - server = HttpServletServerFactoryInstance.getServerFactory().build("TestTaskParameters", false, null, PORT, - "/TestTaskParametersRest", false, false); + server = + HttpServletServerFactoryInstance.getServerFactory().build("TestTaskParameters", false, null, PORT, false, + "/TestTaskParametersRest", false, false); server.addServletClass(null, RestClientEndpointForTaskParameters.class.getName()); server.setSerializationProvider(GsonMessageBodyHandler.class.getName()); @@ -153,7 +153,9 @@ public class TestTaskParameters { // @formatter:on new ApexCliToscaEditorMain(cliArgs); - final String[] args = {"target/classes/APEXPolicy.json"}; + final String[] args = { + "target/classes/APEXPolicy.json" + }; // clear the details set in server client.target("http://" + HOST + ":" + PORT + "/TestTaskParametersRest/apex/event/clearDetails") .request("application/json").get(); -- cgit 1.2.3-korg