From cfa48db5d059b891aa53cb52e512504860863bed Mon Sep 17 00:00:00 2001 From: Bartosz Gardziejewski Date: Wed, 8 Apr 2020 09:47:06 +0200 Subject: Remove old PNF simulator Issue-ID: INT-1517 Signed-off-by: Bartosz Gardziejewski Change-Id: I235b0fdf12b265a256c371126e218826e74a9133 --- test/mocks/pnfsimulator/.gitignore | 3 - .../mocks/pnfsimulator/checkstyle-suppressions.xml | 46 --- test/mocks/pnfsimulator/deployment/assembly.xml | 35 -- test/mocks/pnfsimulator/deployment/pom.xml | 52 --- .../pnfsimulator/deployment/src/MANIFEST.json | 17 - .../deployment/src/simulators_heat_template.env | 10 - .../deployment/src/simulators_heat_template.yaml | 147 -------- .../pnfsimulator/netconfsimulator/Dockerfile_app | 4 - .../netconfsimulator/Dockerfile_netopeer | 6 - test/mocks/pnfsimulator/netconfsimulator/README.md | 297 ---------------- test/mocks/pnfsimulator/netconfsimulator/apt.conf | 5 - .../netconfsimulator/config/netconf.env | 5 - .../netconfsimulator/docker-compose.yml | 93 ----- .../netconfsimulator/docker/Dockerfile | 4 - .../netconfsimulator/ftpes/files/ftpes-noone.txt | 0 .../ftpes/files/onap/ftpes-onap.txt | 0 .../netconfsimulator/ftpes/tls/pure-ftpd.pem | 49 --- .../ftpes/userpass/pureftpd.passwd | 1 - .../netconfsimulator/netconf/__init__.py | 19 -- .../netconf/initialize_netopeer.sh | 37 -- .../netconfsimulator/netconf/load_server_certs.xml | 44 --- .../netconf/netopeer_change_saver.py | 107 ------ .../netconfsimulator/netconf/newmodel.xml | 24 -- .../netconfsimulator/netconf/newmodel.yang | 9 - .../netconf/pnf-simulator.data.xml | 24 -- .../netconfsimulator/netconf/pnf-simulator.yang | 9 - .../netconfsimulator/netconf/set-up-xmls.py | 162 --------- .../netconf/test_yang_loader_server.py | 121 ------- .../netconfsimulator/netconf/tls_listen.xml | 49 --- .../netconfsimulator/netconf/yang_loader_server.py | 172 ---------- test/mocks/pnfsimulator/netconfsimulator/pom.xml | 285 ---------------- .../org/onap/netconfsimulator/Configuration.java | 34 -- .../main/java/org/onap/netconfsimulator/Main.java | 31 -- .../org/onap/netconfsimulator/SwaggerConfig.java | 43 --- .../org/onap/netconfsimulator/kafka/Config.java | 70 ---- .../onap/netconfsimulator/kafka/MessageDTO.java | 31 -- .../netconfsimulator/kafka/StoreController.java | 59 ---- .../onap/netconfsimulator/kafka/StoreService.java | 91 ----- .../kafka/listener/KafkaListenerEntry.java | 36 -- .../kafka/listener/KafkaListenerHandler.java | 67 ---- .../netconfsimulator/kafka/model/KafkaMessage.java | 37 -- .../netconfcore/NetconfController.java | 111 ------ .../configuration/NetconfBeanConfiguration.java | 60 ---- .../configuration/NetconfConfigurationEditor.java | 50 --- .../configuration/NetconfConfigurationReader.java | 57 ---- .../configuration/NetconfConfigurationService.java | 76 ----- .../configuration/NetconfConfigurationTO.java | 32 -- .../configuration/NetconfConnectionParams.java | 37 -- .../configuration/NetconfSessionHelper.java | 37 -- .../netconfcore/model/LoadModelResponse.java | 40 --- .../model/NetconfModelLoaderService.java | 104 ------ .../netconfsimulator/websocket/EndpointConfig.java | 46 --- .../websocket/NetconfEndpoint.java | 95 ------ .../websocket/message/NetconfMessageEncoder.java | 34 -- .../websocket/message/NetconfMessageListener.java | 51 --- .../src/main/resources/application.properties | 8 - .../test/java/integration/NetconfFunctionsIT.java | 211 ------------ .../java/integration/NetconfSimulatorClient.java | 150 --------- .../kafka/EmbeddedKafkaConfig.java | 69 ---- .../kafka/StoreControllerTest.java | 86 ----- .../netconfsimulator/kafka/StoreServiceTest.java | 103 ------ .../kafka/listener/KafkaListenerHandlerTest.java | 87 ----- .../netconfcore/NetconfControllerTest.java | 172 ---------- .../NetconfConfigurationEditorTest.java | 69 ---- .../NetconfConfigurationReaderTest.java | 94 ------ .../NetconfConfigurationServiceTest.java | 102 ------ .../model/NetconfModelLoaderServiceTest.java | 121 ------- .../websocket/NetconfEndpointTest.java | 135 -------- .../message/NetconfMessageListenerTest.java | 73 ---- .../src/test/resources/application-it.properties | 0 .../src/test/resources/initialConfig.xml | 23 -- .../src/test/resources/invalidXmlFile.xml | 23 -- .../src/test/resources/newYangModel.yang | 8 - .../src/test/resources/updatedConfig.xml | 24 -- .../test/resources/updatedConfigForCmHistory.xml | 24 -- .../netconfsimulator/ssh/ssh_host_rsa_key | 49 --- .../netconfsimulator/ssh/ssh_host_rsa_key.pub | 1 - .../mocks/pnfsimulator/netconfsimulator/tls/ca.crt | 32 -- .../mocks/pnfsimulator/netconfsimulator/tls/ca.key | 54 --- .../pnfsimulator/netconfsimulator/tls/client.crt | 30 -- .../pnfsimulator/netconfsimulator/tls/client.key | 51 --- .../pnfsimulator/netconfsimulator/tls/client.req | 28 -- .../pnfsimulator/netconfsimulator/tls/server.req | 28 -- .../netconfsimulator/tls/server_cert.crt | 30 -- .../netconfsimulator/tls/server_key.pem | 51 --- test/mocks/pnfsimulator/pnfsimulator/.gitignore | 4 - test/mocks/pnfsimulator/pnfsimulator/Dockerfile | 8 - test/mocks/pnfsimulator/pnfsimulator/README.md | 333 ------------------ .../pnfsimulator/certificates/AAF_RootCA.crt | 31 -- .../pnfsimulator/certificates/dcaelocal.crt | 20 -- .../pnfsimulator/pnfsimulator/config/config.json | 9 - .../pnfsimulator/pnfsimulator/db/pnf_simulator.js | 28 -- .../deployment/PnP_PNF_sim_heat_template.yml | 118 ------- .../pnfsimulator/pnfsimulator/docker-compose.yml | 38 --- .../pnfsimulator/pnfsimulator/integration/pom.xml | 130 ------- .../org/onap/pnfsimulator/integration/Main.java | 35 -- .../integration/VesSimulatorController.java | 59 ---- .../integration/VesSimulatorService.java | 36 -- .../src/main/resources/application.properties | 1 - .../integration/src/main/resources/keystore | Bin 2196 -> 0 bytes .../integration/BasicAvailabilityTest.java | 235 ------------- .../integration/OptionalTemplatesTest.java | 204 ----------- .../integration/SearchInTemplatesTest.java | 269 --------------- .../integration/TemplatesManagementTest.java | 175 ---------- .../integration/TestConfiguration.java | 36 -- .../integration/suites/DockerBasedTestsSuite.java | 46 --- .../src/test/resources/application.properties | 6 - .../src/test/resources/templates/notification.json | 45 --- .../resources/templates/overwrite_template.json | 6 - .../resources/templates/overwritten_template.json | 6 - .../src/test/resources/templates/registration.json | 36 -- .../templates/search/complicated_template.json | 43 --- .../templates/search/simple_template.json | 12 - .../templates/search/template_with_array.json | 23 -- .../templates/search/template_with_booleans.json | 12 - .../templates/search/template_with_floats.json | 13 - .../templates/search/template_with_ints.json | 12 - .../test/resources/templates/upload_template.json | 6 - test/mocks/pnfsimulator/pnfsimulator/pom.xml | 371 -------------------- .../pnfsimulator/src/assembly/resources.xml | 57 ---- .../src/main/java/org/onap/pnfsimulator/Main.java | 57 ---- .../java/org/onap/pnfsimulator/SwaggerConfig.java | 46 --- .../main/java/org/onap/pnfsimulator/db/Row.java | 34 -- .../java/org/onap/pnfsimulator/db/Storage.java | 41 --- .../org/onap/pnfsimulator/event/EventData.java | 76 ----- .../pnfsimulator/event/EventDataRepository.java | 26 -- .../onap/pnfsimulator/event/EventDataService.java | 63 ---- .../pnfsimulator/filesystem/WatcherConfig.java | 39 --- .../filesystem/WatcherEventProcessor.java | 110 ------ .../pnfsimulator/filesystem/WatcherService.java | 44 --- .../pnfsimulator/filesystem/WatcherThread.java | 81 ----- .../onap/pnfsimulator/logging/MDCVariables.java | 35 -- .../pnfsimulator/rest/SimulatorController.java | 219 ------------ .../onap/pnfsimulator/rest/TemplateController.java | 105 ------ .../onap/pnfsimulator/rest/model/FullEvent.java | 48 --- .../onap/pnfsimulator/rest/model/SearchExp.java | 42 --- .../pnfsimulator/rest/model/SimulatorParams.java | 46 --- .../pnfsimulator/rest/model/SimulatorRequest.java | 51 --- .../pnfsimulator/rest/model/TemplateRequest.java | 42 --- .../org/onap/pnfsimulator/rest/util/DateUtil.java | 35 -- .../rest/util/JsonObjectDeserializer.java | 42 --- .../pnfsimulator/rest/util/ResponseBuilder.java | 62 ---- .../pnfsimulator/simulator/DBTemplateReader.java | 49 --- .../simulator/EventNotFoundException.java | 28 -- .../simulator/FilesystemTemplateReader.java | 54 --- .../pnfsimulator/simulator/IncrementProvider.java | 26 -- .../simulator/IncrementProviderImpl.java | 47 --- .../pnfsimulator/simulator/JsonTokenProcessor.java | 134 -------- .../pnfsimulator/simulator/KeywordsExtractor.java | 118 ------- .../pnfsimulator/simulator/KeywordsHandler.java | 72 ---- .../simulator/KeywordsValueProvider.java | 80 ----- .../pnfsimulator/simulator/SimulatorService.java | 121 ------- .../pnfsimulator/simulator/TemplatePatcher.java | 53 --- .../pnfsimulator/simulator/TemplateReader.java | 28 -- .../simulator/client/HttpClientAdapter.java | 26 -- .../simulator/client/HttpClientAdapterImpl.java | 104 ------ .../client/utils/ssl/SSLAuthenticationHelper.java | 79 ----- .../client/utils/ssl/SslSupportLevel.java | 120 ------- .../pnfsimulator/simulator/keywords/Keyword.java | 74 ---- .../simulator/keywords/NonParameterKeyword.java | 65 ---- .../simulator/keywords/SingleParameterKeyword.java | 73 ---- .../simulator/keywords/TwoParameterKeyword.java | 80 ----- .../pnfsimulator/simulator/scheduler/EventJob.java | 93 ----- .../simulator/scheduler/EventScheduler.java | 121 ------- .../simulator/scheduler/QuartzConfiguration.java | 38 --- .../simulatorconfig/SimulatorConfig.java | 49 --- .../simulatorconfig/SimulatorConfigRepository.java | 26 -- .../simulatorconfig/SimulatorConfigService.java | 52 --- .../template/FsToDbTemplateSynchronizer.java | 74 ---- .../org/onap/pnfsimulator/template/Template.java | 92 ----- .../pnfsimulator/template/TemplateRepository.java | 26 -- .../pnfsimulator/template/TemplateService.java | 81 ----- .../template/search/IllegalJsonValueException.java | 28 -- .../pnfsimulator/template/search/JsonUtils.java | 104 ------ .../template/search/TemplateSearchHelper.java | 95 ------ .../handler/PrimitiveValueCriteriaBuilder.java | 103 ------ .../search/viewmodel/FlatTemplateContent.java | 45 --- .../template/search/viewmodel/KeyValuePair.java | 40 --- .../src/main/resources/application.properties | 18 - .../pnfsimulator/src/main/resources/logback.xml | 70 ---- .../pnfsimulator/event/EventDataServiceTest.java | 133 -------- .../filesystem/InMemoryTemplateStorage.java | 71 ---- .../filesystem/WatcherEventProcessorTest.java | 124 ------- .../pnfsimulator/rest/SimulatorControllerTest.java | 212 ------------ .../pnfsimulator/rest/TemplateControllerTest.java | 256 -------------- .../onap/pnfsimulator/rest/util/DateUtilTest.java | 38 --- .../rest/util/ResponseBuilderTest.java | 65 ---- .../simulator/IncrementProviderImplTest.java | 78 ----- .../KeywordsExtractorInvalidRandomIntegerTest.java | 67 ---- .../KeywordsExtractorInvalidRandomStringTest.java | 67 ---- .../KeywordsExtractorInvalidTimestampTest.java | 65 ---- .../KeywordsExtractorValidRandomIntegerTest.java | 66 ---- ...dsExtractorValidRandomPrimitiveIntegerTest.java | 66 ---- .../KeywordsExtractorValidRandomStringTest.java | 69 ---- ...ywordsExtractorValidTimestampPrimitiveTest.java | 66 ---- .../KeywordsExtractorValidTimestampTest.java | 67 ---- .../simulator/KeywordsHandlerTest.java | 304 ----------------- .../simulator/KeywordsValueProviderTest.java | 81 ----- .../simulator/SimulatorServiceTest.java | 227 ------------- .../simulator/TemplatePatcherTest.java | 164 --------- .../pnfsimulator/simulator/TemplateReaderTest.java | 51 --- .../client/HttpClientAdapterImplTest.java | 99 ------ .../client/utils/ssl/SslSupportLevelTest.java | 52 --- .../simulator/scheduler/EventJobTest.java | 90 ----- .../simulator/scheduler/EventSchedulerTest.java | 149 -------- .../SimulatorConfigServiceTest.java | 104 ------ .../pnfsimulator/template/TemplateServiceTest.java | 152 --------- .../template/search/JsonUtilsTest.java | 166 --------- .../template/search/TemplateSearchHelperTest.java | 160 --------- .../handler/PrimitiveValueCriteriaBuilderTest.java | 75 ----- .../src/test/resources/application.properties | 2 - .../pnfsimulator/src/test/resources/client.p12 | Bin 2685 -> 0 bytes .../src/test/resources/logback-test.xml | 69 ---- .../pnfsimulator/simulator/filesystem/test1.json | 12 - .../simulator/invalidJsonStructureEvent.json | 1 - .../simulator/validExampleMeasurementEvent.json | 89 ----- .../pnfsimulator/src/test/resources/trustStore | Bin 1455 -> 0 bytes .../pnfsimulator/pnfsimulator/store/client.p12 | Bin 2685 -> 0 bytes .../pnfsimulator/pnfsimulator/store/trustStore | Bin 1455 -> 0 bytes .../pnfsimulator/templates/measurement.json | 44 --- .../pnfsimulator/templates/notification.json | 42 --- .../pnfsimulator/templates/registration.json | 33 -- test/mocks/pnfsimulator/pom.xml | 77 ----- test/mocks/pnfsimulator/simulator-cli/.gitignore | 7 - test/mocks/pnfsimulator/simulator-cli/README.md | 304 ----------------- .../pnfsimulator/simulator-cli/cli/__init__.py | 19 -- .../simulator-cli/cli/client/__init__.py | 19 -- .../simulator-cli/cli/client/tailf_client.py | 59 ---- .../simulator-cli/cli/data/logging.ini | 20 -- .../simulator-cli/cli/netconf_simulator.py | 278 --------------- .../simulator-cli/cli/pnf_simulator.py | 374 --------------------- .../pnfsimulator/simulator-cli/requirements.txt | 23 -- test/mocks/pnfsimulator/simulator-cli/setup.py | 34 -- .../pnfsimulator/simulator-cli/tests/__init__.py | 19 -- .../tests/resources/notification.json | 17 - .../simulator-cli/tests/test_netconf_simulator.py | 165 --------- .../simulator-cli/tests/test_pnf_simulator.py | 270 --------------- .../simulator-cli/tests/test_tailf_client.py | 47 --- 238 files changed, 16902 deletions(-) delete mode 100644 test/mocks/pnfsimulator/.gitignore delete mode 100644 test/mocks/pnfsimulator/checkstyle-suppressions.xml delete mode 100644 test/mocks/pnfsimulator/deployment/assembly.xml delete mode 100644 test/mocks/pnfsimulator/deployment/pom.xml delete mode 100644 test/mocks/pnfsimulator/deployment/src/MANIFEST.json delete mode 100644 test/mocks/pnfsimulator/deployment/src/simulators_heat_template.env delete mode 100644 test/mocks/pnfsimulator/deployment/src/simulators_heat_template.yaml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/Dockerfile_app delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/Dockerfile_netopeer delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/README.md delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/apt.conf delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/config/netconf.env delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/docker-compose.yml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/docker/Dockerfile delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/ftpes/files/ftpes-noone.txt delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/ftpes/files/onap/ftpes-onap.txt delete mode 100755 test/mocks/pnfsimulator/netconfsimulator/ftpes/tls/pure-ftpd.pem delete mode 100755 test/mocks/pnfsimulator/netconfsimulator/ftpes/userpass/pureftpd.passwd delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/__init__.py delete mode 100755 test/mocks/pnfsimulator/netconfsimulator/netconf/initialize_netopeer.sh delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/load_server_certs.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/netopeer_change_saver.py delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.yang delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.data.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.yang delete mode 100755 test/mocks/pnfsimulator/netconfsimulator/netconf/set-up-xmls.py delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/test_yang_loader_server.py delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/tls_listen.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/netconf/yang_loader_server.py delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/pom.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Configuration.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Main.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/SwaggerConfig.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/Config.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/MessageDTO.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreController.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreService.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerEntry.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandler.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/model/KafkaMessage.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/NetconfController.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/LoadModelResponse.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderService.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/EndpointConfig.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/NetconfEndpoint.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageEncoder.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListener.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/main/resources/application.properties delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfFunctionsIT.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfSimulatorClient.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/EmbeddedKafkaConfig.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreControllerTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreServiceTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandlerTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/NetconfControllerTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditorTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReaderTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationServiceTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderServiceTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/NetconfEndpointTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListenerTest.java delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/resources/application-it.properties delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/resources/initialConfig.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/resources/invalidXmlFile.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/resources/newYangModel.yang delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfig.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfigForCmHistory.xml delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key.pub delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/ca.crt delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/ca.key delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/client.crt delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/client.key delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/client.req delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/server.req delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/server_cert.crt delete mode 100644 test/mocks/pnfsimulator/netconfsimulator/tls/server_key.pem delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/.gitignore delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/Dockerfile delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/README.md delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/certificates/AAF_RootCA.crt delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/certificates/dcaelocal.crt delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/config/config.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/db/pnf_simulator.js delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/deployment/PnP_PNF_sim_heat_template.yml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/docker-compose.yml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/pom.xml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/Main.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorController.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorService.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/application.properties delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/keystore delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/BasicAvailabilityTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/OptionalTemplatesTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/SearchInTemplatesTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TemplatesManagementTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TestConfiguration.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/suites/DockerBasedTestsSuite.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/application.properties delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/notification.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwrite_template.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwritten_template.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/registration.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/complicated_template.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/simple_template.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_array.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_booleans.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_floats.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_ints.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/upload_template.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/pom.xml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/assembly/resources.xml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Storage.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventData.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataRepository.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherConfig.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessor.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherService.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherThread.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/logging/MDCVariables.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/SimulatorController.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/TemplateController.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/model/FullEvent.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/model/SearchExp.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/model/SimulatorParams.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/model/SimulatorRequest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/model/TemplateRequest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/DateUtil.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/JsonObjectDeserializer.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/rest/util/ResponseBuilder.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/DBTemplateReader.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/EventNotFoundException.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/FilesystemTemplateReader.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProvider.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/IncrementProviderImpl.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/JsonTokenProcessor.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsExtractor.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsHandler.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/KeywordsValueProvider.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/SimulatorService.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/TemplatePatcher.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/TemplateReader.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapter.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImpl.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SSLAuthenticationHelper.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevel.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/Keyword.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/NonParameterKeyword.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/SingleParameterKeyword.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/keywords/TwoParameterKeyword.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventJob.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/EventScheduler.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulator/scheduler/QuartzConfiguration.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulatorconfig/SimulatorConfig.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulatorconfig/SimulatorConfigRepository.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/simulatorconfig/SimulatorConfigService.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/FsToDbTemplateSynchronizer.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/Template.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/TemplateRepository.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/TemplateService.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/IllegalJsonValueException.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/JsonUtils.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/TemplateSearchHelper.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/handler/PrimitiveValueCriteriaBuilder.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/FlatTemplateContent.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/template/search/viewmodel/KeyValuePair.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/resources/application.properties delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/main/resources/logback.xml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/event/EventDataServiceTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/InMemoryTemplateStorage.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessorTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/SimulatorControllerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/TemplateControllerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/DateUtilTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/rest/util/ResponseBuilderTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/IncrementProviderImplTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorInvalidRandomIntegerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorInvalidRandomStringTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorInvalidTimestampTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorValidRandomIntegerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorValidRandomPrimitiveIntegerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorValidRandomStringTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorValidTimestampPrimitiveTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsExtractorValidTimestampTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsHandlerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/KeywordsValueProviderTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/SimulatorServiceTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TemplatePatcherTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/TemplateReaderTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/HttpClientAdapterImplTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/client/utils/ssl/SslSupportLevelTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/scheduler/EventJobTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulator/scheduler/EventSchedulerTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/simulatorconfig/SimulatorConfigServiceTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/template/TemplateServiceTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/template/search/JsonUtilsTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/template/search/TemplateSearchHelperTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/java/org/onap/pnfsimulator/template/search/handler/PrimitiveValueCriteriaBuilderTest.java delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/application.properties delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/client.p12 delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/logback-test.xml delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/filesystem/test1.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/invalidJsonStructureEvent.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/org/onap/pnfsimulator/simulator/validExampleMeasurementEvent.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/src/test/resources/trustStore delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/store/client.p12 delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/store/trustStore delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/templates/measurement.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/templates/notification.json delete mode 100644 test/mocks/pnfsimulator/pnfsimulator/templates/registration.json delete mode 100644 test/mocks/pnfsimulator/pom.xml delete mode 100644 test/mocks/pnfsimulator/simulator-cli/.gitignore delete mode 100644 test/mocks/pnfsimulator/simulator-cli/README.md delete mode 100644 test/mocks/pnfsimulator/simulator-cli/cli/__init__.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/cli/client/__init__.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/cli/client/tailf_client.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/cli/data/logging.ini delete mode 100755 test/mocks/pnfsimulator/simulator-cli/cli/netconf_simulator.py delete mode 100755 test/mocks/pnfsimulator/simulator-cli/cli/pnf_simulator.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/requirements.txt delete mode 100644 test/mocks/pnfsimulator/simulator-cli/setup.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/tests/__init__.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/tests/resources/notification.json delete mode 100644 test/mocks/pnfsimulator/simulator-cli/tests/test_netconf_simulator.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/tests/test_pnf_simulator.py delete mode 100644 test/mocks/pnfsimulator/simulator-cli/tests/test_tailf_client.py (limited to 'test/mocks') diff --git a/test/mocks/pnfsimulator/.gitignore b/test/mocks/pnfsimulator/.gitignore deleted file mode 100644 index daf6cf225..000000000 --- a/test/mocks/pnfsimulator/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -**/*.iml -**/.idea -**/target \ No newline at end of file diff --git a/test/mocks/pnfsimulator/checkstyle-suppressions.xml b/test/mocks/pnfsimulator/checkstyle-suppressions.xml deleted file mode 100644 index 8d9560789..000000000 --- a/test/mocks/pnfsimulator/checkstyle-suppressions.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/test/mocks/pnfsimulator/deployment/assembly.xml b/test/mocks/pnfsimulator/deployment/assembly.xml deleted file mode 100644 index a0609efd3..000000000 --- a/test/mocks/pnfsimulator/deployment/assembly.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - resources - false - - zip - - - - - src - . - - - \ No newline at end of file diff --git a/test/mocks/pnfsimulator/deployment/pom.xml b/test/mocks/pnfsimulator/deployment/pom.xml deleted file mode 100644 index 25fe08b49..000000000 --- a/test/mocks/pnfsimulator/deployment/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - 4.0.0 - - - org.onap.simulator - simulator-parent - 5.0.0-SNAPSHOT - - onboarding-package - - - - org.apache.maven.plugins - maven-assembly-plugin - - assembly.xml - pnf-pnp-simulators - . - - - - package - - single - - - - - - - diff --git a/test/mocks/pnfsimulator/deployment/src/MANIFEST.json b/test/mocks/pnfsimulator/deployment/src/MANIFEST.json deleted file mode 100644 index 1065b6eb0..000000000 --- a/test/mocks/pnfsimulator/deployment/src/MANIFEST.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "", - "description": "", - "data": [ - { - "file": "simulators_heat_template.yaml", - "type": "HEAT", - "isBase": "true", - "data": [ - { - "file": "simulators_heat_template.env", - "type": "HEAT_ENV" - } - ] - } - ] -} diff --git a/test/mocks/pnfsimulator/deployment/src/simulators_heat_template.env b/test/mocks/pnfsimulator/deployment/src/simulators_heat_template.env deleted file mode 100644 index cf2db52bf..000000000 --- a/test/mocks/pnfsimulator/deployment/src/simulators_heat_template.env +++ /dev/null @@ -1,10 +0,0 @@ -parameters: - image_name: ubuntu-14-04-cloud-amd64 - flavor_name: m1.medium - public_net_id: 41eae12a-27f7-4ace-9fda-3cd55c7c0651 - private_net_id: 41eae12a-27f7-4ace-9fda-3cd55c7c0651 - private_subnet_id: 41eae12a-27f7-4ace-9fda-3cd55c7c0651 - proxy: http://10.10.10.10:8080 - vnf_id: simulators_vnf - vf_module_id: simulators_vsp - key_name: onap-dev \ No newline at end of file diff --git a/test/mocks/pnfsimulator/deployment/src/simulators_heat_template.yaml b/test/mocks/pnfsimulator/deployment/src/simulators_heat_template.yaml deleted file mode 100644 index 253fcc735..000000000 --- a/test/mocks/pnfsimulator/deployment/src/simulators_heat_template.yaml +++ /dev/null @@ -1,147 +0,0 @@ -description: Heat template that deploys PnP PNF simulators -heat_template_version: '2013-05-23' -parameters: - flavor_name: {description: Type of instance (flavor) to be used, label: Flavor, - type: string} - image_name: {description: Image to be used for compute instance, label: Image name - or ID, type: string} - key_name: {description: Public/Private key pair name, label: Key pair name, type: string} - public_net_id: {description: Public network that enables remote connection to VNF, - label: Public network name or ID, type: string} - private_net_id: {type: string, description: Private network id, label: Private network name or ID} - private_subnet_id: {type: string, description: Private subnet id, label: Private subnetwork name or ID} - proxy: {type: string, description: Proxy, label: Proxy, default: ""} - vnf_id: {type: string, label: VNF ID, description: The VNF ID is provided by ONAP} - vf_module_id: {type: string, label: vBase module ID, description: The vBase Module ID is provided by ONAP} -resources: - PNF_PnP_simulator: - type: OS::Nova::Server - properties: - key_name: { get_param: key_name } - image: { get_param: image_name } - flavor: { get_param: flavor_name } - networks: - - port: { get_resource: PNF_PnP_simulator_port0 } - user_data_format: RAW - user_data: - str_replace: - template: | - #!/bin/bash - - set_versions () { - DOCKER_VERSION=17.03 - DOCKER_COMPOSE_VERSION=1.22.0 - } - - set_proxy () { - HTTP_PROXY=$proxy - HTTPS_PROXY=$proxy - http_proxy=$proxy - https_proxy=$proxy - export HTTP_PROXY=$proxy - export HTTPS_PROXY=$proxy - export http_proxy=$proxy - export https_proxy=$proxy - } - - enable_root_ssh () { - sed -i 's/PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config - sed -i 's/PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config - service sshd restart - echo -e "arthur\narthur" | passwd root - } - - update_os () { - rm -rf /var/lib/apt/lists/* - apt-get clean - apt-get update - } - - set_apt_get_proxy () { - cat > /etc/apt/apt.conf.d/proxy.conf << EOF - Acquire { - HTTP::proxy "$proxy"; - HTTPS::proxy "$proxy"; - } - EOF - } - - docker_remove () { - dnf -y remove docker \ - docker-client \ - docker-client-latest \ - docker-common \ - docker-latest \ - docker-latest-logrotate \ - docker-logrotate \ - docker-selinux \ - docker-engine-selinux \ - docker-engine - } - - docker_install_and_configure () { - curl "https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh" | sh - mkdir -p /etc/systemd/system/docker.service.d/ - cat > /etc/systemd/system/docker.service.d/docker.conf << EOF - [Service] - ExecStart= - ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry=nexus3.onap.org:10003 - Environment="HTTP_PROXY=$proxy" - Environment="HTTPS_PROXY=$proxy" - EOF - systemctl daemon-reload - systemctl restart docker - apt-mark hold docker-ce - docker login -u docker -p docker nexus3.onap.org:10003 - } - docker_compose_install () { - curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose - } - pnf_sim_file_checkout () { - cd /root; git clone https://gerrit.onap.org/r/integration - } - - start_pnf_simulator () { - docker login -u docker -p docker nexus3.onap.org:10003 - cd ~/integration/test/mocks/pnfsimulator/pnfsimulator - docker-compose up -d - } - - start_netconf_simulator () { - docker login -u docker -p docker nexus3.onap.org:10003 - cd ~/integration/test/mocks/pnfsimulator/netconfsimulator - docker-compose up -d - } - - set_versions - set_proxy - enable_root_ssh - set_apt_get_proxy - docker_install_and_configure - docker_compose_install - pnf_sim_file_checkout - start_pnf_simulator - start_netconf_simulator - params: - $proxy: { get_param: proxy } - PNF_PnP_simulator_port0: - type: OS::Neutron::Port - properties: - network_id: { get_param: private_net_id } - security_groups: - - default - fixed_ips: - - subnet_id: { get_param: private_subnet_id } - PNF_PnP_simulator_public: - type: OS::Neutron::FloatingIP - properties: - floating_network_id: { get_param: public_net_id } - port_id: { get_resource: PNF_PnP_simulator_port0 } -outputs: - PNF_PnP_simulator_private_ip: - description: IP address of PNF_PnP_simulator in private network - value: { get_attr: [ PNF_PnP_simulator, first_address ] } - PNF_PnP_simulator_public_ip: - description: Floating IP address of PNF_PnP_simulator in public network - value: { get_attr: [ PNF_PnP_simulator_public, floating_ip_address ] } diff --git a/test/mocks/pnfsimulator/netconfsimulator/Dockerfile_app b/test/mocks/pnfsimulator/netconfsimulator/Dockerfile_app deleted file mode 100644 index a775219e6..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/Dockerfile_app +++ /dev/null @@ -1,4 +0,0 @@ -FROM openjdk:8-jre-alpine -ADD target/libs /app/libs -ADD target/netconfsimulator-5.0.0-SNAPSHOT.jar /app/netconf-simulator.jar -CMD java -cp /app/libs/*:/app/netconf-simulator.jar org.onap.netconfsimulator.Main \ No newline at end of file diff --git a/test/mocks/pnfsimulator/netconfsimulator/Dockerfile_netopeer b/test/mocks/pnfsimulator/netconfsimulator/Dockerfile_netopeer deleted file mode 100644 index 9fe56e19d..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/Dockerfile_netopeer +++ /dev/null @@ -1,6 +0,0 @@ -FROM sysrepo/sysrepo-netopeer2:v0.7.7 -ADD apt.conf /etc/apt/apt.conf -RUN apt-get update && apt-get install -y python3 python3-pip python-pip && pip3 install flask flask_restful kafka-python && pip install kafka-python -RUN cd /opt/dev/sysrepo && cmake -DGEN_PYTHON_VERSION=2 -DREPOSITORY_LOC:PATH=/etc/sysrepo . && make install - -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] diff --git a/test/mocks/pnfsimulator/netconfsimulator/README.md b/test/mocks/pnfsimulator/netconfsimulator/README.md deleted file mode 100644 index b82522602..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/README.md +++ /dev/null @@ -1,297 +0,0 @@ -# Netconf Simulator -A simulator that is able to receive and print history of CM configurations. - -## Required software -To run the simulator, the following software should be installed: -- JDK 1.8 -- Maven -- docker -- docker-compose - -### API -Simulator exposes both HTTP and native netconf interface. - -### Running simulator -In order to run simulator, invoke *mvn clean install docker:build* to build required images. -Add executable permission to initialize_netopeer.sh (by executing `sudo chmod +x netconf/initialize_netopeer.sh`) -and then invoke *docker-compose up* command. -In case of copying simulator files to another location, keep in mind to copy also *docker-compose.yml* and directories: *config, templates, netopeer-change-saver-native and netconf*. - -#### Restarting -Restarting simulator can be done by first typing *docker-compose restart* in terminal. - -#### Shutting down -The command *docker-compose down* can be used to shut the simulator down. - -## Usage of simulator - -### Netconf TLS support -Embedded netconf server supports connections over TLS on port 6513. Default server and CA certificate have been generated using method described below. Please proceed with these steps to recreate own certificates. Important is to fulfill all needed data during certificate preparation because Netconf verifies certs description pretty strictly. - -Mentioned Github repository contains sample client certificate, which works out of the box. - -#### Replacing server certificates -In order to replace TLS certificates with third-party ones, the following naming schema must be followed: -* CA certificate file should be named 'ca.crt' -* Netconf server certificate file should be named 'server_cert.crt' -* Netconf server keyfile file should be named 'server_key.pem' -* Client certificate file should be named 'client.crt' -* Client keyfile should be named 'client.key' - -Certificates and keys should follow PEM formatting guidelines. -Prepared files should be placed under _tls/_ directory (existing files must be overwritten). -After copying, it is necessary to restart the Netconf Simulator (please refer to [restarting simulator](restarting) guide). - -This is a sample curl command to test client connection (the example assumes that Netconf Simulator runs on 127.0.0.1): -``` -curl --cacert ca.crt --cert client.crt --key client.key https://127.0.0.1:6513 -kv --http0.9 -``` -or using openssl: -``` -openssl s_client -connect 127.0.0.1:6513 -cert client.crt -key client.key -CAfile ca.crt -``` - -To regenerate all required certificates follow steps: -1. Generate your private key and public certificate: ```openssl req -newkey rsa:4096 -keyform PEM -keyout ca.key -x509 -days 3650 -outform PEM -out ca.crt``` -2. Create a private client key:```openssl genrsa -out client.key 4096``` -3. Generate certificate signing request:```openssl req -new -key client.key -out client.req``` -4. Generating signed client certificate: ```openssl x509 -req -in client.req -CA ca.crt -CAkey ca.key -set_serial 101 -extensions client -days 365 -outform PEM -out client.crt``` -5. Create a private server key:```openssl genrsa -out server_key.pem 4096``` -6. Generate certificate signing request:```openssl req -new -key server_key.pem -out server.req -sha256``` -7. Generating signed server certificate: ```openssl x509 -req -in server.req -CA ca.crt -CAkey ca.key -set_serial 100 -extensions server -days 1460 -outform PEM -out server_cert.crt -sha256``` - -Client authenticates using described TLS configuration, their username will resolve to test (more information in tls_listen.xml under the cert-to-name section). It is required that this username exists on the local system (just like for SSH), so you will need to (temporarily) create this user. The simplest way is executing # useradd -MN test, which creates the user without a home directory and user group. - -Currently by default there is only a possibility to substitute existing certificates for single user. -``` - - -### Capturing netconf configuration changes - -The netconfsimulator tool will intercept changes in netconf configuration, done by edit-config command (invoked through simulator's edit-configuration endpoint or directly through exposed netconf-compliant interface). The following changes are intercepted: -- creating new item -- moving an item -- modifying an item -- deleting an item - -Each captured change contains fully qualified parameter name (including xpath - namespace and container name) - -#### REST API usage with examples - -Application of native netconf operations on YANG model is covered by REST API layer. -Example invocation of operations with its requests and results are presented below. -For basic edit-config and get config actions, response is in plain XML format, whereas stored data that can be accessed via API is returned in JSON format. - -**Load new YANG model** -http method: POST -``` -URL: http::9000/netconf/model/ -``` -request: file content to be sent as multipart (form data) -``` -module pnf-simulator { - namespace "http://onap.org/pnf-simulator"; - prefix config; - container config { - config true; - leaf itemValue1 {type uint32;} - leaf itemValue2 {type uint32;} - leaf itemValue3 {type uint32;} - leaf-list allow-user { - type string; - ordered-by user; - description "A sample list of user names."; - } - } -} -``` - -**Delete existing YANG model** -http method: DELETE -``` -URL: http::9000/netconf/model/ -``` -request body should be empty. -response: a HTTP 200 code indicating successful operation or 400/500 in case of errors. - -**Get all running configurations** -http method: GET -``` -URL: http::9000/netconf/get -``` -response: plain XML -``` - - 2781 - 3782 - 3333 - - - 2781 - 3782 - 3333 - -``` - -**Get running configuration** -http method: GET -``` -URL: http::9000/netconf/get/'moduleName'/'container' -``` -response: plain XML -``` - - 2781 - 3782 - 3333 - -``` - -**Edit configuration** -To edit configuration XML file must be prepared. No plain request body is used here, -request content must be passed as multipart file (form data) with file name/key='editConfigXml' and file content in XML format - -http method: POST -``` -URL: http::9000/netconf/edit-config -``` -request: file content to be sent as multipart (form data) -``` - - 2781 - 3782 - 3333 - -``` - -response: actual, running configuration after editing config: -``` - - 2781 - 3782 - 3333 -" -``` - -Captured change, that can be obtained from db also via REST API: - -http method: GET -``` -URL: http://:9000/store/less?offset=1 -``` -response: -``` -[{"timestamp": 1542877413979, "configuration": "CREATED: /pnf-simulator:config/itemValue3 = 3333"}] -``` - -Notice: if new value is the same as the old one, the change won’t be intercepted (because there is no state change). This is a limitation of used netconf implementation (Netopeer2). - -**Modify request** -http method: POST -``` -URL: http::9000/netconf/edit-config -``` -file content to be sent as multipart (form data): -``` - - 111 - 222 - -``` - -response: actual, running configuration after editing config: -``` - - 111 - 222 -" -``` - -Captured change: -http method: GET -``` -URL: http://:9000/store/less?offset=2 -``` -``` -[{"timestamp": 1542877413979, "configuration": "MODIFIED: : old value: /pnf-simulator:config/itemValue1 = 2781, new value: /pnf-simulator:config/itemValue1 = 111", - {"timestamp": 1542877413979, "configuration": "MODIFIED: : old value: /pnf-simulator:config/itemValue2 = 3782, new value: /pnf-simulator:config/itemValue2 = 222"}] -``` - -**Move request** (inserting a value into leaf-list which in turn rearranges remaining elements) -http method: POST -``` -URL: http::9000/netconf/edit-config -``` -file content to be sent as multipart (form data): -``` - - mike - -``` - -Captured change: -http method: GET -``` -URL: http://:9000/store/less?offset=2 -``` -``` -[{"timestamp": 1542877413979, "configuration": "CREATED: /pnf-simulator:config/allow-user = mike"}, - {"timestamp": 1542877413979, "configuration": "MOVED: /pnf-simulator:config/allow-user = mike after /pnf-simulator:config/allow-user = alice"}] -``` - -**Delete request** -http method: POST -``` -URL: http::9000/netconf/edit-config -``` -file content to be sent as multipart (form data): -``` - - 1111 - - -``` - -Captured change: -http method: GET -``` -URL: http://:9000/store/less?offset=1 -``` -``` -[{"timestamp": 1542877413979, "configuration": "DELETED: /pnf-simulator:config/itemValue2 = 222"}] -``` - -Getting all configuration changes: -http method: GET -``` -URL: http://:9000/store/cm-history -``` -response: -``` -[{"timestamp":1542877413979,"configuration":"MODIFIED: : old value: /pnf-simulator:config/itemValue1 = 2781, new value: /pnf-simulator:config/itemValue1 = 111"}, - {"timestamp":1542877413979,"configuration":"MODIFIED: : old value: /pnf-simulator:config/itemValue2 = 3782, new value: /pnf-simulator:config/itemValue2 = 222"}, - {"timestamp":1542877414000,"configuration":"CREATED: : /pnf-simulator:config/itemValue3 = 3333"}, - {"timestamp":1542877414104,"configuration":"CREATED: : CREATED: /pnf-simulator:config/allow-user = mike"} - {"timestamp":1542877414107,"configuration":"MOVED: /pnf-simulator:config/allow-user = mike after /pnf-simulator:config/allow-user = alice"}, - {"timestamp":1542877414275,"configuration":"DELETED: /pnf-simulator:config/itemValue2 = 222"}] -``` - -### Logging - -### Swagger - -## Developers Guide - -### Integration tests -Integration tests use docker-compose for setting up cluster with all services. -Those tests are not part of build pipeline, but can be run manually by invoking *mvn verify -DskipITs=false* from project command line. -Tests can be found in netconfsimulator project in src/integration directory. - -## Troubleshooting -Q: Simulator throws errors after shutting down with *docker-compose down* or *docker-compose restart* - -A: Remove docker containers that were left after stopping the simulator with the following commands: -``` -docker stop $(docker ps | grep netconfsimulator | awk '{print $1;}') -docker rm $(docker ps -a | grep netconfsimulator | awk '{print $1;}') -``` diff --git a/test/mocks/pnfsimulator/netconfsimulator/apt.conf b/test/mocks/pnfsimulator/netconfsimulator/apt.conf deleted file mode 100644 index 9146b6b31..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/apt.conf +++ /dev/null @@ -1,5 +0,0 @@ -Acquire::http { - No-Cache "true"; - No-Store "true"; - Pipeline-Depth "0"; - }; \ No newline at end of file diff --git a/test/mocks/pnfsimulator/netconfsimulator/config/netconf.env b/test/mocks/pnfsimulator/netconfsimulator/config/netconf.env deleted file mode 100644 index 6cf310a27..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/config/netconf.env +++ /dev/null @@ -1,5 +0,0 @@ -NETCONF_ADDRESS=netopeer -NETCONF_PORT=830 -NETCONF_MODEL=pnf-simulator -NETCONF_MAIN_CONTAINER=config -TZ=Europe/Warsaw diff --git a/test/mocks/pnfsimulator/netconfsimulator/docker-compose.yml b/test/mocks/pnfsimulator/netconfsimulator/docker-compose.yml deleted file mode 100644 index 5e9acbe8e..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/docker-compose.yml +++ /dev/null @@ -1,93 +0,0 @@ -version: '3' - -services: - zookeeper: - image: wurstmeister/zookeeper - ports: - - "2181:2181" - networks: - - netconfnetwork - - kafka1: - image: wurstmeister/kafka:1.1.0 - ports: - - "9092:9092" - hostname: kafka1 - networks: - - netconfnetwork - environment: - KAFKA_ADVERTISED_PORT: 9092 - KAFKA_ADVERTISED_HOST_NAME: kafka1 - KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 - KAFKA_CREATE_TOPICS: "config:1:1" - KAFKA_DELETE_RETENTION_MS: 604800000 - KAFKA_LOG_CLEANER_DELETE_RETENTION_MS: 604800000 - depends_on: - - zookeeper - - netconf-simulator: - image: nexus3.onap.org:10003/onap/netconfsimulator - ports: - - "9000:8080" - restart: on-failure - hostname: netconf-simulator - networks: - - netconfnetwork - depends_on: - - zookeeper - - kafka1 - - netopeer - - netopeer: - image: nexus3.onap.org:10003/netopeer - ports: - - "830:830" - - "5002:5002" - - "6513:6513" - volumes: - - ./netconf:/netconf - - ./netopeer-change-saver-native:/netopeer-change-saver - - ./tls:/tls - env_file: - - ./config/netconf.env - restart: on-failure - networks: - - netconfnetwork - depends_on: - - sftp-server - - ftpes-server - command: - - /netconf/initialize_netopeer.sh - - sftp-server: - image: atmoz/sftp:alpine - ports: - - "2222:22" - volumes: - - ./sftp:/home/sftp-user/sftp - - ./ssh/ssh_host_rsa_key.pub:/home/sftp-user/.ssh/keys/ssh_host_rsa_key.pub - networks: - - netconfnetwork - restart: on-failure - command: sftp-user::1001 - - ftpes-server: - image: stilliard/pure-ftpd:latest - ports: - - "2221:21" - - "30000-30009:30000-30009" - volumes: - - ./ftpes/files:/home/ftpusers/onap - - ./ftpes/userpass/:/etc/pure-ftpd/passwd/ - - ./ftpes/tls/:/etc/ssl/private/ - networks: - - netconfnetwork - environment: - PUBLICHOST: localhost - ADDED_FLAGS: --tls=2 - FTP_USER_HOME: onap - restart: on-failure - -networks: - netconfnetwork: - driver: bridge diff --git a/test/mocks/pnfsimulator/netconfsimulator/docker/Dockerfile b/test/mocks/pnfsimulator/netconfsimulator/docker/Dockerfile deleted file mode 100644 index 0e25fd310..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/docker/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM openjdk:8-jre-alpine -ADD libs /app/libs -ADD netconfsimulator-5.0.0-SNAPSHOT.jar /app/netconf-simulator.jar -CMD java -cp /app/libs/*:/app/netconf-simulator.jar org.onap.netconfsimulator.Main diff --git a/test/mocks/pnfsimulator/netconfsimulator/ftpes/files/ftpes-noone.txt b/test/mocks/pnfsimulator/netconfsimulator/ftpes/files/ftpes-noone.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/mocks/pnfsimulator/netconfsimulator/ftpes/files/onap/ftpes-onap.txt b/test/mocks/pnfsimulator/netconfsimulator/ftpes/files/onap/ftpes-onap.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/mocks/pnfsimulator/netconfsimulator/ftpes/tls/pure-ftpd.pem b/test/mocks/pnfsimulator/netconfsimulator/ftpes/tls/pure-ftpd.pem deleted file mode 100755 index 0ce676efa..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/ftpes/tls/pure-ftpd.pem +++ /dev/null @@ -1,49 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHbSk5/cABTpCt -q54QyTkhuhb84nEz5ztKL0hY56fsVtAA2gSAde+qV9YwUIuReOUhAF4RVVt2Lkn/ -1R0yX+0IjrXnO7jYzDj6QhgyqYKb3iQlvShZMMQ7qihn8qBxobk7+O10x6VLS2L8 -WYpQxGXu7T1qXbw10RhrqG8nbXYX+aHMsv9zMt9OYqKSI073OZR2vk3K49Uqcurj -sXuRJOa10MRsxgA726pr8OLWAWejsoFaqP2fQS3HeT2RnAqPyAgPc0P6n7gxo0JU -U5dPnrPbsvfdegIFxfc57oZXrLz7nYXkJEcjYTBFSQ+JAaRfx9kNXZ7Gft7EAMyF -BLemY/0VAgMBAAECggEARD9bSHlKaCgW4xhEM8JpRt2EWG62BukvJSghPiupD/x1 -mpUBzWSO7GC68DXgTZxt7WlOx+fKMRuOP3sTTtX9LFyKa+PIUokxRpOv7EaOaAER -pciiMkO6JCELSueBeOG7noaF3N0l+CqIaYvLBfDwYV/XELubWV+BV/aAc6HGNFWi -4bjM+BOBLQstrEeJh2jVylzv4CTtlTs2pwiHFSyrHhudTk5nnATAHn1gi+X42v1A -zk3UfqADZJmMI0/Roup4YPZ3+6zUzDN2i+qasHexL0OKIjRcSqpgqQoIeKEbKKfw -sOgiWIR2Xvj7EJmhzJlWgKjk8OLs/7U4QpnD+s0agQKBgQDu3ojqKNWnPHy0Nupm -tmAs28WLK76R0iZeAd2nwsU2K6lnm9z5o2ab3ffTJVB9kAetKJa3UerKskF/qF9C -MtjlEn6F++uYFitpLjQevnyrKSqFqbzytDXrQlk+gZLglmi6YylT5k9qLSREAu55 -XS/wbm9XU2Q7sl8oTnZHXptT7QKBgQDVunvqdDn1FaNU9EwQCGPS3QGu+go22xkM -4Rs2CoHWfqmhGOo8lJKBElDqsXvxggrZLWJe/1lgnELT/9aXS8QLWBnZxpTj9wfd -igH+CJc3mWnLThmUGdSV/tuHon2IdQ8/1CiGSwIr9kYCnStidUtOXjIbgc6kUTTi -5wtIGHh4yQKBgQDXJ/0dJbDklRgiX4CdCdLxNPfnlnxt7mN+s6GK1WY7l/JcD8ln -1qW66aGrP2YT42L2tqOi9hdNgmh66xb6ksBI/XKXjsWz1Ow/Lk3mD2BN76OMh8pY -trgGc1ndcmrw/qnQkTcNilqn4YdT92wER0rB/0cs2kFjgBQ0QxBI0s+INQKBgA6Y -2fW9UmgGvk0DEl7V89tm9MJ6mU/9zswuY6lhNlTr+bHi/bx9eTQPiC8/R/PKqesD -SoCqd/Q9N+M6yfEzX4RW1A0nnuui54qd7lznQUyu0abtApo22WoVKfEti91SAWSe -nNXvMYrHGyj6iwgCcs47aLiwOOjIExCcLw0RfsjhAoGAc1zaRbrtjjh66FJYjLiJ -Q6EXfm31ptaQQUn5rQyHMD2VRlajCYV+fv75tezf2dQvJcqHYWrEuY8U+OTbB1TB -IEqN8ETUeLegl5RgvWoyWinqdbv/0d9LtwVBdtiEQLoYumD934mshEDgzCOOjrBe -Salcd1vc6y6NiFooPlvloXQ= ------END PRIVATE KEY----- ------BEGIN CERTIFICATE----- -MIIDYDCCAkigAwIBAgIJAMH2upKd2yAJMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV -BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX -aWRnaXRzIFB0eSBMdGQwHhcNMTgwOTEwMTI1ODE2WhcNMzgwOTA1MTI1ODE2WjBF -MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50 -ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAx20pOf3AAU6QraueEMk5IboW/OJxM+c7Si9IWOen7FbQANoEgHXvqlfW -MFCLkXjlIQBeEVVbdi5J/9UdMl/tCI615zu42Mw4+kIYMqmCm94kJb0oWTDEO6oo -Z/KgcaG5O/jtdMelS0ti/FmKUMRl7u09al28NdEYa6hvJ212F/mhzLL/czLfTmKi -kiNO9zmUdr5NyuPVKnLq47F7kSTmtdDEbMYAO9uqa/Di1gFno7KBWqj9n0Etx3k9 -kZwKj8gID3ND+p+4MaNCVFOXT56z27L33XoCBcX3Oe6GV6y8+52F5CRHI2EwRUkP -iQGkX8fZDV2exn7exADMhQS3pmP9FQIDAQABo1MwUTAdBgNVHQ4EFgQUt51lQ+ab -MTq+w2U/knCsIPb3wrkwHwYDVR0jBBgwFoAUt51lQ+abMTq+w2U/knCsIPb3wrkw -DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAQ69AktYLQ+VRbojz -zC0XQ2M1FAkfJI2P0LvPoYxZgId2CnZW3sMIdnJdF+KjvOqeGyFmw+hn8WkoKiWj -0sxuGmrWt5t+5bF2wcq0CtTeF1/o6DsRhRiJBzmcLe81ItrN6emZSg96xCKzkHBZ -3nF4fG88vtiYgD932lMStDqQzSTx0FsCGpGaKh9xDmKvlP24NWdM9gyOEsRbDvqd -vS1Q45Jx0jzkp7X5d0casqBWIZak3z0EVdK7c8Y/GxxTcWfIMINCl9+F9kpTA/ZX -uARYzrPWaBfDBi2r5acWi/AHJM3U+LgzO5nCKa+38vtjNw3NtbslA4InQ5cU2B8X -QN8NlQ== ------END CERTIFICATE----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/ftpes/userpass/pureftpd.passwd b/test/mocks/pnfsimulator/netconfsimulator/ftpes/userpass/pureftpd.passwd deleted file mode 100755 index 7961e710d..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/ftpes/userpass/pureftpd.passwd +++ /dev/null @@ -1 +0,0 @@ -onap:$6$Guq6OMhBdNZ6nTk0$7dLt6hOrAv.in36jzWGd5UgWeDqN3CuKjrzJ.izRTdgZRTszeNYbT2dk7UDh9CLD7pohnB0.k1NSZmRIUB/ID/:1001:1001::/home/ftpusers/onap/./:::::::::::: diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/__init__.py b/test/mocks/pnfsimulator/netconfsimulator/netconf/__init__.py deleted file mode 100644 index aa8b4f995..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -### -# ============LICENSE_START======================================================= -# Simulator -# ================================================================================ -# Copyright (C) 2019 Nokia. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/initialize_netopeer.sh b/test/mocks/pnfsimulator/netconfsimulator/netconf/initialize_netopeer.sh deleted file mode 100755 index 59fc8a14e..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/initialize_netopeer.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -### -# ============LICENSE_START======================================================= -# Simulator -# ================================================================================ -# Copyright (C) 2019 Nokia. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -cp /tls/* /usr/local/etc/keystored/keys/ -cp /netconf/*.xml /tmp/ - -chmod +x /netconf/set-up-xmls.py -/netconf/set-up-xmls.py /tls ca.crt server_cert.crt server_key.pem /tmp/load_server_certs.xml /tmp/tls_listen.xml client.crt - -/usr/bin/supervisord -c /etc/supervisord.conf & -sysrepoctl --install --yang=/netconf/pnf-simulator.yang --owner=netconf:nogroup --permissions=777 -sysrepocfg --import=/netconf/pnf-simulator.data.xml --datastore=startup --format=xml --level=3 pnf-simulator -sysrepocfg --merge=/tmp/load_server_certs.xml --format=xml --datastore=startup ietf-keystore -sysrepocfg --merge=/tmp/tls_listen.xml --format=xml --datastore=startup ietf-netconf-server - -nohup python3 /netconf/yang_loader_server.py & - -python /netconf/netopeer_change_saver.py pnf-simulator kafka1:9092 config \ No newline at end of file diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/load_server_certs.xml b/test/mocks/pnfsimulator/netconfsimulator/netconf/load_server_certs.xml deleted file mode 100644 index b52f911c9..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/load_server_certs.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - SERVER_KEY_NAME - - - SERVER_CERT_NAME - SERVER_CERTIFICATE_HERE - - - - - - test_trusted_ca_list - - CA_CERT_NAME - CA_CERTIFICATE_HERE - - - CLIENT_CERT_NAME - CLIENT_CERTIFICATE_HERE - - - diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/netopeer_change_saver.py b/test/mocks/pnfsimulator/netconfsimulator/netconf/netopeer_change_saver.py deleted file mode 100644 index 92f88463d..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/netopeer_change_saver.py +++ /dev/null @@ -1,107 +0,0 @@ -### -# ============LICENSE_START======================================================= -# Simulator -# ================================================================================ -# Copyright (C) 2019 Nokia. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -import sysrepo as sr -import sys -import json -import time -import logging -from kafka import KafkaProducer -from enum import Enum - -logging.basicConfig(filename='netopeer_change_saver.log', level=logging.DEBUG) - -kafka_producer = None -topic = "config" - - -class OperationType(Enum): - CREATED = sr.SR_OP_CREATED - DELETED = sr.SR_OP_DELETED - MODIFIED = sr.SR_OP_MODIFIED - MOVED = sr.SR_OP_MOVED - - -def module_change_callback(session, name, event, private_ctx): - if sr.SR_EV_APPLY == event: - change_path = "/{}:*".format(name) - changes = session.get_changes_iter(change_path) - change = session.get_change_next(changes) - while change: - try: - process_change(change) - change = session.get_change_next(changes) - except Exception: - logging.exception("Exception occured") - - return sr.SR_ERR_OK - - -def process_change(change): - if change: - message = {"type": OperationType(change.oper()).name} - if change.old_val(): - message["old"] = {"path": change.old_val().xpath(), "value": change.old_val().val_to_string()} - if change.new_val(): - message["new"] = {"path": change.new_val().xpath(), "value": change.new_val().val_to_string()} - send_message(message) - - -def send_message(message): - logging.debug("Message to kafka : %s", message) - response = kafka_producer.send(topic, message) - logging.info(response.get(timeout=90)) - - -def create_producer(server): - for i in range(10): # pylint: disable=W0612 - try: - return KafkaProducer(bootstrap_servers=server, value_serializer=lambda v: json.dumps(v).encode('utf-8')) - except Exception: - time.sleep(15) - raise Exception("Could not connect to kafka server") - - -def print_current_config(kafka_session, module): - name = "/{}:*//*".format(module) - logging.info("Retrieving current config for %s module", name) - values = kafka_session.get_items(name) - for i in range(values.val_cnt()): - logging.info(values.val(i).to_string()) - - -if __name__ == "__main__": - try: - module_name = sys.argv[1] - bootstrap_servers = sys.argv[2] - topic = sys.argv[3] - connection = sr.Connection("example_application2") - session = sr.Session(connection) - subscribe = sr.Subscribe(session) - subscribe.module_change_subscribe(module_name, module_change_callback) - - print_current_config(session, module_name) - - kafka_producer = create_producer(bootstrap_servers) - - sr.global_loop() - except Exception as e: - logging.exception("Exception occured") - raise e diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.xml b/test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.xml deleted file mode 100644 index 90a3451d4..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - 500 - 1000 - diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.yang b/test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.yang deleted file mode 100644 index 544f46725..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/newmodel.yang +++ /dev/null @@ -1,9 +0,0 @@ -module newmodel { - namespace "http://onap.org/pnf-simulator2"; - prefix config2; - container config2 { - config true; - leaf item1 {type uint32;} - leaf item2 {type uint32;} - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.data.xml b/test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.data.xml deleted file mode 100644 index c235f6405..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.data.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - 42 - 35 - diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.yang b/test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.yang deleted file mode 100644 index ba1158560..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/pnf-simulator.yang +++ /dev/null @@ -1,9 +0,0 @@ -module pnf-simulator { - namespace "http://onap.org/pnf-simulator"; - prefix config; - container config { - config true; - leaf itemValue1 {type uint32;} - leaf itemValue2 {type uint32;} - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/set-up-xmls.py b/test/mocks/pnfsimulator/netconfsimulator/netconf/set-up-xmls.py deleted file mode 100755 index 2ec1cf2b9..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/set-up-xmls.py +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/env python - -### -# ============LICENSE_START======================================================= -# Simulator -# ================================================================================ -# Copyright (C) 2019 Nokia. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -import os -import sys -import logging -import logging.config - -logging.basicConfig() -logger = logging.getLogger() -logger.setLevel(logging.INFO) - -# Placeholders definition - this needs to match placeholders in -# load_server_certs_xml_file and tls_listen_xml_file -SERVER_KEY_NAME = "SERVER_KEY_NAME" -SERVER_CERT_NAME = "SERVER_CERT_NAME" -SERVER_CERTIFICATE_HERE = "SERVER_CERTIFICATE_HERE" -CA_CERT_NAME = "CA_CERT_NAME" -CLIENT_CERT_NAME = "CLIENT_CERT_NAME" -CLIENT_CERTIFICATE_HERE="CLIENT_CERTIFICATE_HERE" -CA_CERTIFICATE_HERE = "CA_CERTIFICATE_HERE" -CLIENT_FINGERPRINT_HERE = "CLIENT_FINGERPRINT_HERE" -SERVER_CERTIFICATE_ENV = "SERVER_CERTIFICATE_ENV" -CA_CERTIFICATE_ENV = "CA_CERTIFICATE_ENV" - - -class FileHelper(object): - @classmethod - def get_file_contents(cls, filename): - with open(filename, "r") as f: - return f.read() - - @classmethod - def write_file_contents(cls, filename, data): - with open(filename, "w+") as f: - f.write(data) - - -class CertHelper(object): - @classmethod - def get_pem_content_stripped(cls, pem_dir, pem_filename): - cmd = "cat {}/{} | grep -v '^-'".format(pem_dir, pem_filename) - content = CertHelper.system(cmd) - return content - - @classmethod - def get_cert_fingerprint(cls, directory, cert_filename): - cmd = "openssl x509 -fingerprint -noout -in {}/{} | sed -e " \ - "'s/SHA1 Fingerprint//; s/=//; s/=//p'" \ - .format(directory, cert_filename) - fingerprint = CertHelper.system(cmd) - return fingerprint - - @classmethod - def print_certs_info(cls, ca_cert, ca_fingerprint, server_cert): - logger.info("Will use server certificate: " + server_cert) - logger.info("Will use CA certificate: " + ca_cert) - logger.info("CA certificate fingerprint: " + ca_fingerprint) - - @classmethod - def system(cls, cmd): - return os.popen(cmd).read().replace("\n", "") - - -class App(object): - @classmethod - def patch_server_certs(cls, data, server_key_filename_noext, - server_cert_filename_noext, ca_cert_filename_noext, - server_cert, ca_cert, client_cert_filename_noext, client_cert): - data = data.replace(SERVER_KEY_NAME, server_key_filename_noext) - data = data.replace(SERVER_CERT_NAME, server_cert_filename_noext) - data = data.replace(CA_CERT_NAME, ca_cert_filename_noext) - data = data.replace(CLIENT_CERT_NAME, client_cert_filename_noext) - data = data.replace(CLIENT_CERTIFICATE_HERE, client_cert) - data = data.replace(SERVER_CERTIFICATE_HERE, server_cert) - data = data.replace(CA_CERTIFICATE_HERE, ca_cert) - return data - - @classmethod - def patch_tls_listen(cls, data, server_cert_filename_noext, client_fingerprint, - server_cert, ca_cert): - data = data.replace(SERVER_CERT_NAME, server_cert_filename_noext) - data = data.replace(CLIENT_FINGERPRINT_HERE, client_fingerprint) - data = data.replace(SERVER_CERTIFICATE_HERE, server_cert) - data = data.replace(CA_CERTIFICATE_HERE, ca_cert) - return data - - @classmethod - def run(cls): - # name things - cert_dir = sys.argv[1] - ca_cert_filename = sys.argv[2] - server_cert_filename = sys.argv[3] - server_key_filename = sys.argv[4] - load_server_certs_xml_file = sys.argv[5] - tls_listen_xml_file = sys.argv[6] - client_cert_filename = sys.argv[7] - - - # strip extensions - ca_cert_filename_noext = ca_cert_filename.replace(".crt", "") - server_cert_filename_noext = server_cert_filename.replace(".crt", "") - server_key_filename_noext = server_key_filename.replace(".pem", "") - client_cert_filename_noext = client_cert_filename.replace(".crt", "") - - # get certificates from files - server_cert = CertHelper.get_pem_content_stripped(cert_dir, - server_cert_filename) - ca_cert = CertHelper.get_pem_content_stripped(cert_dir, - ca_cert_filename) - client_fingerprint = CertHelper.get_cert_fingerprint(cert_dir, - client_cert_filename) - CertHelper.print_certs_info(ca_cert, client_fingerprint, server_cert) - - client_cert = CertHelper.get_pem_content_stripped(cert_dir, - client_cert_filename) - # patch TLS configuration files - data_srv = FileHelper.get_file_contents(load_server_certs_xml_file) - patched_srv = App.patch_server_certs(data_srv, server_key_filename_noext, - server_cert_filename_noext, - ca_cert_filename_noext, - server_cert, ca_cert, - client_cert_filename_noext, client_cert) - FileHelper.write_file_contents(load_server_certs_xml_file, patched_srv) - - data_tls = FileHelper.get_file_contents(tls_listen_xml_file) - patched_tls = App.patch_tls_listen(data_tls, server_cert_filename_noext, - client_fingerprint, server_cert, ca_cert) - FileHelper.write_file_contents(tls_listen_xml_file, patched_tls) - - -def main(): - if len(sys.argv) is not 8: - print("Usage: {1} " - " " - " ", sys.argv[0]) - return 1 - App.run() - logger.info("XML files patched successfully") - - -if __name__ == '__main__': - main() diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/test_yang_loader_server.py b/test/mocks/pnfsimulator/netconfsimulator/netconf/test_yang_loader_server.py deleted file mode 100644 index a22208711..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/test_yang_loader_server.py +++ /dev/null @@ -1,121 +0,0 @@ -### -# ============LICENSE_START======================================================= -# Simulator -# ================================================================================ -# Copyright (C) 2019 Nokia. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -import unittest - -from unittest import mock -from werkzeug.datastructures import FileStorage - -from yang_loader_server import YangLoaderHelper, YangModelServer - - -class TestYangLoaderHelper(unittest.TestCase): - - def test_should_save_file_and_return_path(self): - helper = YangLoaderHelper() - mocked_file = mock.Mock(FileStorage) - mocked_file.filename = "sample" - - path = helper.save_file(mocked_file) - - self.assertEqual(path, "/tmp/sample") - mocked_file.save.assert_called_once_with("/tmp/sample") - - @mock.patch('yang_loader_server.check_output') - def test_should_install_new_yang_model(self, mocked_output): - helper = YangLoaderHelper() - - helper.install_new_model("path") - - mocked_output.assert_called_with( - ['sysrepoctl', '--install', '--yang=path', - '--owner=netconf:nogroup', '--permissions=777'], - stderr=-2, universal_newlines=True) - - @mock.patch('yang_loader_server.check_output') - def test_should_delete_yang_model(self, mocked_output): - helper = YangLoaderHelper() - - helper.uninstall_a_model("modelName") - - mocked_output.assert_called_with( - ['sysrepoctl', '--uninstall', '--module=modelName'], - stderr=-2, universal_newlines=True) - - @mock.patch('yang_loader_server.check_output') - def test_should_set_default_configuration(self, mocked_output): - helper = YangLoaderHelper() - - helper.set_default_configuration("samplePath", "sampleModuleName") - - mocked_output.assert_called_with( - ['sysrepocfg', '--import=samplePath', '--datastore=startup', - '--format=xml', '--level=3', 'sampleModuleName'], - stderr=-2, universal_newlines=True) - - @mock.patch('yang_loader_server.subprocess.Popen') - @mock.patch('yang_loader_server.check_output') - def test_should_verify_change_listener_for_model_properly(self, mocked_output, mocked_popen): - helper = YangLoaderHelper() - - helper.start_change_listener_for_model("sampleModule") - - mocked_output.assert_called_with( - ['pgrep', '-f', 'python /netconf/netopeer_change_saver.py sampleModule kafka1:9092 config'], - stderr=-2, universal_newlines=True) - - @mock.patch('yang_loader_server.check_output') - def test_should_raise_exception_when_error_occurred_in_output(self, - mocked_output): - helper = YangLoaderHelper() - mocked_output.return_value = "abcd ERR" - with self.assertRaises(RuntimeError) as context: - helper._run_bash_command("sample command") - - self.assertEqual('abcd ERR', str(context.exception)) - - -class TestYangModelServer(unittest.TestCase): - - def __init__(self, methodName='runTest'): - super().__init__(methodName) - self._mocked_file = mock.Mock(FileStorage) - - def test_should_properly_apply_and_start_new_model(self): - with mock.patch.object(YangModelServer, '_parse_request', - new=self._mock_request): - helper = mock.Mock(YangLoaderHelper) - helper.save_file.return_value = "sampleFile" - server = YangModelServer(helper) - - server.post() - - self.assertEqual(helper.save_file.call_count, 2) - helper.install_new_model.assert_called_once_with('sampleFile') - helper.set_default_configuration.assert_called_once_with( - 'sampleFile', 'sampleModuleName') - helper.start_change_listener_for_model.assert_called_once_with('sampleModuleName') - - def _mock_request(self): - return { - 'yangModel': self._mocked_file, - 'initialConfig': self._mocked_file, - 'moduleName': "sampleModuleName" - } diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/tls_listen.xml b/test/mocks/pnfsimulator/netconfsimulator/netconf/tls_listen.xml deleted file mode 100644 index 4f610b580..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/tls_listen.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - test_tls_listen_endpt - -
0.0.0.0
- 6513 - - - SERVER_CERT_NAME - - - - test_trusted_ca_list - test_trusted_ca_list - - - 1 - - 02:CLIENT_FINGERPRINT_HERE - x509c2n:specified - test - - - -
-
-
-
diff --git a/test/mocks/pnfsimulator/netconfsimulator/netconf/yang_loader_server.py b/test/mocks/pnfsimulator/netconfsimulator/netconf/yang_loader_server.py deleted file mode 100644 index 27d46cea5..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/netconf/yang_loader_server.py +++ /dev/null @@ -1,172 +0,0 @@ -### -# ============LICENSE_START======================================================= -# Simulator -# ================================================================================ -# Copyright (C) 2019 Nokia. All rights reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -import logging -import subprocess -import os -from subprocess import check_output, CalledProcessError -from flask import Flask -from flask_restful import Resource, Api, reqparse -from werkzeug.datastructures import FileStorage -import time - -app = Flask(__name__) -api = Api(app) -logger = logging.getLogger("yang-loader") -logger.addHandler(logging.StreamHandler()) -KAFKA_BROKER_NAME="kafka1:9092" -KAFKA_TOPIC_NAME="config" - - -class YangLoaderHelper(object): - - @classmethod - def save_file(cls, yang_model_file: FileStorage) -> str: - path = "/tmp/" + yang_model_file.filename - yang_model_file.save(path) - return path - - @classmethod - def install_new_model(cls, yang_model_path: str): - logger.info("Installing new model: %s", yang_model_path) - command = "sysrepoctl --install --yang={} --owner=netconf:nogroup --permissions=777" \ - .format(yang_model_path) - cls._run_bash_command(command) - - @classmethod - def uninstall_a_model(cls, yang_model_name: str): - logger.info("Uninstalling a model: %s", yang_model_name) - command = "sysrepoctl --uninstall --module={}" \ - .format(yang_model_name) - cls._run_bash_command(command) - - - @classmethod - def set_default_configuration(cls, init_conf_path: str, module_name: str): - logger.info("Attempting to set default configuration %s for module %s", init_conf_path, module_name) - command = "sysrepocfg --import={} --datastore=startup --format=xml --level=3 {}" \ - .format(init_conf_path, module_name) - cls._run_bash_command(command) - - @classmethod - def start_change_listener_for_model(cls, module_name: str): - logger.info("Starting listener for model: %s", module_name) - command = "python /netconf/netopeer_change_saver.py {} {} {}" \ - .format(module_name, KAFKA_BROKER_NAME, KAFKA_TOPIC_NAME) - try: - check_output(["pgrep", "-f" , command], stderr=subprocess.STDOUT, universal_newlines=True) - logger.info("Change listener for {} already exist.".format(module_name)) - except CalledProcessError: - subprocess.Popen(command.split(), stdout=subprocess.PIPE) - - @classmethod - def stop_change_listener_for_model(cls, model_name): - logger.info("Stopping listener for model %s", model_name) - pid = cls.get_pid_by_name(model_name) - logger.info("pid is %s", pid) - command = "kill -2 {}".format(pid) - cls._run_bash_command(command) - - @classmethod - def _run_bash_command(cls, command: str): - try: - logger.info("Attempts to invoke %s", command) - output = check_output(command.split(), stderr=subprocess.STDOUT, - universal_newlines=True) - logger.info("Output: %s", output) - if "ERR" in output: - raise RuntimeError(str(output)) - except subprocess.CalledProcessError as e: - raise RuntimeError(e, str(e.stdout)) - - @classmethod - def get_pid_by_name(cls, name): - for dirname in os.listdir('/proc'): - if not dirname.isdigit(): - continue - try: - with open('/proc/{}/cmdline'.format(dirname), mode='rb') as fd: - content = fd.read().decode().split('\x00') - except Exception as e: - print(e) - continue - - if name in content: - return dirname - - -class YangModelServer(Resource): - logger = logging.getLogger('YangModelServer') - - def __init__(self, yang_loader_helper: YangLoaderHelper = YangLoaderHelper()): - self._yang_loader_helper = yang_loader_helper - - def post(self): - args = self._parse_request() - yang_model_file = args['yangModel'] - initial_config_file = args['initialConfig'] - module_name = args['moduleName'] - model_path = self._yang_loader_helper.save_file(yang_model_file) - conf_path = self._yang_loader_helper.save_file(initial_config_file) - - try: - self._yang_loader_helper.install_new_model(model_path) - self._yang_loader_helper.set_default_configuration(conf_path, - module_name) - self._yang_loader_helper.start_change_listener_for_model(module_name) - except RuntimeError as e: - self.logger.error(e.args, exc_info=True) - return str(e.args), 400 - return "Successfully started" - - def delete(self): - args = self._parse_request() - yang_model_name = args['yangModelName'] - - try: - self._yang_loader_helper.stop_change_listener_for_model(yang_model_name) - time.sleep(5) - self._yang_loader_helper.uninstall_a_model(yang_model_name) - except RuntimeError as e: - self.logger.error(e.args, exc_info=True) - return str(e.args), 400 - return "Successfully deleted" - - @classmethod - def _parse_request(cls) -> reqparse.Namespace: - parse = reqparse.RequestParser() - parse.add_argument('yangModel', - type=FileStorage, - location='files') - parse.add_argument('initialConfig', - type=FileStorage, - location='files') - parse.add_argument('moduleName', type=str) - parse.add_argument('yangModelName', type=str) - return parse.parse_args() - - -api.add_resource(YangModelServer, '/model') - -if __name__ == '__main__': - logging.basicConfig(filename=os.path.dirname(__file__) + "/yang_loader.log", - filemode="w", - level=logging.DEBUG) - app.run(host='0.0.0.0', port='5002') diff --git a/test/mocks/pnfsimulator/netconfsimulator/pom.xml b/test/mocks/pnfsimulator/netconfsimulator/pom.xml deleted file mode 100644 index d5d7157da..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/pom.xml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - 4.0.0 - - - org.onap.simulator - simulator-parent - 5.0.0-SNAPSHOT - - - netconfsimulator - 5.0.0-SNAPSHOT - - - UTF-8 - 1.8 - 1.8 - yyyyMMdd'T'HHmmss - nexus3.onap.org:10003 - latest - onap/${project.artifactId} - 2.1.6.RELEASE - 2.2.7.RELEASE - 4.5.6 - libs - ${project.build.directory}/${dependency.directory.name} - - netopeer-change-saver - ${project.basedir}/netopeer-change-saver-native - ${project.build.directory}/cmake - ${netopeer-saver-build-dir}/bin - true - "" - - - - - org.springframework.boot - spring-boot-starter - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - - - org.projectlombok - lombok - 1.18.2 - provided - - - org.onosproject - jnc - 1.0 - - - org.springframework.boot - spring-boot-starter-websocket - ${spring.boot.version} - - - javax.websocket - javax.websocket-api - 1.1 - - - - - - org.springframework.kafka - spring-kafka - ${spring.kafka.version} - - - - - - org.assertj - assertj-core - 3.9.1 - test - - - org.mockito - mockito-core - 2.18.3 - test - - - org.junit.jupiter - junit-jupiter-engine - 5.3.1 - test - - - org.junit.vintage - junit-vintage-engine - 5.3.1 - test - - - junit - junit - 4.12 - test - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - test - - - org.springframework.kafka - spring-kafka-test - ${spring.kafka.version} - test - - - org.bitbucket.radistao.test - before-after-spring-test-runner - 0.1.0 - test - - - com.palantir.docker.compose - docker-compose-rule-junit4 - 0.29.1 - test - - - org.apache.httpcomponents - httpclient - 4.5.6 - test - - - org.apache.httpcomponents - httpmime - 4.5.6 - test - - - org.apache.httpcomponents - httpclient - ${apache.httpclient.version} - - - org.apache.httpcomponents - httpmime - ${apache.httpclient.version} - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - ${dependency.directory.location} - runtime - true - - - - copy-external-dependencies - package - - copy-dependencies - - - - - - maven-surefire-plugin - 2.19 - - - org.junit.platform - junit-platform-surefire-provider - 1.1.1 - - - - true - true - false - - - - org.apache.maven.plugins - maven-failsafe-plugin - 2.19.1 - - ${skipITs} - - - - - integration-test - verify - - - - - - io.fabric8 - docker-maven-plugin - 0.31.0 - - - build-images - - push - - - - - - - ${docker.registry}/${docker.image.name} - - ${project.basedir} - ${project.basedir}/Dockerfile_app - - - - ${docker.registry}/netopeer - - ${project.basedir} - ${project.basedir}/Dockerfile_netopeer - - ${proxy} - - - - - - - - - - - Palantir - https://dl.bintray.com/palantir/releases/ - - - diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Configuration.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Configuration.java deleted file mode 100644 index 92e5b2327..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Configuration.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator; - -import org.apache.http.client.HttpClient; -import org.apache.http.impl.client.HttpClientBuilder; -import org.springframework.context.annotation.Bean; - -@org.springframework.context.annotation.Configuration -public class Configuration { - - @Bean - public HttpClient httpClient() { - return HttpClientBuilder.create().build(); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Main.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Main.java deleted file mode 100644 index e2a0ed0c0..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/Main.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.netconfsimulator; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class Main { - - public static void main(String[] args) { - SpringApplication.run(Main.class, args); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/SwaggerConfig.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/SwaggerConfig.java deleted file mode 100644 index 2e9df997e..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/SwaggerConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@EnableSwagger2 -@Configuration -class SwaggerConfig { - - @Bean - Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.onap.netconfsimulator")) - .paths(PathSelectors.any()) - .build(); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/Config.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/Config.java deleted file mode 100644 index 9ae564103..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/Config.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.kafka.clients.consumer.ConsumerConfig; -import org.apache.kafka.common.serialization.StringDeserializer; -import org.onap.netconfsimulator.kafka.listener.KafkaListenerHandler; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.kafka.annotation.EnableKafka; -import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; -import org.springframework.kafka.core.ConsumerFactory; -import org.springframework.kafka.core.DefaultKafkaConsumerFactory; - -@Configuration -@EnableKafka -class Config { - - @Value("${spring.kafka.bootstrap-servers}") - private String bootstrapServer; - - @Value("${spring.kafka.consumer.auto-offset-reset}") - private String offsetReset; - - @Bean - ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory(ConsumerFactory consumerFactory) { - ConcurrentKafkaListenerContainerFactory containerFactory = new ConcurrentKafkaListenerContainerFactory<>(); - containerFactory.setConsumerFactory(consumerFactory); - return containerFactory; - } - - @Bean - ConsumerFactory consumerFactory() { - Map props = new HashMap<>(); - props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapServer); - props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); - props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); - props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, offsetReset); - return new DefaultKafkaConsumerFactory<>(props); - } - - - @Bean - KafkaListenerHandler kafkaListenerHandler(ConsumerFactory consumerFactory) { - return new KafkaListenerHandler(consumerFactory); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/MessageDTO.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/MessageDTO.java deleted file mode 100644 index 4311cd61f..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/MessageDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -class MessageDTO { - private long timestamp; - private String configuration; -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreController.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreController.java deleted file mode 100644 index 33bbdf7cf..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreController.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - -import java.util.List; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Slf4j -@RequestMapping("/store") -public class StoreController { - - private StoreService service; - - @Autowired - public StoreController(StoreService service) { - this.service = service; - } - - @GetMapping("/ping") - String ping() { - return "pong"; - } - - @GetMapping("cm-history") - List getAllConfigurationChanges() { - return service.getAllMessages(); - } - - @GetMapping("/less") - List less(@RequestParam(value = "offset", required = false, defaultValue = "${spring.kafka.default-offset}") long offset) { - return service.getLastMessages(offset); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreService.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreService.java deleted file mode 100644 index 5fddff5a2..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/StoreService.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - -import lombok.extern.slf4j.Slf4j; -import org.apache.kafka.clients.consumer.Consumer; -import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.apache.kafka.common.TopicPartition; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.core.ConsumerFactory; -import org.springframework.stereotype.Service; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Slf4j -@Service -public class StoreService { - - private static final String CONFIG_TOPIC = "config"; - private static final long CONSUMING_DURATION_IN_MS = 1000; - - private ConsumerFactory consumerFactory; - static final List TOPICS_TO_SUBSCRIBE = Collections.singletonList(CONFIG_TOPIC); - - @Autowired - StoreService(ConsumerFactory consumerFactory) { - this.consumerFactory = consumerFactory; - } - - List getAllMessages() { - List messages = new ArrayList<>(); - String clientID = Long.toString(Instant.now().getEpochSecond()); - try (Consumer consumer = consumerFactory.createConsumer(clientID, clientID)) { - consumer.subscribe(TOPICS_TO_SUBSCRIBE); - ConsumerRecords consumerRecords = consumer.poll(CONSUMING_DURATION_IN_MS); - consumerRecords.forEach( - consumerRecord -> - messages.add(new MessageDTO(consumerRecord.timestamp(), consumerRecord.value()))); - log.debug(String.format("consumed %d messages", consumerRecords.count())); - } - return messages; - } - - List getLastMessages(long offset) { - List messages = new ArrayList<>(); - try (Consumer consumer = createConsumer(offset)) { - ConsumerRecords consumerRecords = consumer.poll(CONSUMING_DURATION_IN_MS); - consumerRecords.forEach(consumerRecord -> - messages.add(new MessageDTO(consumerRecord.timestamp(), consumerRecord.value()))); - } - return messages; - } - - private Consumer createConsumer(long offsetFromLastIndex) { - String clientID = Long.toString(Instant.now().getEpochSecond()); - Consumer consumer = consumerFactory.createConsumer(clientID, clientID); - consumer.subscribe(TOPICS_TO_SUBSCRIBE); - seekConsumerTo(consumer, offsetFromLastIndex); - return consumer; - } - - private void seekConsumerTo(Consumer consumer, long offsetFromLastIndex) { - consumer.seekToEnd(consumer.assignment()); - consumer.poll(CONSUMING_DURATION_IN_MS); - TopicPartition topicPartition = consumer.assignment().iterator().next(); - long topicCurrentSize = consumer.position(topicPartition); - long indexToSeek = offsetFromLastIndex > topicCurrentSize ? 0 : topicCurrentSize - offsetFromLastIndex; - consumer.seek(topicPartition, indexToSeek); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerEntry.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerEntry.java deleted file mode 100644 index e3c04c9fc..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerEntry.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka.listener; - -import lombok.Getter; -import org.springframework.kafka.listener.AbstractMessageListenerContainer; - -@Getter -public class KafkaListenerEntry { - - private String clientId; - private AbstractMessageListenerContainer listenerContainer; - - public KafkaListenerEntry(String clientId, AbstractMessageListenerContainer listenerContainer) { - this.clientId = clientId; - this.listenerContainer = listenerContainer; - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandler.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandler.java deleted file mode 100644 index 604315d5f..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandler.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka.listener; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.core.ConsumerFactory; - -import org.springframework.kafka.listener.ContainerProperties; -import org.springframework.kafka.listener.KafkaMessageListenerContainer; -import org.springframework.kafka.listener.MessageListener; - - -import org.springframework.kafka.support.TopicPartitionInitialOffset; - -import java.time.Instant; - -public class KafkaListenerHandler { - - private static final int PARTITION = 0; - private static final long NUMBER_OF_HISTORICAL_MESSAGES_TO_SHOW = -10L; - private static final boolean RELATIVE_TO_CURRENT = false; - private ConsumerFactory consumerFactory; - - - @Autowired - public KafkaListenerHandler(ConsumerFactory consumerFactory) { - this.consumerFactory = consumerFactory; - } - - - public KafkaListenerEntry createKafkaListener(MessageListener messageListener, String topicName) { - String clientId = Long.toString(Instant.now().getEpochSecond()); - ContainerProperties containerProperties = new ContainerProperties(topicName); - containerProperties.setGroupId(clientId); - KafkaMessageListenerContainer listenerContainer = createListenerContainer(containerProperties, - topicName); - - listenerContainer.setupMessageListener(messageListener); - return new KafkaListenerEntry(clientId, listenerContainer); - } - - - KafkaMessageListenerContainer createListenerContainer(ContainerProperties containerProperties, - String topicName) { - TopicPartitionInitialOffset config = new TopicPartitionInitialOffset(topicName, PARTITION, - NUMBER_OF_HISTORICAL_MESSAGES_TO_SHOW, RELATIVE_TO_CURRENT); - return new KafkaMessageListenerContainer<>(consumerFactory, containerProperties, config); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/model/KafkaMessage.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/model/KafkaMessage.java deleted file mode 100644 index 90f283acf..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/kafka/model/KafkaMessage.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka.model; - -import lombok.Getter; - -@Getter -public class KafkaMessage { - private long timestamp; - private String configuration; - - public KafkaMessage(long timestamp, String configuration) { - this.timestamp = timestamp; - this.configuration = configuration; - } - - KafkaMessage() { - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/NetconfController.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/NetconfController.java deleted file mode 100644 index cdb4a8f97..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/NetconfController.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * NETCONF-CONTROLLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore; - -import com.tailf.jnc.JNCException; - -import java.io.IOException; - -import lombok.extern.slf4j.Slf4j; -import org.onap.netconfsimulator.netconfcore.configuration.NetconfConfigurationService; -import org.onap.netconfsimulator.netconfcore.model.LoadModelResponse; -import org.onap.netconfsimulator.netconfcore.model.NetconfModelLoaderService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -@Slf4j -@RestController -@RequestMapping("netconf") -class NetconfController { - - private final NetconfConfigurationService netconfService; - private final NetconfModelLoaderService netconfModelLoaderService; - - @Autowired - NetconfController(NetconfConfigurationService netconfService, - NetconfModelLoaderService netconfModelLoaderService) { - this.netconfService = netconfService; - this.netconfModelLoaderService = netconfModelLoaderService; - } - - @GetMapping(value = "get", produces = "application/xml") - ResponseEntity getNetconfConfiguration() throws IOException, JNCException { - return ResponseEntity.ok(netconfService.getCurrentConfiguration()); - } - - @GetMapping(value = "get/{model}/{container}", produces = "application/xml") - ResponseEntity getNetconfConfiguration(@PathVariable String model, - @PathVariable String container) - throws IOException { - ResponseEntity entity; - try { - entity = ResponseEntity.ok(netconfService.getCurrentConfiguration(model, container)); - } catch (JNCException exception) { - log.error("Get configuration for model {} and container {} failed.", model, container, - exception); - entity = ResponseEntity.badRequest().body(exception.toString()); - } - return entity; - } - - @PostMapping(value = "edit-config", produces = "application/xml") - @ResponseStatus(HttpStatus.ACCEPTED) - ResponseEntity editConfig(@RequestPart("editConfigXml") MultipartFile editConfig) - throws IOException, JNCException { - log.info("Loading updated configuration"); - if (editConfig == null || editConfig.isEmpty()) { - throw new IllegalArgumentException("No XML file with proper name: editConfigXml found."); - } - return ResponseEntity - .status(HttpStatus.ACCEPTED) - .body(netconfService.editCurrentConfiguration(editConfig)); - } - - @PostMapping("model/{moduleName}") - ResponseEntity loadNewYangModel(@RequestBody MultipartFile yangModel, - @RequestBody MultipartFile initialConfig, @PathVariable String moduleName) - throws IOException { - LoadModelResponse response = netconfModelLoaderService.loadYangModel(yangModel, initialConfig, moduleName); - return ResponseEntity - .status(response.getStatusCode()) - .body(response.getMessage()); - } - - @DeleteMapping("model/{modelName}") - ResponseEntity deleteYangModel(@PathVariable String modelName) - throws IOException { - LoadModelResponse response = netconfModelLoaderService.deleteYangModel(modelName); - return ResponseEntity - .status(response.getStatusCode()) - .body(response.getMessage()); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java deleted file mode 100644 index d90c60d58..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfBeanConfiguration.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -class NetconfBeanConfiguration { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetconfBeanConfiguration.class); - - @Value("${netconf.port}") - private Integer netconfPort; - - @Value("${netconf.address}") - private String netconfAddress; - - @Value("${netconf.user}") - private String netconfUser; - - @Value("${netconf.password}") - private String netconfPassword; - - @Bean - NetconfConfigurationReader configurationReader() { - NetconfConnectionParams params = new NetconfConnectionParams(netconfAddress, netconfPort, netconfUser, netconfPassword); - LOGGER.info("Configuration params are : {}", params); - return new NetconfConfigurationReader(params, new NetconfSessionHelper()); - } - - @Bean - NetconfConfigurationEditor configurationEditor() { - NetconfConnectionParams params = - new NetconfConnectionParams(netconfAddress, netconfPort, netconfUser, netconfPassword); - return new NetconfConfigurationEditor(params, new NetconfSessionHelper()); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java deleted file mode 100644 index 992c88d5a..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditor.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import com.tailf.jnc.Element; -import com.tailf.jnc.JNCException; -import com.tailf.jnc.NetconfSession; -import lombok.extern.slf4j.Slf4j; - -import java.io.IOException; - -@Slf4j -public class NetconfConfigurationEditor { - - private NetconfConnectionParams params; - private NetconfSessionHelper netconfSessionHelper; - - public NetconfConfigurationEditor(NetconfConnectionParams params, NetconfSessionHelper netconfSessionHelper) { - this.params = params; - this.netconfSessionHelper = netconfSessionHelper; - } - - void editConfig(Element configurationXmlElement) throws JNCException, IOException { - log.debug("New configuration passed to simulator: {}", configurationXmlElement.toXMLString()); - NetconfSession session = netconfSessionHelper.createNetconfSession(params); - session.editConfig(configurationXmlElement); - session.closeSession(); - - log.info("Successfully updated configuration"); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java deleted file mode 100644 index 10fe40e2f..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReader.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import com.tailf.jnc.JNCException; -import com.tailf.jnc.NetconfSession; -import com.tailf.jnc.NodeSet; -import java.io.IOException; -import java.util.Objects; - -class NetconfConfigurationReader { - - private NetconfConnectionParams params; - private NetconfSessionHelper netconfSessionHelper; - - NetconfConfigurationReader(NetconfConnectionParams params, NetconfSessionHelper netconfSessionHelper) { - this.params = params; - this.netconfSessionHelper = netconfSessionHelper; - } - - String getRunningConfig() throws IOException, JNCException { - NetconfSession session = netconfSessionHelper.createNetconfSession(params); - String config = session.getConfig().toXMLString(); - session.closeSession(); - return config; - } - - String getRunningConfig(String modelPath) throws IOException, JNCException { - NetconfSession session = netconfSessionHelper.createNetconfSession(params); - NodeSet config = session.getConfig(modelPath); - if (Objects.isNull(config) || Objects.isNull(config.first())) { - throw new JNCException(JNCException.ELEMENT_MISSING, modelPath); - } - session.closeSession(); - return config.first().toXMLString(); - } - - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java deleted file mode 100644 index 248aec46a..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationService.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import com.tailf.jnc.Element; -import com.tailf.jnc.JNCException; -import com.tailf.jnc.XMLParser; - -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; -import org.xml.sax.InputSource; - -@Service -public class NetconfConfigurationService { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetconfConfigurationService.class); - private static final String CONFIGURATION_HAS_BEEN_ACTIVATED = "New configuration has been activated"; - - private final NetconfConfigurationReader netconfConfigurationReader; - private NetconfConfigurationEditor configurationEditor; - private XMLParser parser; - - @Autowired - public NetconfConfigurationService(NetconfConfigurationReader netconfConfigurationReader, - NetconfConfigurationEditor netconfConfigurationEditor) throws JNCException { - this.netconfConfigurationReader = netconfConfigurationReader; - this.configurationEditor = netconfConfigurationEditor; - this.parser = new XMLParser(); - } - - public String getCurrentConfiguration() throws IOException, JNCException { - return netconfConfigurationReader.getRunningConfig(); - } - - public String getCurrentConfiguration(String model, String container) throws IOException, JNCException { - String path = String.format("/%s:%s", model, container); - return netconfConfigurationReader.getRunningConfig(path); - } - - public String editCurrentConfiguration(MultipartFile newConfiguration) throws IOException, JNCException { - Element configurationElement = convertMultipartToXmlElement(newConfiguration); - configurationEditor.editConfig(configurationElement); - - LOGGER.debug("Loading new configuration: \n{}", configurationElement.toXMLString()); - return CONFIGURATION_HAS_BEEN_ACTIVATED; - } - - private Element convertMultipartToXmlElement(MultipartFile editConfig) throws IOException, JNCException { - InputSource inputSourceUpdateConfig = new InputSource(new ByteArrayInputStream(editConfig.getBytes())); - return parser.parse(inputSourceUpdateConfig); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java deleted file mode 100644 index e43ff690e..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationTO.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public class NetconfConfigurationTO { - - private String configuration; - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java deleted file mode 100644 index ace0ee04c..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConnectionParams.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.ToString; - -@AllArgsConstructor -@ToString -@Getter -class NetconfConnectionParams { - - private final String address; - private final int port; - private final String user; - private final String password; - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java deleted file mode 100644 index 69fda7d63..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfSessionHelper.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import com.tailf.jnc.JNCException; -import com.tailf.jnc.NetconfSession; -import com.tailf.jnc.SSHConnection; -import com.tailf.jnc.SSHSession; -import java.io.IOException; - -class NetconfSessionHelper { - - NetconfSession createNetconfSession(NetconfConnectionParams params) throws IOException, JNCException { - SSHConnection sshConnection = new SSHConnection(params.getAddress(), params.getPort()); - sshConnection.authenticateWithPassword(params.getUser(), params.getPassword()); - return new NetconfSession(new SSHSession(sshConnection)); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/LoadModelResponse.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/LoadModelResponse.java deleted file mode 100644 index a6e292f62..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/LoadModelResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.model; - -public class LoadModelResponse { - - private Integer statusCode; - private String message; - - public LoadModelResponse(Integer statusCode, String message) { - this.statusCode = statusCode; - this.message = message; - } - - public Integer getStatusCode() { - return this.statusCode; - } - - public String getMessage() { - return this.message; - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderService.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderService.java deleted file mode 100644 index 7e0739579..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderService.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.model; - -import java.io.IOException; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -@Service -public class NetconfModelLoaderService { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetconfModelLoaderService.class); - - @Value("${netconf.address}") - private String netconfIp; - - @Value("${netconf.model-loader.port}") - private String modelLoaderPort; - - private final HttpClient httpClient; - - @Autowired - public NetconfModelLoaderService(HttpClient httpClient) { - this.httpClient = httpClient; - } - - public LoadModelResponse deleteYangModel(String yangModelName) throws IOException { - String uri = getDeleteAddress(yangModelName); - HttpDelete httpDelete = new HttpDelete(uri); - HttpResponse httpResponse = httpClient.execute(httpDelete); - return parseResponse(httpResponse); - } - - public LoadModelResponse loadYangModel(MultipartFile yangModel, MultipartFile initialConfig, String moduleName) - throws IOException { - HttpPost httpPost = new HttpPost(getBackendAddress()); - HttpEntity httpEntity = MultipartEntityBuilder.create() - .addBinaryBody("yangModel", yangModel.getInputStream(), ContentType.MULTIPART_FORM_DATA, - yangModel.getOriginalFilename()) - .addBinaryBody("initialConfig", initialConfig.getInputStream(), ContentType.MULTIPART_FORM_DATA, - initialConfig.getOriginalFilename()) - .addTextBody("moduleName", moduleName) - .build(); - httpPost.setEntity(httpEntity); - HttpResponse response = httpClient.execute(httpPost); - return parseResponse(response); - } - - String getBackendAddress() { - return String.format("http://%s:%s/model", netconfIp, modelLoaderPort); - } - - String getDeleteAddress(String yangModelName) { - return String.format("%s?yangModelName=%s", getBackendAddress(), yangModelName); - } - - - private LoadModelResponse parseResponse(HttpResponse response) throws IOException { - int statusCode = response.getStatusLine().getStatusCode(); - String responseBody = EntityUtils.toString(response.getEntity()); - - logResponse(statusCode, responseBody); - return new LoadModelResponse(statusCode, responseBody); - } - - private void logResponse(int statusCode, String responseBody) { - if (statusCode >= HttpStatus.BAD_REQUEST.value()) { - LOGGER.error(responseBody); - } else { - LOGGER.info(responseBody); - } - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/EndpointConfig.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/EndpointConfig.java deleted file mode 100644 index 4eaa85010..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/EndpointConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.websocket; - -import java.util.Collections; -import org.onap.netconfsimulator.websocket.message.NetconfMessageEncoder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.socket.server.standard.ServerEndpointExporter; -import org.springframework.web.socket.server.standard.ServerEndpointRegistration; - -@Configuration -class EndpointConfig { - - @Bean - ServerEndpointRegistration endpointRegistration() { - ServerEndpointRegistration serverEndpointRegistration = new ServerEndpointRegistration("/netconf", - NetconfEndpoint.class); - serverEndpointRegistration.setEncoders(Collections.singletonList(NetconfMessageEncoder.class)); - return serverEndpointRegistration; - } - - @Bean - ServerEndpointExporter endpointExporter() { - return new ServerEndpointExporter(); - } -} - diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/NetconfEndpoint.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/NetconfEndpoint.java deleted file mode 100644 index 5870ee1e4..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/NetconfEndpoint.java +++ /dev/null @@ -1,95 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.websocket; - - -import java.util.Optional; -import javax.websocket.CloseReason; -import javax.websocket.Endpoint; -import javax.websocket.EndpointConfig; -import javax.websocket.RemoteEndpoint; -import javax.websocket.Session; - -import org.onap.netconfsimulator.kafka.listener.KafkaListenerEntry; -import org.onap.netconfsimulator.kafka.listener.KafkaListenerHandler; -import org.onap.netconfsimulator.websocket.message.NetconfMessageListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.listener.AbstractMessageListenerContainer; -import org.springframework.kafka.listener.MessageListener; -import org.springframework.stereotype.Component; - -//instance of this class is created every each websocket request -@Component -class NetconfEndpoint extends Endpoint { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetconfEndpoint.class); - private static final String TOPIC_NAME = "config"; - - private KafkaListenerHandler kafkaListenerHandler; - - public Optional getEntry() { - return entry; - } - - public void setEntry(Optional entry) { - this.entry = entry; - } - - private Optional entry = Optional.empty(); - - - @Autowired - NetconfEndpoint(KafkaListenerHandler listenerHandler) { - this.kafkaListenerHandler = listenerHandler; - } - - @Override - public void onOpen(Session session, EndpointConfig endpointConfig) { - RemoteEndpoint.Basic basicRemote = session.getBasicRemote(); - - addKafkaListener(basicRemote); - entry.ifPresent(x -> LOGGER.info("Session with client: {} established", x.getClientId())); - } - - @Override - public void onError(Session session, Throwable throwable) { - LOGGER.error("Unexpected error occurred", throwable); - } - - @Override - public void onClose(Session session, CloseReason closeReason) { - entry.ifPresent(x -> x.getListenerContainer().stop()); - entry.ifPresent(x -> LOGGER.info("Closing connection for client: {}", x.getClientId())); - } - - - private void addKafkaListener(RemoteEndpoint.Basic remoteEndpoint) { - MessageListener messageListener = new NetconfMessageListener(remoteEndpoint); - - KafkaListenerEntry kafkaListener = kafkaListenerHandler.createKafkaListener(messageListener, TOPIC_NAME); - - AbstractMessageListenerContainer listenerContainer = kafkaListener.getListenerContainer(); - listenerContainer.start(); - entry = Optional.of(kafkaListener); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageEncoder.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageEncoder.java deleted file mode 100644 index 349b7e2d9..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageEncoder.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.websocket.message; - -import org.onap.netconfsimulator.kafka.model.KafkaMessage; -import org.springframework.web.socket.adapter.standard.ConvertingEncoderDecoderSupport; - -public class NetconfMessageEncoder extends ConvertingEncoderDecoderSupport.TextEncoder { - - private static final String MESSAGE_FORMAT = "%s: %s"; - - @Override - public String encode(KafkaMessage netconfMessage) { - return String.format(MESSAGE_FORMAT, netconfMessage.getTimestamp(), netconfMessage.getConfiguration()); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListener.java b/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListener.java deleted file mode 100644 index 61610dea0..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.websocket.message; - -import java.io.IOException; -import javax.websocket.EncodeException; -import javax.websocket.RemoteEndpoint; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.onap.netconfsimulator.kafka.model.KafkaMessage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.kafka.listener.MessageListener; - -public class NetconfMessageListener implements MessageListener { - - private static final Logger LOGGER = LoggerFactory.getLogger(NetconfMessageListener.class); - private RemoteEndpoint.Basic remoteEndpoint; - - public NetconfMessageListener(RemoteEndpoint.Basic remoteEndpoint) { - this.remoteEndpoint = remoteEndpoint; - } - - @Override - public void onMessage(ConsumerRecord message) { - LOGGER.debug("Attempting to send message to {}", remoteEndpoint); - try { - remoteEndpoint - .sendObject(new KafkaMessage(message.timestamp(), message.value())); - } catch (IOException | EncodeException exception) { - LOGGER.error("Error during sending message to remote", exception); - } - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/main/resources/application.properties b/test/mocks/pnfsimulator/netconfsimulator/src/main/resources/application.properties deleted file mode 100644 index 3947cf358..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/main/resources/application.properties +++ /dev/null @@ -1,8 +0,0 @@ -netconf.port=830 -netconf.address=netopeer -netconf.user=netconf -netconf.password=netconf -netconf.model-loader.port=5002 -spring.kafka.bootstrap-servers=kafka1:9092 -spring.kafka.default-offset=100 -spring.kafka.consumer.auto-offset-reset=earliest diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfFunctionsIT.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfFunctionsIT.java deleted file mode 100644 index 95ef58696..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfFunctionsIT.java +++ /dev/null @@ -1,211 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package integration; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.palantir.docker.compose.connection.DockerMachine; -import com.palantir.docker.compose.connection.waiting.HealthChecks; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.bitbucket.radistao.test.annotation.BeforeAllMethods; -import org.bitbucket.radistao.test.runner.BeforeAfterSpringTestRunner; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.RunWith; -import com.palantir.docker.compose.DockerComposeRule; -import org.onap.netconfsimulator.kafka.model.KafkaMessage; -import org.springframework.http.HttpStatus; - -import java.io.IOException; - -import java.time.Duration; -import java.time.Instant; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import static junit.framework.TestCase.fail; -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(BeforeAfterSpringTestRunner.class) -public class NetconfFunctionsIT { - - private static NetconfSimulatorClient client; - private static ObjectMapper objectMapper; - - private static final DockerMachine dockerMachine = DockerMachine - .localMachine() - .build(); - - private static DockerComposeRule docker = DockerComposeRule.builder() - .file("docker-compose.yml") - .machine(dockerMachine) - .removeConflictingContainersOnStartup(true) - .waitingForService("sftp-server", HealthChecks.toHaveAllPortsOpen()) - .waitingForService("ftpes-server", HealthChecks.toHaveAllPortsOpen()) - .waitingForService("zookeeper", HealthChecks.toHaveAllPortsOpen()) - .waitingForService("netopeer", HealthChecks.toHaveAllPortsOpen()) - .waitingForService("kafka1", HealthChecks.toHaveAllPortsOpen()) - .waitingForService("netconf-simulator", HealthChecks.toHaveAllPortsOpen()) - .build(); - - @ClassRule - public static TestRule exposePortMappings = docker; - - @BeforeClass - public static void setUpClass() { - objectMapper = new ObjectMapper(); - client = new NetconfSimulatorClient(String.format("http://%s:%d", docker.containers().ip(), 9000)); - } - - @BeforeAllMethods - public void setupBeforeAll() throws InterruptedException { - if (client.isServiceAvailable(Instant.now(), Duration.ofSeconds(45))) { - Thread.sleep(60000); - return; - } - fail("Application failed to start within established timeout: 45 seconds. Exiting."); - } - - @Before - public void setUp() { - client.reinitializeClient(); - } - - @After - public void tearDown() throws Exception { - client.releaseClient(); - } - - @Test - public void testShouldLoadModelEditConfigurationAndDeleteModule() throws IOException { - // do load - try (CloseableHttpResponse response = client - .loadModel("newyangmodel", "newYangModel.yang", "initialConfig.xml")) { - assertResponseStatusCode(response, HttpStatus.OK); - String original = client.getResponseContentAsString(response); - assertThat(original).isEqualTo("\"Successfully started\"\n"); - } - // do edit-config - try (CloseableHttpResponse updateResponse = client.updateConfig()) { - String afterUpdateConfigContent = client.getResponseContentAsString(updateResponse); - assertResponseStatusCode(updateResponse, HttpStatus.ACCEPTED); - assertThat(afterUpdateConfigContent).isEqualTo("New configuration has been activated"); - } - // do delete - try (CloseableHttpResponse deleteResponse = client.deleteModel("newyangmodel")) { - assertResponseStatusCode(deleteResponse, HttpStatus.OK); - String original = client.getResponseContentAsString(deleteResponse); - assertThat(original).isEqualTo("\"Successfully deleted\"\n"); - } - } - - @Test - public void testShouldGetCurrentConfigurationAndEditItSuccessfully() throws IOException { - try (CloseableHttpResponse updateResponse = client.updateConfig(); - CloseableHttpResponse newCurrentConfigResponse = client.getCurrentConfig()) { - String afterUpdateConfigContent = client.getResponseContentAsString(updateResponse); - - assertResponseStatusCode(updateResponse, HttpStatus.ACCEPTED); - assertResponseStatusCode(newCurrentConfigResponse, HttpStatus.OK); - - assertThat(afterUpdateConfigContent).isEqualTo("New configuration has been activated"); - } - } - - @Test - public void testShouldPersistConfigChangesAndGetAllWhenRequested() throws IOException { - client.updateConfig(); - - try (CloseableHttpResponse newAllConfigChangesResponse = client.getAllConfigChanges()) { - String newAllConfigChangesString = client.getResponseContentAsString(newAllConfigChangesResponse); - assertResponseStatusCode(newAllConfigChangesResponse, HttpStatus.OK); - - List kafkaMessages = objectMapper - .readValue(newAllConfigChangesString, new TypeReference>() { - }); - - assertThat(kafkaMessages.size()).isGreaterThanOrEqualTo(1); - Set configChangeContent = kafkaMessages.stream().map(KafkaMessage::getConfiguration) - .collect(Collectors.toSet()); - assertThat(configChangeContent) - .anyMatch(el -> el.contains("new value: /pnf-simulator:config/itemValue1 = 100")); - assertThat(configChangeContent) - .anyMatch(el -> el.contains("new value: /pnf-simulator:config/itemValue2 = 200")); - } - } - - @Test - public void testShouldGetLastMessage() throws IOException { - client.updateConfig(); - - try (CloseableHttpResponse lastConfigChangesResponse = client.getLastConfigChanges(2)) { - String newAllConfigChangesString = client.getResponseContentAsString(lastConfigChangesResponse); - List kafkaMessages = objectMapper - .readValue(newAllConfigChangesString, new TypeReference>() { - }); - - assertThat(kafkaMessages).hasSize(2); - assertThat(kafkaMessages.get(0).getConfiguration()) - .contains("new value: /pnf-simulator:config/itemValue1 = 100"); - assertThat(kafkaMessages.get(1).getConfiguration()) - .contains("new value: /pnf-simulator:config/itemValue2 = 200"); - } - } - - @Test - public void testShouldLoadNewYangModelAndReconfigure() throws IOException { - try (CloseableHttpResponse response = client - .loadModel("newyangmodel", "newYangModel.yang", "initialConfig.xml")) { - assertResponseStatusCode(response, HttpStatus.OK); - - String original = client.getResponseContentAsString(response); - - assertThat(original).isEqualTo("\"Successfully started\"\n"); - } - } - - @Test - public void shouldGetLoadedModelByName() throws IOException { - testShouldLoadNewYangModelAndReconfigure(); - - try (CloseableHttpResponse response = client.getConfigByModelAndContainerNames("newyangmodel", "config2")) { - assertResponseStatusCode(response, HttpStatus.OK); - String config = client.getResponseContentAsString(response); - - assertThat(config).isEqualTo( - "\n" - + " 100\n" - + "\n"); - } - - } - - private void assertResponseStatusCode(HttpResponse response, HttpStatus expectedStatus) { - assertThat(response.getStatusLine().getStatusCode()).isEqualTo(expectedStatus.value()); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfSimulatorClient.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfSimulatorClient.java deleted file mode 100644 index 61f2ef1d8..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/integration/NetconfSimulatorClient.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package integration; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.junit.platform.commons.logging.Logger; -import org.junit.platform.commons.logging.LoggerFactory; -import org.springframework.util.ResourceUtils; - -import java.io.IOException; -import java.time.Duration; -import java.time.Instant; - -class NetconfSimulatorClient { - - private CloseableHttpClient netconfClient; - private String simulatorBaseUrl; - private static final Logger LOG = LoggerFactory.getLogger(NetconfSimulatorClient.class); - - NetconfSimulatorClient(String simulatorBaseUrl) { - this.netconfClient = HttpClients.createDefault(); - this.simulatorBaseUrl = simulatorBaseUrl; - } - - CloseableHttpResponse loadModel(String moduleName, String yangModelFileName, String initialiConfigFileName) throws IOException { - String updateConfigUrl = String.format("%s/netconf/model/%s", simulatorBaseUrl, moduleName); - HttpPost httpPost = new HttpPost(updateConfigUrl); - HttpEntity updatedConfig = MultipartEntityBuilder - .create() - .addBinaryBody("yangModel", ResourceUtils.getFile(String.format("classpath:%s", yangModelFileName))) - .addBinaryBody("initialConfig", ResourceUtils.getFile(String.format("classpath:%s",initialiConfigFileName))) - .addTextBody("moduleName", moduleName) - .build(); - httpPost.setEntity(updatedConfig); - return netconfClient.execute(httpPost); - } - - CloseableHttpResponse deleteModel(String moduleName) throws IOException { - String deleteModuleUrl = String.format("%s/netconf/model/%s", simulatorBaseUrl, moduleName); - HttpDelete httpDelete = new HttpDelete(deleteModuleUrl); - return netconfClient.execute(httpDelete); - } - - boolean isServiceAvailable(Instant startTime, Duration maxWaitingDuration) throws InterruptedException { - boolean isServiceReady = false; - while (Duration.between(startTime, Instant.now()).compareTo(maxWaitingDuration) < 1){ - if(checkIfSimResponds()){ - return true; - } - else { - LOG.info(() -> "Simulator not ready yet, retrying in 5s..."); - Thread.sleep(5000); - } - } - return isServiceReady; - } - - private boolean checkIfSimResponds() throws InterruptedException { - try(CloseableHttpResponse pingResponse = getCurrentConfig()){ - String responseString = getResponseContentAsString(pingResponse); - if(pingResponse.getStatusLine().getStatusCode() == 200 && !responseString.trim().isEmpty()){ - return true; - } - } - catch(IOException ex){ - LOG.error(ex, () -> "EXCEPTION"); - Thread.sleep(5000); - } - return false; - } - - CloseableHttpResponse getCurrentConfig() throws IOException { - String netconfAddress = String.format("%s/netconf/get", simulatorBaseUrl); - HttpGet get = new HttpGet(netconfAddress); - return netconfClient.execute(get); - } - - CloseableHttpResponse getConfigByModelAndContainerNames(String model, String container) throws IOException { - String netconfAddress = String - .format("%s/netconf/get/%s/%s", simulatorBaseUrl, model, container); - HttpGet get = new HttpGet(netconfAddress); - return netconfClient.execute(get); - } - - CloseableHttpResponse updateConfig() throws IOException { - String updateConfigUrl = String.format("%s/netconf/edit-config", simulatorBaseUrl); - HttpPost httpPost = new HttpPost(updateConfigUrl); - HttpEntity updatedConfig = MultipartEntityBuilder - .create() - .addBinaryBody("editConfigXml", ResourceUtils.getFile("classpath:updatedConfig.xml")) - .build(); - httpPost.setEntity(updatedConfig); - return netconfClient.execute(httpPost); - } - - CloseableHttpResponse getAllConfigChanges() throws IOException { - String netconfStoreCmHistoryAddress = String.format("%s/store/cm-history", simulatorBaseUrl); - HttpGet configurationChangesResponse = new HttpGet(netconfStoreCmHistoryAddress); - return netconfClient.execute(configurationChangesResponse); - } - - CloseableHttpResponse getLastConfigChanges(int howManyLastChanges) throws IOException { - String netconfStoreCmHistoryAddress = String.format("%s/store/less?offset=%d", simulatorBaseUrl, howManyLastChanges); - HttpGet configurationChangesResponse = new HttpGet(netconfStoreCmHistoryAddress); - return netconfClient.execute(configurationChangesResponse); - } - - void releaseClient() throws IOException { - netconfClient.close(); - } - - void reinitializeClient(){ - netconfClient = HttpClients.createDefault(); - } - - String getResponseContentAsString(HttpResponse response) throws IOException { - HttpEntity entity = response.getEntity(); - String entityStringRepr = EntityUtils.toString(entity); - EntityUtils.consume(entity); - return entityStringRepr; - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/EmbeddedKafkaConfig.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/EmbeddedKafkaConfig.java deleted file mode 100644 index 5ddf2b2a6..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/EmbeddedKafkaConfig.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - - -import java.util.Map; -import org.apache.kafka.clients.consumer.ConsumerConfig; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; -import org.springframework.kafka.core.ConsumerFactory; -import org.springframework.kafka.core.DefaultKafkaConsumerFactory; -import org.springframework.kafka.core.DefaultKafkaProducerFactory; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.core.ProducerFactory; -import org.springframework.kafka.test.utils.KafkaTestUtils; - -import static org.onap.netconfsimulator.kafka.StoreServiceTest.embeddedKafka; - -@Configuration -class EmbeddedKafkaConfig { - - @Bean - KafkaTemplate kafkaTemplate(){ - return new KafkaTemplate<>(producerFactory()); - } - - @Bean - @Autowired - ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory(ConsumerFactory consumerFactory){ - ConcurrentKafkaListenerContainerFactory containerFactory = new ConcurrentKafkaListenerContainerFactory<>(); - containerFactory.setConsumerFactory(consumerFactory); - return containerFactory; - } - - @Bean - ConsumerFactory consumerFactory(){ - Map consumerProperties = - KafkaTestUtils.consumerProps("sender", "false", embeddedKafka.getEmbeddedKafka()); - consumerProperties.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest"); - return new DefaultKafkaConsumerFactory<>(consumerProperties); - } - - private ProducerFactory producerFactory() { - Map senderProperties = - KafkaTestUtils.senderProps(embeddedKafka.getEmbeddedKafka().getBrokersAsString()); - return new DefaultKafkaProducerFactory<>(senderProperties); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreControllerTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreControllerTest.java deleted file mode 100644 index 02eec12ac..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreControllerTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - -import java.time.Instant; -import java.util.List; -import org.assertj.core.api.Assertions; -import org.assertj.core.util.Lists; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import static org.mockito.Mockito.when; - -@RunWith(SpringJUnit4ClassRunner.class) -public class StoreControllerTest { - - private static final String MESSAGE_3 = "message 3"; - private static final String MESSAGE_2 = "message 2"; - private static final String MESSAGE_1 = "message 1"; - - private static final List ALL_MESSAGES = Lists.newArrayList(new MessageDTO(Instant.now().getEpochSecond(), MESSAGE_1), - new MessageDTO(Instant.now().getEpochSecond(), MESSAGE_2), - new MessageDTO(Instant.now().getEpochSecond(), MESSAGE_3)); - - @Mock - private StoreService service; - - @InjectMocks - private StoreController storeController; - - - @Test - public void lessShouldTakeAllMessagesTest() { - when(service.getLastMessages(3)).thenReturn(ALL_MESSAGES); - - List lessResponse = storeController.less(3); - - assertResponseContainsExpectedMessages(lessResponse, 3, MESSAGE_1, MESSAGE_2, MESSAGE_3); - } - - @Test - public void lessShouldTakeTwoMessagesTest() { - when(service.getLastMessages(2)).thenReturn(Lists.newArrayList(new MessageDTO(Instant.now().getEpochSecond(), MESSAGE_1))); - - List lessResult = storeController.less(2); - - assertResponseContainsExpectedMessages(lessResult, 1, MESSAGE_1); - } - - @Test - public void shouldGetAllMessages(){ - when(service.getAllMessages()).thenReturn(ALL_MESSAGES); - - List allMsgResult = storeController.getAllConfigurationChanges(); - - assertResponseContainsExpectedMessages(allMsgResult, 3, MESSAGE_1, MESSAGE_2, MESSAGE_3); - } - - private void assertResponseContainsExpectedMessages(List actualMessages, int expectedMessageCount, String... expectedMessages){ - Assertions.assertThat(actualMessages.stream().map(MessageDTO::getConfiguration)) - .hasSize(expectedMessageCount) - .containsExactly(expectedMessages); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreServiceTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreServiceTest.java deleted file mode 100644 index fd36116a8..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/StoreServiceTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka; - -import org.bitbucket.radistao.test.annotation.BeforeAllMethods; -import org.bitbucket.radistao.test.runner.BeforeAfterSpringTestRunner; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.test.context.EmbeddedKafka; -import org.springframework.kafka.test.rule.EmbeddedKafkaRule; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(BeforeAfterSpringTestRunner.class) -@SpringBootTest(classes = {StoreService.class, EmbeddedKafkaConfig.class}) -@EmbeddedKafka -public class StoreServiceTest { - - private static final String MESSAGE_1 = "message1"; - private static final String MESSAGE_2 = "message2"; - private static final String MESSAGE_3 = "message3"; - - @ClassRule - public static EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, true, 1, "config"); - - @Autowired - StoreService service; - - @Autowired - KafkaTemplate kafkaTemplate; - - @BeforeAllMethods - public void setupBeforeAll() { - prepareProducer(); - } - - @Test - public void testShouldReturnAllAvailableMessages(){ - - List actualMessages = service.getAllMessages(); - - assertResponseContainsExpectedMessages(actualMessages, 3, MESSAGE_1, MESSAGE_2, MESSAGE_3); - } - - @Test - public void testShouldGetLastMessagesRespectingOffset(){ - - List wantedLastMsg = service.getLastMessages(1L); - - assertResponseContainsExpectedMessages(wantedLastMsg, 1, MESSAGE_3); - } - - @Test - public void testShouldGetAll3Messages() { - List wantedLastMsgs = service.getLastMessages(3L); - - assertResponseContainsExpectedMessages(wantedLastMsgs, 3, MESSAGE_1, MESSAGE_2, MESSAGE_3); - } - - private void prepareProducer(){ - kafkaTemplate.send("config", "message1"); - kafkaTemplate.send("config", "message2"); - kafkaTemplate.send("config", "message3"); - } - - private void assertResponseContainsExpectedMessages(List actualMessages, int expectedMessageCount, String... expectedMessages){ - assertThat(actualMessages.stream().map(MessageDTO::getConfiguration)) - .hasSize(expectedMessageCount) - .containsExactly(expectedMessages); - } - -} - - - - - - - diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandlerTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandlerTest.java deleted file mode 100644 index fcb72666a..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/kafka/listener/KafkaListenerHandlerTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.kafka.listener; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.MockitoAnnotations.initMocks; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.springframework.kafka.core.ConsumerFactory; -import org.springframework.kafka.listener.ContainerProperties; -import org.springframework.kafka.listener.KafkaMessageListenerContainer; -import org.springframework.kafka.listener.MessageListener; - -class KafkaListenerHandlerTest { - - private static final String CLIENT_ID_REGEX = "[0-9]{10,}"; - private static final String SAMPLE_TOPIC = "sampleTopic"; - - @Mock - private ConsumerFactory consumerFactory; - - @Mock - private KafkaMessageListenerContainer kafkaMessageListenerContainer; - - @Mock - private MessageListener messageListener; - - @BeforeEach - void setUp() { - initMocks(this); - } - - - @Test - void shouldProperlyCreateKafkaListener() { - KafkaListenerHandler kafkaListenerHandler = spy(new KafkaListenerHandler(consumerFactory)); - doReturn(kafkaMessageListenerContainer).when(kafkaListenerHandler) - .createListenerContainer(any(ContainerProperties.class), eq(SAMPLE_TOPIC)); - - KafkaListenerEntry kafkaListenerEntry = kafkaListenerHandler - .createKafkaListener(messageListener, SAMPLE_TOPIC); - - assertThat(kafkaListenerEntry.getListenerContainer()).isEqualTo(kafkaMessageListenerContainer); - assertThat(kafkaListenerEntry.getClientId()).matches(CLIENT_ID_REGEX); - } - - @Test - void shouldProperlyCreateContainer() { - KafkaListenerHandler kafkaListenerHandler = spy(new KafkaListenerHandler(consumerFactory)); - ContainerProperties containerProperties = new ContainerProperties(SAMPLE_TOPIC); - containerProperties.setMessageListener(mock(MessageListener.class)); - - KafkaMessageListenerContainer listenerContainer = kafkaListenerHandler - .createListenerContainer(containerProperties, SAMPLE_TOPIC); - - ContainerProperties actualProperties = listenerContainer.getContainerProperties(); - assertThat(actualProperties.getTopics()).isEqualTo(containerProperties.getTopics()); - assertThat(actualProperties.getMessageListener()).isEqualTo(containerProperties.getMessageListener()); - } - - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/NetconfControllerTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/NetconfControllerTest.java deleted file mode 100644 index 73fb627ea..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/NetconfControllerTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import com.tailf.jnc.JNCException; -import java.io.IOException; -import java.nio.file.Files; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.netconfsimulator.netconfcore.configuration.NetconfConfigurationService; -import org.onap.netconfsimulator.netconfcore.model.LoadModelResponse; -import org.onap.netconfsimulator.netconfcore.model.NetconfModelLoaderService; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.util.ResourceUtils; -import org.springframework.web.multipart.MultipartFile; - -class NetconfControllerTest { - - private MockMvc mockMvc; - - @Mock - private NetconfConfigurationService netconfService; - - @Mock - private NetconfModelLoaderService netconfModelLoaderService; - - @InjectMocks - private NetconfController controller; - - private static final String SAMPLE_CONFIGURATION = "1122"; - - @BeforeEach - void setUp() { - initMocks(this); - mockMvc = MockMvcBuilders.standaloneSetup(controller).build(); - } - - @Test - void testShouldDigestMultipartFile() throws Exception { - byte[] bytes = - Files.readAllBytes(ResourceUtils.getFile("classpath:updatedConfig.xml").toPath()); - MockMultipartFile file = new MockMultipartFile("editConfigXml", bytes); - - mockMvc - .perform(MockMvcRequestBuilders.multipart("/netconf/edit-config").file(file)) - .andExpect(status().isAccepted()); - - verify(netconfService).editCurrentConfiguration(any(MultipartFile.class)); - } - - @Test - void testShouldThrowExceptionWhenEditConfigFileWithIncorrectNameProvided() throws Exception { - MockMultipartFile file = new MockMultipartFile("wrongName", new byte[0]); - - mockMvc - .perform(MockMvcRequestBuilders.multipart("/netconf/edit-config").file(file)) - .andExpect(status().isBadRequest()); - - verify(netconfService, never()).editCurrentConfiguration(any(MultipartFile.class)); - } - - @Test - void testShouldReturnCurrentConfiguration() throws Exception { - when(netconfService.getCurrentConfiguration()).thenReturn(SAMPLE_CONFIGURATION); - - String contentAsString = - mockMvc - .perform(get("/netconf/get")) - .andExpect(status().isOk()) - .andReturn() - .getResponse() - .getContentAsString(); - - verify(netconfService).getCurrentConfiguration(); - assertThat(contentAsString).isEqualTo(SAMPLE_CONFIGURATION); - } - - @Test - void testShouldReturnConfigurationForGivenPath() throws Exception { - when(netconfService.getCurrentConfiguration("sampleModel", "sampleContainer")) - .thenReturn(SAMPLE_CONFIGURATION); - - String contentAsString = - mockMvc - .perform(get("/netconf/get/sampleModel/sampleContainer")) - .andExpect(status().isOk()) - .andReturn() - .getResponse() - .getContentAsString(); - - verify(netconfService).getCurrentConfiguration("sampleModel", "sampleContainer"); - assertThat(contentAsString).isEqualTo(SAMPLE_CONFIGURATION); - } - - @Test - void testShouldRaiseBadRequestWhenConfigurationIsNotPresent() throws Exception { - when(netconfService.getCurrentConfiguration("sampleModel", "sampleContainer2")) - .thenThrow(new JNCException(JNCException.ELEMENT_MISSING, "/sampleModel:sampleContainer2")); - - String contentAsString = - mockMvc - .perform(get("/netconf/get/sampleModel/sampleContainer2")) - .andExpect(status().isBadRequest()) - .andReturn() - .getResponse() - .getContentAsString(); - - assertThat(contentAsString).isEqualTo("Element does not exists: /sampleModel:sampleContainer2"); - } - - @Test - void shouldThrowExceptionWhenNoConfigurationPresent() throws IOException, JNCException { - when(netconfService.getCurrentConfiguration()).thenThrow(JNCException.class); - - assertThatThrownBy(() -> mockMvc.perform(get("/netconf/get"))) - .hasRootCauseExactlyInstanceOf(JNCException.class); - } - - @Test - void testShouldDeleteYangModel() throws Exception { - String responseOkString = "Alles klar"; - String yangModelName = "someModel"; - LoadModelResponse loadModelResponse = new LoadModelResponse(200, responseOkString); - String uri = String.format("/netconf/model/%s", yangModelName); - when(netconfModelLoaderService.deleteYangModel(yangModelName)).thenReturn(loadModelResponse); - - String contentAsString = - mockMvc - .perform(delete(uri)) - .andExpect(status().isOk()) - .andReturn() - .getResponse() - .getContentAsString(); - - verify(netconfModelLoaderService).deleteYangModel(yangModelName); - assertThat(contentAsString).isEqualTo(responseOkString); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditorTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditorTest.java deleted file mode 100644 index 371bdd84b..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationEditorTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import com.tailf.jnc.Element; -import com.tailf.jnc.JNCException; -import com.tailf.jnc.NetconfSession; -import com.tailf.jnc.XMLParser; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.onap.netconfsimulator.netconfcore.configuration.NetconfConfigurationEditor; -import org.springframework.util.ResourceUtils; -import org.xml.sax.InputSource; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.file.Files; - -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; - -class NetconfConfigurationEditorTest { - - @Mock - private NetconfSession session; - @Mock - private NetconfSessionHelper netconfSessionHelper; - - private NetconfConfigurationEditor editor; - - @BeforeEach - void setUp() throws IOException, JNCException { - initMocks(this); - NetconfConnectionParams params = null; - Mockito.when(netconfSessionHelper.createNetconfSession(params)).thenReturn(session); - editor = new NetconfConfigurationEditor(params, netconfSessionHelper); - } - - @Test - void testShouldEditConfigSuccessfully() throws IOException, JNCException { - byte[] bytes = - Files.readAllBytes(ResourceUtils.getFile("classpath:updatedConfig.xml").toPath()); - Element editConfigXml = new XMLParser().parse(new InputSource(new ByteArrayInputStream(bytes))); - - editor.editConfig(editConfigXml); - - verify(session).editConfig(editConfigXml); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReaderTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReaderTest.java deleted file mode 100644 index a0a15b993..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationReaderTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.tailf.jnc.Element; -import com.tailf.jnc.JNCException; -import com.tailf.jnc.NetconfSession; -import com.tailf.jnc.NodeSet; -import java.io.IOException; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; - -class NetconfConfigurationReaderTest { - - private static final String NETCONF_MODEL_PATH = ""; - private static final String EXPECTED_STRING_XML = ""; - private NetconfConfigurationReader reader; - - @Mock - private NetconfSession netconfSession; - - @Mock - private NetconfSessionHelper netconfSessionHelper; - - @Mock - private NodeSet nodeSet; - - @Mock - private Element element; - - @BeforeEach - void setUp() throws IOException, JNCException { - MockitoAnnotations.initMocks(this); - NetconfConnectionParams params = null; - Mockito.when(netconfSessionHelper.createNetconfSession(params)).thenReturn(netconfSession); - reader = new NetconfConfigurationReader(params, netconfSessionHelper); - } - - @Test - void properlyReadXML() throws IOException, JNCException { - when(netconfSession.getConfig()).thenReturn(nodeSet); - when(nodeSet.toXMLString()).thenReturn(EXPECTED_STRING_XML); - - String result = reader.getRunningConfig(); - - verify(netconfSession).getConfig(); - verify(nodeSet).toXMLString(); - assertThat(result).isEqualTo(EXPECTED_STRING_XML); - } - - @Test - void shouldProperlyReadXmlByName() throws IOException, JNCException { - when(netconfSession.getConfig("/sample:test")).thenReturn(nodeSet); - when(nodeSet.first()).thenReturn(element); - when(element.toXMLString()).thenReturn(EXPECTED_STRING_XML); - - String result = reader.getRunningConfig("/sample:test"); - - verify(netconfSession).getConfig("/sample:test"); - verify(nodeSet, times(2)).first(); - verify(element).toXMLString(); - - assertThat(result).isEqualTo(EXPECTED_STRING_XML); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationServiceTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationServiceTest.java deleted file mode 100644 index 6da65728e..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/configuration/NetconfConfigurationServiceTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.configuration; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import com.tailf.jnc.Element; -import com.tailf.jnc.JNCException; -import java.io.IOException; -import java.nio.file.Files; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.springframework.mock.web.MockMultipartFile; -import org.springframework.util.ResourceUtils; - -class NetconfConfigurationServiceTest { - - @Mock - NetconfConfigurationReader reader; - - @Mock - NetconfConfigurationEditor editor; - - @InjectMocks - NetconfConfigurationService service; - - private static String CURRENT_CONFIG_XML_STRING = - "\n" - + " 100\n" - + " 200\n" - + "\n"; - - @BeforeEach - void setUp() { - initMocks(this); - } - - @Test - void testShouldReturnCorrectCurrentConfiguration() throws IOException, JNCException { - String expectedConfiguration = CURRENT_CONFIG_XML_STRING; - when(reader.getRunningConfig()).thenReturn(CURRENT_CONFIG_XML_STRING); - - String actualCurrentConfiguration = service.getCurrentConfiguration(); - - assertThat(actualCurrentConfiguration).isEqualToIgnoringCase(expectedConfiguration); - } - - @Test - void testShouldThrowExceptionWhenCurrentConfigurationDoesNotExists() throws IOException, JNCException{ - when(reader.getRunningConfig()).thenThrow(JNCException.class); - - assertThatThrownBy(() -> service.getCurrentConfiguration()).isInstanceOf(JNCException.class); - } - - @Test - void testShouldEditConfigurationSuccessfully() throws IOException, JNCException{ - byte[] bytes = - Files.readAllBytes(ResourceUtils.getFile("classpath:updatedConfig.xml").toPath()); - MockMultipartFile editConfigXmlContent = new MockMultipartFile("editConfigXml", bytes); - ArgumentCaptor elementCaptor = ArgumentCaptor.forClass(Element.class); - doNothing().when(editor).editConfig(elementCaptor.capture()); - - service.editCurrentConfiguration(editConfigXmlContent); - - assertThat(elementCaptor.getValue().toXMLString()).isEqualTo(CURRENT_CONFIG_XML_STRING); - } - - @Test - void testShouldRaiseExceptionWhenMultipartFileIsInvalidXmlFile() throws IOException { - byte[] bytes = - Files.readAllBytes(ResourceUtils.getFile("classpath:invalidXmlFile.xml").toPath()); - MockMultipartFile editConfigXmlContent = new MockMultipartFile("editConfigXml", bytes); - - assertThatThrownBy(() -> service.editCurrentConfiguration(editConfigXmlContent)).isInstanceOf(JNCException.class); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderServiceTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderServiceTest.java deleted file mode 100644 index a10876b98..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/netconfcore/model/NetconfModelLoaderServiceTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.netconfcore.model; - - -import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; -import org.apache.http.StatusLine; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpRequestBase; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.springframework.web.multipart.MultipartFile; - -class NetconfModelLoaderServiceTest { - - @Mock - private HttpClient httpClient; - - private NetconfModelLoaderService modelLoaderService; - - @BeforeEach - void setUp() { - MockitoAnnotations.initMocks(this); - modelLoaderService = new NetconfModelLoaderService(httpClient); - } - - - @Test - void shouldSendMultipartToServer() throws IOException { - //given - String loadModelAddress = modelLoaderService.getBackendAddress(); - makeMockClientReturnStatusOk(httpClient, HttpPost.class); - ArgumentCaptor postArgumentCaptor = ArgumentCaptor.forClass(HttpPost.class); - MultipartFile yangMmodel = mock(MultipartFile.class); - MultipartFile initialConfig = mock(MultipartFile.class); - String moduleName = "moduleName"; - when(yangMmodel.getInputStream()).thenReturn(getEmptyImputStream()); - when(initialConfig.getInputStream()).thenReturn(getEmptyImputStream()); - - //when - LoadModelResponse response = modelLoaderService.loadYangModel(yangMmodel, initialConfig, moduleName); - - //then - verify(httpClient).execute(postArgumentCaptor.capture()); - HttpPost sentPost = postArgumentCaptor.getValue(); - assertThat(response.getStatusCode()).isEqualTo(200); - assertThat(response.getMessage()).isEqualTo(""); - assertThat(sentPost.getURI().toString()).isEqualTo(loadModelAddress); - assertThat(sentPost.getEntity().getContentType().getElements()[0].getName()).isEqualTo("multipart/form-data"); - } - - @Test - void shouldSendDeleteRequestToServer() throws IOException { - //given - String yangModelName = "sampleModel"; - String deleteModelAddress = modelLoaderService.getDeleteAddress(yangModelName); - makeMockClientReturnStatusOk(httpClient, HttpDelete.class); - ArgumentCaptor deleteArgumentCaptor = ArgumentCaptor.forClass(HttpDelete.class); - - //when - LoadModelResponse response = modelLoaderService.deleteYangModel(yangModelName); - - //then - verify(httpClient).execute(deleteArgumentCaptor.capture()); - HttpDelete sendDelete = deleteArgumentCaptor.getValue(); - assertThat(response.getStatusCode()).isEqualTo(200); - assertThat(response.getMessage()).isEqualTo(""); - assertThat(sendDelete.getURI().toString()).isEqualTo(deleteModelAddress); - } - - private void makeMockClientReturnStatusOk(HttpClient client, - Class httpMethodClass) throws IOException { - HttpResponse httpResponse = mock(HttpResponse.class); - StatusLine mockStatus = mock(StatusLine.class); - HttpEntity mockEntity = mock(HttpEntity.class); - - when(client.execute(any(httpMethodClass))).thenReturn(httpResponse); - when(httpResponse.getStatusLine()).thenReturn(mockStatus); - when(mockStatus.getStatusCode()).thenReturn(200); - when(httpResponse.getEntity()).thenReturn(mockEntity); - when(mockEntity.getContent()).thenReturn(getEmptyImputStream()); - } - - private InputStream getEmptyImputStream() { - return new ByteArrayInputStream("".getBytes()); - } - -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/NetconfEndpointTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/NetconfEndpointTest.java deleted file mode 100644 index c1484d4b2..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/NetconfEndpointTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.websocket; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.util.Map; -import java.util.Optional; -import javax.websocket.CloseReason; -import javax.websocket.EndpointConfig; -import javax.websocket.RemoteEndpoint; -import javax.websocket.Session; -import org.apache.kafka.common.Metric; -import org.apache.kafka.common.MetricName; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; -import org.onap.netconfsimulator.kafka.listener.KafkaListenerEntry; -import org.onap.netconfsimulator.kafka.listener.KafkaListenerHandler; -import org.onap.netconfsimulator.websocket.message.NetconfMessageListener; -import org.springframework.kafka.core.ConsumerFactory; -import org.springframework.kafka.listener.AbstractMessageListenerContainer; - -import org.springframework.kafka.listener.ContainerProperties; -import org.springframework.kafka.listener.GenericMessageListener; - -class NetconfEndpointTest { - - - @Mock - private KafkaListenerHandler kafkaListenerHandler; - - @Mock - private Session session; - - @Mock - private EndpointConfig endpointConfig; - - @Mock - private RemoteEndpoint.Basic remoteEndpoint; - - - @BeforeEach - void setUp() { - initMocks(this); - } - - - @Test - void shouldCreateKafkaListenerWhenClientInitializeConnection() { - NetconfEndpoint netconfEndpoint = new NetconfEndpoint(kafkaListenerHandler); - AbstractMessageListenerContainer abstractMessageListenerContainer = getListenerContainer(); - when(session.getBasicRemote()).thenReturn(remoteEndpoint); - KafkaListenerEntry kafkaListenerEntry = new KafkaListenerEntry("sampleGroupId", - abstractMessageListenerContainer); - when(kafkaListenerHandler.createKafkaListener(any(NetconfMessageListener.class), eq("config"))) - .thenReturn(kafkaListenerEntry); - - netconfEndpoint.onOpen(session, endpointConfig); - - assertThat(netconfEndpoint.getEntry().get().getClientId()).isEqualTo("sampleGroupId"); - assertThat(netconfEndpoint.getEntry().get().getListenerContainer()).isEqualTo(abstractMessageListenerContainer); - - verify(abstractMessageListenerContainer).start(); - } - - - @Test - void shouldCloseListenerWhenClientDisconnects() { - NetconfEndpoint netconfEndpoint = new NetconfEndpoint(kafkaListenerHandler); - AbstractMessageListenerContainer abstractMessageListenerContainer = getListenerContainer(); - netconfEndpoint.setEntry( Optional.of(new KafkaListenerEntry("sampleGroupId", abstractMessageListenerContainer)) ); - - netconfEndpoint.onClose(session, mock(CloseReason.class)); - - verify(abstractMessageListenerContainer).stop(); - } - - class TestAbstractMessageListenerContainer extends AbstractMessageListenerContainer { - - - TestAbstractMessageListenerContainer(ContainerProperties containerProperties) { - super(mock(ConsumerFactory.class),containerProperties); - } - - @Override - protected void doStart() { - - } - - @Override - protected void doStop(Runnable callback) { - - } - - @Override - public Map> metrics() { - return null; - } - } - - private AbstractMessageListenerContainer getListenerContainer() { - ContainerProperties containerProperties = new ContainerProperties("config"); - containerProperties.setGroupId("sample"); - containerProperties.setMessageListener(mock(GenericMessageListener.class)); - TestAbstractMessageListenerContainer testAbstractMessageListenerContainer = new TestAbstractMessageListenerContainer( - containerProperties); - return spy(testAbstractMessageListenerContainer); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListenerTest.java b/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListenerTest.java deleted file mode 100644 index bb040d1e3..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/java/org/onap/netconfsimulator/websocket/message/NetconfMessageListenerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.netconfsimulator.websocket.message; - - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.verify; -import static org.mockito.MockitoAnnotations.initMocks; - -import java.io.IOException; -import javax.websocket.EncodeException; -import javax.websocket.RemoteEndpoint; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.onap.netconfsimulator.kafka.model.KafkaMessage; - - -class NetconfMessageListenerTest { - - private static final ConsumerRecord KAFKA_RECORD = new ConsumerRecord<>("sampleTopic", 0, 0, - "sampleKey", "sampleValue"); - - @Mock - private RemoteEndpoint.Basic remoteEndpoint; - - @InjectMocks - private NetconfMessageListener netconfMessageListener; - - - @BeforeEach - void setUp() { - initMocks(this); - } - - - @Test - void shouldProperlyParseAndSendConsumerRecord() throws IOException, EncodeException { - netconfMessageListener.onMessage(KAFKA_RECORD); - - verify(remoteEndpoint).sendObject(any(KafkaMessage.class)); - } - - - - @Test - void shouldNotPropagateEncodeException() throws IOException, EncodeException { - doThrow(new EncodeException("","")).when(remoteEndpoint).sendObject(any(KafkaMessage.class)); - - netconfMessageListener.onMessage(KAFKA_RECORD); - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/application-it.properties b/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/application-it.properties deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/initialConfig.xml b/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/initialConfig.xml deleted file mode 100644 index f28a1a0a8..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/initialConfig.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - 100 - diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/invalidXmlFile.xml b/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/invalidXmlFile.xml deleted file mode 100644 index 3debd8c26..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/invalidXmlFile.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - 100 - diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/newYangModel.yang b/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/newYangModel.yang deleted file mode 100644 index bbe66c3ae..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/newYangModel.yang +++ /dev/null @@ -1,8 +0,0 @@ -module newyangmodel { - namespace "http://onap.org/newyangmodel"; - prefix config2; - container config2 { - config true; - leaf item1 {type uint32;} - } -} diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfig.xml b/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfig.xml deleted file mode 100644 index 628a710fd..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfig.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - 100 - 200 - diff --git a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfigForCmHistory.xml b/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfigForCmHistory.xml deleted file mode 100644 index 5bc0e4285..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/src/test/resources/updatedConfigForCmHistory.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - 500 - 1000 - diff --git a/test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key b/test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key deleted file mode 100644 index dbf8d7635..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key +++ /dev/null @@ -1,49 +0,0 @@ ------BEGIN OPENSSH PRIVATE KEY----- -b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAACFwAAAAdzc2gtcn -NhAAAAAwEAAQAAAgEA0Eve1v58bkLc4/6FvcBYWO8q6rOTJok7YyOHnc6QBJFuChSTbAaV -nn+E8nPgyqN0/hH740+qjtWpaJdKh0+hJMw0vUeX6SQ1OpRgyXFbDSbFrjsBjB7N2eusrR -M5FweDxVW/mfR7AHemrLulbNYHt/HmY+Hee09D/awICpuViLKLOsPp8ifmbHG1mXStLNSg -OJgBvsrMvbsKYgJq0HdWPyfkzFf4SVdjKxeegQbkSogWGqRG7zkfu8bsYooUpIFRFMiJvW -dr9tlegESAu1fmUx2Wz7EtN4Qq7xqHfAbT+Ruzr4rtCRRCsdEou49kpTSM75FaKlXmchRV -tBQKndFhcPQCO+m9OkQ4+45VSeLL236MTvAFGnqfLks97TO7VLGinhtMvJA1gZI93bwVBS -P1uaVuiUdzT8OgUq6xsLx2qg2aoau5Ivj65Hdj8tlIjeFHeGgUd1GZa434X3p8WCDFVrQK -GpReaDTFttVFw7F2+biFmn68TO0bb4GE84r8ouaYVSGzWG1kEy8UtriXnx6GPOzncp8HKT -YFn2etzs5EE9Ae64+1mIJTUEnWlpxwrjCqCIreibMz4/7AkSWrwc0YeAUERso+ESQkCU8R -zpcYSRz50UTCaerS8K5cPE9N2XB3WYbsziNTpR568onQIkL+ZlTIbNNYBgdVNDLlQeabKS -kAAAdILF3O/Sxdzv0AAAAHc3NoLXJzYQAAAgEA0Eve1v58bkLc4/6FvcBYWO8q6rOTJok7 -YyOHnc6QBJFuChSTbAaVnn+E8nPgyqN0/hH740+qjtWpaJdKh0+hJMw0vUeX6SQ1OpRgyX -FbDSbFrjsBjB7N2eusrRM5FweDxVW/mfR7AHemrLulbNYHt/HmY+Hee09D/awICpuViLKL -OsPp8ifmbHG1mXStLNSgOJgBvsrMvbsKYgJq0HdWPyfkzFf4SVdjKxeegQbkSogWGqRG7z -kfu8bsYooUpIFRFMiJvWdr9tlegESAu1fmUx2Wz7EtN4Qq7xqHfAbT+Ruzr4rtCRRCsdEo -u49kpTSM75FaKlXmchRVtBQKndFhcPQCO+m9OkQ4+45VSeLL236MTvAFGnqfLks97TO7VL -GinhtMvJA1gZI93bwVBSP1uaVuiUdzT8OgUq6xsLx2qg2aoau5Ivj65Hdj8tlIjeFHeGgU -d1GZa434X3p8WCDFVrQKGpReaDTFttVFw7F2+biFmn68TO0bb4GE84r8ouaYVSGzWG1kEy -8UtriXnx6GPOzncp8HKTYFn2etzs5EE9Ae64+1mIJTUEnWlpxwrjCqCIreibMz4/7AkSWr -wc0YeAUERso+ESQkCU8RzpcYSRz50UTCaerS8K5cPE9N2XB3WYbsziNTpR568onQIkL+Zl -TIbNNYBgdVNDLlQeabKSkAAAADAQABAAACAQDFUyq+14T/W34wytzd/opzbddlUksTlavZ -5j3CZH4Qpcjt6cIi8zXoWfuTR+1ramAZlOXf2IfGGmkLeU+UUf5hgsZvjZQ+vBtk7E2oaC -eOlO1ued2kZUYzrMz/hRdvVqIhXnNNoMqpjbArMPSs3zGes53Df6UpgdTySnevvOZzAlld -iV1mFyB2GV6lCmBH+QHzuyTkHvDIyJk0cf/Ij1T4LY3Ve3zt1chPeWeh6ep5JORzxq6gT6 -hdVjx3uUGG+i7aloPOF1yzFAcvUjX1xHagxIYrKTihwCaALsys1TcYZYLayKx3DmeEVpXU -4SnCS7878KHPO2M9LUBngRjxmvpHtnaIyp4LugY48y+KtywjR39hOsKW3QawVp6CtTceNE -QMlosaVIQuMJkeW14poYBclva0B/lCn3r9/3OrCI9qZPdD1RrCQqUyom56EU4kwRddSwHi -LDj4xKoyzH022lfaTt+PwbXtVJGAOVTS86ZovJaIJwyKCE1T0p66qqIM/mo1GVMTfTKwUt -A9v0AwTYFXmZ/9HJjhMNhCNclPilZHzuPI9VqiZ3tkKhS6kxZQA2cB1VdcFPIEeVOpZcJd -yPzGfFuKYOh9CLQMxfMC46MeT1XoQi5bMBygy8ZajV9VM2xUMKft1IqyN65nA7d+covoxL -PLjC6n3hUJJtSMTAohAQAAAQBf4lenniOgFycb1REtnUhyaCsopBmkuxlCOknkmFiMNW+B -v/aeFUp03WluKGOVureJoooU3Z32Om2+YTxTOnCRL5Sn4gL7cAp7JfDSZpZPqynUAKFvKq -QVbYyiEmFkUDFWes9Q0r0LAx2rvPrDIGhqx2ZgrzINlhrhxaQU2+fGbNRdI86PcWSYtc5u -Oucd6nJM7eI3QL7/pVNlK3GMJ68eviKmhxP5HHnanNes2ORa15S5rRSOAZ5653pA1J1KxB -J5vwwMvIXbEnBn8NilqWK50DHJMFXEoLaKlb0OoYMKbiLt4CjcCCIUUT1kAu/SFUpFdYI1 -DNXfrieu3ZTEwnU9AAABAQDrf9b8VnARNimzLqI15hp0Z5B8Sxf8Xw85KRRxg7cu6TJLoF -K6VRK1jOzrKCrIzvBwuS2Er06ogEE/3N8eXC2ipzNOtDh7CQqoAq8IKNUt+2cvThNzfOFe -BZ6lP9pQ60RGEPoeQyhlxHOUbV80K/ksiFqnAixOmOV7Uc7KZ+8clFvhOCm76vo80GaYYk -NQtvMa1qxIsyUrOdhmIxF9dYN/sQMUr909o80kN69L7d+D1hG6WNskEJphrHSkPWTell5g -4ekFna1+MjNQoCWhp6KPDKK9Y8AMrqWU/bFYw9CYwXo67p486qt487ZN+0cNItmSLMR3Ke -MWmCmq37+v3viJAAABAQDibc4fU/xePaCjQa4VlAwk9ISd8Ufz/LcJWDiseKSzQnIdCaCG -gO/SWTUuAzGEdrNnfJRcEUtrJ0UJAo2ntYZ3AlJLQvFF9KII3yuUn/RHMrkwslAIoqLhLO -QX38nJeWR+hEWSFbpWP5N5biLRi2Qnwtv55hYgNqTLHRURzvin5/YeuwigBax1SwtN+V2D -JSDhMiaFV85ZQggSoIjLIsunLK5XIDzTC82gJ9aaazvKBXwkf4Yfv5t1BgPATzqwjmXztQ -T8WbTeqEO95cIu0zhfKIGo7Wvx7S9NPrNjyNO+JK9/qqdYGhErPiZPKOcHHywF77Yyv2cm -gOrMYVCubUOhAAAAD21hcmNpbkBtYW5kaW5nbwECAw== ------END OPENSSH PRIVATE KEY----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key.pub b/test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key.pub deleted file mode 100644 index 8f739114b..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/ssh/ssh_host_rsa_key.pub +++ /dev/null @@ -1 +0,0 @@ -ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDQS97W/nxuQtzj/oW9wFhY7yrqs5MmiTtjI4edzpAEkW4KFJNsBpWef4Tyc+DKo3T+EfvjT6qO1alol0qHT6EkzDS9R5fpJDU6lGDJcVsNJsWuOwGMHs3Z66ytEzkXB4PFVb+Z9HsAd6asu6Vs1ge38eZj4d57T0P9rAgKm5WIsos6w+nyJ+ZscbWZdK0s1KA4mAG+ysy9uwpiAmrQd1Y/J+TMV/hJV2MrF56BBuRKiBYapEbvOR+7xuxiihSkgVEUyIm9Z2v22V6ARIC7V+ZTHZbPsS03hCrvGod8BtP5G7Oviu0JFEKx0Si7j2SlNIzvkVoqVeZyFFW0FAqd0WFw9AI76b06RDj7jlVJ4svbfoxO8AUaep8uSz3tM7tUsaKeG0y8kDWBkj3dvBUFI/W5pW6JR3NPw6BSrrGwvHaqDZqhq7ki+Prkd2Py2UiN4Ud4aBR3UZlrjfhfenxYIMVWtAoalF5oNMW21UXDsXb5uIWafrxM7RtvgYTzivyi5phVIbNYbWQTLxS2uJefHoY87OdynwcpNgWfZ63OzkQT0B7rj7WYglNQSdaWnHCuMKoIit6JszPj/sCRJavBzRh4BQRGyj4RJCQJTxHOlxhJHPnRRMJp6tLwrlw8T03ZcHdZhuzOI1OlHnryidAiQv5mVMhs01gGB1U0MuVB5pspKQ== marcin@mandingo diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/ca.crt b/test/mocks/pnfsimulator/netconfsimulator/tls/ca.crt deleted file mode 100644 index a72e926d4..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/ca.crt +++ /dev/null @@ -1,32 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFlTCCA32gAwIBAgIUYjGBXIujymdkS9A2MzssbetWn9gwDQYJKoZIhvcNAQEL -BQAwWjELMAkGA1UEBhMCUEwxCzAJBgNVBAgMAkRTMRAwDgYDVQQHDAdXcm9jbGF3 -MQ4wDAYDVQQKDAVOb2tpYTENMAsGA1UECwwETWFubzENMAsGA1UEAwwET25hcDAe -Fw0xOTExMDYxNTExNDBaFw0yOTExMDMxNTExNDBaMFoxCzAJBgNVBAYTAlBMMQsw -CQYDVQQIDAJEUzEQMA4GA1UEBwwHV3JvY2xhdzEOMAwGA1UECgwFTm9raWExDTAL -BgNVBAsMBE1hbm8xDTALBgNVBAMMBE9uYXAwggIiMA0GCSqGSIb3DQEBAQUAA4IC -DwAwggIKAoICAQC7zJGm+qODeBm0citmi+VKOwhVUg1QTyofXsqoib+yeiepYz+c -MRMXMK20TA2m4ObAG5JoU0Ht1bT08f4K8BAoutq0rwb28YodSKiq8PCtD4Pn81Up -FdP+Ymsl4YqXhydLEsqv/tpZgVvsCr/a6esxPfGSrScqw2PUf8qrHEXV48lX2Ho9 -19nZWjQTgqDzmOAShyMQabdrfuKII6/A6w/Q8eghzMQrJFsnfOS35RmH6MJyi1vl -Hn37uEpZWjh0untRA4mtAHB6f3exw36gfpGyQgfMUiCBCbsr8SgJbHCaDpozD9ZE -Ny+R+jRsqt0RlBoZsSPToNw1o6YjzBZZi1qYyDuNz0bQR/hedQxkwwKcj0Y7tfxF -IfwUkb1XQ0e4mDia6R6tptphSfrSKLouVFGTVdVtoP5lpGhsw3+KWuTbwB64cZuS -YuWW1BJ7gM6xj8b9cWRtOakHJ7WKt98Z3U7wDrQqZpnWk893kWoo0Q22X4uTipHX -+ETSdtTq5mVvYQQNub2CcA/4GQyODfdlC0gDkNeT9t6yfMJcOAJUBvW1JMoDAkED -nWnWm/kS7aflFH6IHfqHbt1ZXUGJG94wTpvGJAHTnaiyX0mL4KK/r+ivdii+Tais -VFKOqW7EqNZziOvZ0TMfkHtrBY89DgG8+XNwa0KUQIqVIQoJwOfQl4pAjQIDAQAB -o1MwUTAdBgNVHQ4EFgQUQ9QHKoM/JUSm7ZnO+JvsHMVo6M0wHwYDVR0jBBgwFoAU -Q9QHKoM/JUSm7ZnO+JvsHMVo6M0wDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0B -AQsFAAOCAgEAK6bcNkkAVY11yUg1Vm3e9QGRWPeWNbKVIHR/uJIvq4R8AthvFcEG -6GxApE9Zdd0oWpUG9cM/EZ3ZB5drDnpqUYURkQ8YNrIPJXByvqXFeQPej+m7DHOE -vPtbm780cE+Z6abfctRFdujJX8hQ5s3UEKjpk0HsbZqEX4JbNeLT+LKgH+kwU/SA -puVFZXN7dTACdX2gg2F1Fg52L54ZTWMlFMNn32b1a8zrKY0HaoLQd+yXS4RfrMpd -jPsaytuOimU+OFRFb8cvSpuC+gkCEwQFVKb/B+0Rp1No3edEE4N92hpkiDh5/+ML -/B8kSh0InaGxu6uTC3QzqTRgzbaRpOoWkdVRkDSpU6xNtyQN5jXDExpXtPe4LMP6 -Vk1jGpJ3E6kjSzzSvZFsH9Fko++aF6m5qqAHgG/Yc0j+7bmWCoMZWVqoxE9fHjfc -mFs8N7R2HYA7G3qKs1fZy5SzAhuMkggys6z3c6ZW2BtD82GClSlXIlPwBu6KpCNy -6cDeQ245wH1pO7pKfaIu3hbY6m5Z9jkbyOeW4I2Pj2s13345qjF9pRggkJ0MQtgi -M6vU/13o/WhF0lEVz37pbriJ106412tF60uyyzZvJkAqhBCJyJ0jxqtwKr8GhL9g -PnTRJkhFAE/5KvAi0ETbOIScRz/B+v+nm08ZGe1nHQ/Vu+NIY5gLp18= ------END CERTIFICATE----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/ca.key b/test/mocks/pnfsimulator/netconfsimulator/tls/ca.key deleted file mode 100644 index 1e87b9010..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/ca.key +++ /dev/null @@ -1,54 +0,0 @@ ------BEGIN ENCRYPTED PRIVATE KEY----- -MIIJpDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIUwiDd8rZROYCAggA -MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECJDuKSaXjEGWBIIJUImHlTdWbHhQ -5/4oKETy31+ge3i0bBkk4HvfxaKlzsiHlG/WCLbUCSb0MR7KBdg1Xvl0sA9fE8ei -6GH/iEBsJ/NDdwhQyPZiaLRKwQQaaT33zkBTY02fxHAxz5YCGmahFUa/UQYcBZKX -FjHUWx1MBv0tNgwpcdOKhLSTviL92QNHdzuq2IlOfhZ/Ly3fTKlQbgRaTPfgtlWh -8VkhtOUjikcNzoOUEQja2OUQ5scjmAo07iLx+ObR8znpOfg/ScYTUZ6fEEm8zykV -1QFnuNr5RAUnldIqPUhZwmbNrlijvGcbQez0jQI/KZqKEMtBX8Hs224IiCrG1GPe -AFvbs2Y3gc4hP9OSqlePVNhTSF8i6ALy8FZdCH70rJ3nHowxmuj5TnEWSZV2gqjv -ruNy7u8KGK9YPSyL6dI/toE0vdNjvbDlqOEbLKJ6wg0spdQx1w6PBjImc/S+21oB -pXTt3VEgo6AWlB2Q4sbIg+7Oh6iWwgzcrLjmkFndgWnxa74Ajzi8TylJdgLQ2wHg -2w4cuFxdPdgDwYNUiJtC7FhnEerOndTxgTtAAwjPKtI7xhwVqd11aCw0MR/Zi7Pp -GVN2EAEJjFUwRfnc37JwOiL03HfKZGdDCBggldyqJX82ECeMvfwSqlBVji4ouxKY -ZRypStk8wQnB4BCOgymQXTWAzUIWtVjOpOyUIobRXkqX3vDTEYfKkBzHQSVgFqA9 -iOMJ4pB76wG/f7Y8X7rz7p9AVMrt8XhNeQP9/H4COZmhWYyOkJNcAM3S4Gq3jnpp -sYy99Vw81BWHXmqCfY7omZSle7YstisB5syIdehDR7H3pqe84ZHrs3GP84sWbuyC -jpmOWp5pt5PhJA3BmyUZZpGpwzGr3ZgRzo5O+l8LkDNa5tcz1qgyergzxyQWwurV -YMTxSoBiJOMJdGD3ZwNgQ499naDUeHExncWWA1ghCOsEcTNSF0SjSINRk6NhP0bQ -KsbMemqF1pr6qLtyVmWHv2pl8yunxvRxUM8VGReXhRoJGsm4U6lXY3pL5LumQ6TM -7J0AKdaTl9qV3xL9LXVFfP4pcx6vstMVHzzkt8i6uN0tti0OkQzCk6tiPBi/pk3l -vlLQ/IWrng4ddI6IObF+63JkDfpzGkFk1XG07qP/Urj88f3lEkh5D208JpMb5Zfu -m3O5nM/SQddL4FWU63OvfVRISiJ9V93mE6Zc2z1+XeTEx8OKK720sCeYwaCkTv1f -6FhVG9F8QvX+OP7eLPCXQKokY6/XgwK/C0gJHdrJcJYT1pM3rR+CTBoxHs+698xO -utV0miEDTg8jG6CoU86tP9o1KP7eSAWII+8E7tWJlMphHTBdWJZbz/917LQMlCyF -ObLwhSKCi8PPNGj09wkZBOt5CoMGFsVZkO+z+4m++g9BWS/hzYaQxwnNZ0JnxVci -15QkZRl4deyKiJqcKjvPdLCXBGsejjAfaUfu3xuwq+ZNlcHqlMRGBx7RLngGciFK -yRJxrUBoWcHCUNF5zpUiQq8UIU88ptCQyk1qRXAmIcXyzRZ8ge9J0mFoznd+vY6X -Mlm1fHR1sR/CY+neZlWnVKCiR+3BLl/vVoavsOo8FBbPUiIuAvPuqSUK37IG/RAZ -E4mfxP6K5B+zGaPSXXOiI1uqYj1RGRtRXYWKmoIpOQhwydylMOYGRksmfCL4ureA -eMmsXAs0pLXjkcxv81pE7ax004OZtB/RnnlGmSgmvpzRt6usIxH8YksWT5ZyXZsD -IcXtmOim4BpniZFjTAQb53u5gd5C1KvlLs3IZQ6n+1brPT2fwSiCI9SKJgln2exv -0oKyYCs1MtZpLPi8tb3/iuZTc33cyyLkf/e27qREauYS+IlFtQrjG4EMslzNrcyU -FcVUmqgMArxObcBmv6/yMTsu3gGUPxCR59y9EZwZ/iNo+AJqer1lUdZD5RurGBW+ -qEohqtZ1zeBWq7a5S/RPm6+UcdXzQNJd5Ipfw1geIjyT3Xqn2gSf/hHXfSmu7vqv -xvIdDu5H7ZEfguhSxtmde/tWdckDXrBRqGATCr9iZ5Jp+DZ2YXaOSW0JuSfZFEAI -1XsIPyGaGvH3qXdGN/xruUq/lGFLNPsLWzWFzV31tuTgsqE1ptkRUTmLMwz8tIFW -hFCuGuEMp1wgsco5x7GOrwn6w6p7fDqgCnXBAI2Y5094j5UmtM4SsWWxiQO/muLk -v01s5DoJh5oEhDjsHmwkvnHzuhjco/omZCcik1kbs7KRu8ha26kMZ6A28T29OvAL -llQvOPzAVQFXCYWJIn7JFv185kna+twfGX78rXyxbfl9l640D0tlklKZZwxsvIFI -Zb+jPFFQdKFlAnDXSYvhqr7UHbIM4jDOPyKNmkXB13ePuxisIZvO1QEQP/Jz21xj -yF5VcHIImFpzXhJyqbUn6PlSJUPgkGsTLeIMAXBaYk+JfRnxcARdTqPAXXIOF+wf -QTnAwsAI14nwiZ7skoPqBkKUvUOWg0nQF1+BpqUmbONbAjTetfJEzg8Qkkdj5poG -h7w9vT5h/PyGjYa1dkAJVaFHCE/cW2Hy6jQ6b5dO3/HfAgEpZxaGKBri2fns7WhU -iTzQb1RhD9JLFDnMRqNDWbwW7DDqN3hjevDs8MIoaxIaxW8zjpOYMRKAbkUWpr6i -Tz1sa1vQewNPq+Pw14AbYlr7LMm7y6WJWW1vzXVstQFE4JU1drSwSqRP/CVPSWRb -5l5mb7/eiERKN4/EFsHpoRB7EIsRdD5xNGy9rAmjFOUlO/CxzjIy5MYLcKT+liJf -x8l+EbfsjqtNFFVnntduTL7joo9bi9OufFDTtJkoBJdx+YZITrsQ0szbrdQBOe0Q -KcU3CmY7TsUlur/2BHQ8KARA3e1nhYYKJxlb0WDocVlQANcervZ8qf4EmlPSxi5n -1E9AxLSrhPFW8wa3G2ygwZWPmNgLdPw8bD3aS60s1P+whsBdDq6oQXFMD+RIWm2n -L293J8nml3PcP3RhphMTUUbNLepOYYRNOieHr2dt2V78M8Hp2Ue8lCfNYu7ZXjTB -5XeUWa2b76vwiZiSiKYDIG59hHjeIsQOGtPq6CzrgtxsPORpmmDcBFmZ6HxszApB -hr8rrcdPLmoI0zFF+tOBuGglrHswp1c98aZcM9lrErf62MfOG9DRa11Xiexmt4wt -ETq+BbQtrvmZb6x5IrRU3Kt5QmkS/K/1 ------END ENCRYPTED PRIVATE KEY----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/client.crt b/test/mocks/pnfsimulator/netconfsimulator/tls/client.crt deleted file mode 100644 index 3c0d20cce..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/client.crt +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFKDCCAxACAWUwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UEBhMCUEwxCzAJBgNV -BAgMAkRTMRAwDgYDVQQHDAdXcm9jbGF3MQ4wDAYDVQQKDAVOb2tpYTENMAsGA1UE -CwwETWFubzENMAsGA1UEAwwET25hcDAeFw0xOTExMDYxNTEyMjlaFw0yMDExMDUx -NTEyMjlaMFoxCzAJBgNVBAYTAlBMMQswCQYDVQQIDAJETjEQMA4GA1UEBwwHV3Jv -Y2xhdzEOMAwGA1UECgwFTm9raWExDTALBgNVBAsMBE1hbm8xDTALBgNVBAMMBE9u -YXAwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC1kEo6cAykAqNE4R53 -8VJn5Rzbs5HDDk9+0HCxgEp/7suRMWLOgeG5/L+nRgrLLcFPscwnIwIHUUE1pzyj -aDux6cXjpto+1APq/sd1ofVMMl3I/zqcrqojixjFJO1INgN/i1CaAeBRO+mNmIUN -IJKy2KbTYvTYYJrJbzIRh1NBsUvuIzvj5Wkq3cri4oJmz82lsNDAh4BGedWQT4RU -mjb/EC7D9WpfOlMhsgLVJgPdG5ESFqN+xx/n4xJUcM/HGqVlfZED5XDcfQjp56Ba -FBpNhLW41qVy8UoeixYiduLaVvKDoJc2Ea3N/pyE3YU1LBOy7znpULX3UdMb+bX5 -jGn4uauKz77hLZA5nurgb8v1ofbj1GCM28JfaiPRtIuWVtWKI+8RyKjaXjKd/rcG -W/5T9aM9um/lH2v/DteaTa4i8zebL7k/DJFTXP+DCtJTi8e23Xalkp+O+MWQQrGR -O07NHdl1gjDmEoc3NMRO51Ux5CDyqCbhF4QdX0ND+vDJmD8GBuxb6A3HjdmT5/iB -iH5/HO6FRHFhMtR9xABryT01gYkDWJHszTStNLx/ZzW4Dz3i2WyoEvDa2meLkSh5 -edE1skowZriSeoOuGWJlfpjjvn1p4kjk0msg3T8EgJqZu9AiKzuVgILa8u6Kny8/ -p12MN+yltB02hiJZyMlyJDCn3QIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQAf227R -PWMNcdVKbDz8pKXOYUN5RtvvisabF25CrxVMNzH2+3nQIuICOEg7dFI1qKEEh+DJ -51dAgwCC7d+levHBHximFaW7ED1rRFZJUoHlF9Ku74KA3eWPcWBJdzIAk2KzcQhu -GXVQs2RUv5nJJogAPTtt9hFU9e3vqfpb+DNrzO0BTCfTsO3QSSojrtOpLOhH4EBV -z6TyKDYJH7XCIvhApJjbuWsvVi3WTYFpFtF3dBNTMXjMZaHqMQBmMO4VzoQeu422 -fAcCVb+UUIrdU/Jdm+6tjuUqfQj3lVIZFPhTXrZ0MfBkowHoioos34u+JJ3Hjd+5 -mK27OhNA4SKaYQfi2DQ8jV1Jf/yA+lcmZddAiLZyOgHXPNZpP6glG802/k67i61J -PIxaoaVmgxccZINzqov4Sn7A6hgt3S68izpsrIu1R9JqKjjgNA5HqtkMjyYqaMoX -nQ0jIxkd5lkHL8MzAecaR37Y4hibpgsDl2SsuLTtfcO3NQO0bGFMRqYaIHN6DYd0 -4S1vOrsCWc3njvUGW8UcvB8GC4puwTi9en9SPaVcgSEBZ8gsJ4E1XWAdyTQZJWon -aMn8iAeapfJu7N3UA5nM9L0f7dvODkLDqXOJuLl1IhhNFu6E864Ld+BVH8EQjIrr -xCvjvlMQ4pnp7kjQdEekswN9ON6e3pxT/W3t7g== ------END CERTIFICATE----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/client.key b/test/mocks/pnfsimulator/netconfsimulator/tls/client.key deleted file mode 100644 index cb80fca8d..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/client.key +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJKAIBAAKCAgEAtZBKOnAMpAKjROEed/FSZ+Uc27ORww5PftBwsYBKf+7LkTFi -zoHhufy/p0YKyy3BT7HMJyMCB1FBNac8o2g7senF46baPtQD6v7HdaH1TDJdyP86 -nK6qI4sYxSTtSDYDf4tQmgHgUTvpjZiFDSCSstim02L02GCayW8yEYdTQbFL7iM7 -4+VpKt3K4uKCZs/NpbDQwIeARnnVkE+EVJo2/xAuw/VqXzpTIbIC1SYD3RuREhaj -fscf5+MSVHDPxxqlZX2RA+Vw3H0I6eegWhQaTYS1uNalcvFKHosWInbi2lbyg6CX -NhGtzf6chN2FNSwTsu856VC191HTG/m1+Yxp+Lmris++4S2QOZ7q4G/L9aH249Rg -jNvCX2oj0bSLllbViiPvEcio2l4ynf63Blv+U/WjPbpv5R9r/w7Xmk2uIvM3my+5 -PwyRU1z/gwrSU4vHtt12pZKfjvjFkEKxkTtOzR3ZdYIw5hKHNzTETudVMeQg8qgm -4ReEHV9DQ/rwyZg/BgbsW+gNx43Zk+f4gYh+fxzuhURxYTLUfcQAa8k9NYGJA1iR -7M00rTS8f2c1uA894tlsqBLw2tpni5EoeXnRNbJKMGa4knqDrhliZX6Y4759aeJI -5NJrIN0/BICambvQIis7lYCC2vLuip8vP6ddjDfspbQdNoYiWcjJciQwp90CAwEA -AQKCAgBvwrq+T/yn9Gu12XDc2fIku9ZQsq81xxhN8lZ8HIE/UKmD3Ud54F8nEhqT -B71bJfYJbWNCb/0ureia8y+TUnT0ZfcG080hwXYL7/qtQR1yYspyEBFvIuDd8iA0 -Mi/RNFZg60uZETCYMG3qWAkGdJd4eX3vPsmCa6y787N5MLiiBlW753pVJQDgfxgF -IvKsAJwQss88w+vE9ffs1dWaEjdqN/bhbq6koY1Mf3vY4oacUvywirjnMAFGxvKg -gbSUVaWb3HgoUtJvFpQnDwoYiKlMMDV/6rh7EWXTeUANxOqNBdpQBckuYiF/XIvS -CV2WxmP1z+Xw5VqtO3Pck5BdZP5RLj/43CAtXt/1JV7QFMXohBOvFbcqBaWjfvl7 -6/CvtTnTjNlp4Z2mciFrClqPTgeLT67dCCiyUwXiqJGWJ50tuao5vpPX3JEbc0By -FGDsdcnXKat99EhC72celO1NprqfvFGJubHSmF1Kce+faqXEQLWHkda1dJtW2+BY -AWgtOS9Gaxb/hTZPrD/mkhnUYebLBDmnp9azacKzddlovJvnbRNrpJZ+D+wXkGQR -XmtfpFAkGyBlT4RyYOmfbEXvas8aSZmOltsPwiFwk0rPoH2owuYCj0XXLTFODuOy -Rs0zns8sdQsvdpKuykvdh7m4hDDdR8FgEDbzK39DndwGUk7+DQKCAQEA8P82Re74 -Ri02TYK6SaSpxauaJMajgfg6FtXMhZ+Ed0eUmtDI5OMWkoVgaRZGjTLzxGmQxd2I -h6YV3KsQng0mMySIqnVAPLm2HK3Ahopd1R26XalBBXpE7OwGlLmv7/9hQHNscMyO -i89WcQWQWuvMUxHc55byeI3cfchgwrR5uqZcBcTmaCu8SQXfyVZnM230532Gz4+P -DvLicAEI79SCKGDtjgnjWzqGbMgUtvtYDJzOT9py9DjW/h3I7aMIswp0y5PVvzOq -HIFaDRW2WyfZD6FTqhhtYodQ5Bpu1APdhFo+ELYg7YuqwF8N/+oEU+BtkHlOGgnN -RXMaBurO9W0MRwKCAQEAwN3iefqYcz+TywUbDXyvWGZNIrU7d8hS2NXZPDgj7ysc -RecaPAcnEOEv4PgQjj6w+WL4XrIqDk6Nigzq/8nFL8M+odZke7o+zYxOFU9vsj7P -iqfvcG3Yzkmuw8Rl/9yw25t3tq4ftN3Lw70CeSnWOo8wGrkYmnoHi1Boq1E+PAHr -co2A6HvJchNxZhrEYPZJk1zg0w2TAhnwGxngZX2dz3bVTDWCu1dU5Me5Xj2ZLrcv -ypTqF8wGPOkqzrCtV+diLybaYc4pLtuYRKew85KXRd/kNKVRLwtfA9MaLGYIuqaP -+X/fxUTDvWX3d/za7rUC7mgA0wLbzLkg/3i72nnQuwKCAQBwzrXD9IFIsB8sFxZG -JIrHmXTU5BpjWyMtzzQmFC44e0wnT7XJ1jaZrU8cwa2SqJgMh3GZ/QHMpUS0f2qO -4Q7Rf7dtOucvxapmMDrff2M+v+SdtP1XqA0dbboC4gxl5f/K4HyRLF9JOGt5Ciax -OJDzDXh++1xSa+0a/7GzUjFs2jRXCvzjJB3FfLdtEkHKhBzQQyTYgZVwZObzkLhz -MuEeL4jjJOPEr1d/EgUIRgzIEppMLLAEe5q/ZofIHLmUvT9Aj9nM300wfKf/Wft7 -HeLv+w8jnr2NElQeAfWAzrJhIrDMt8QgDXGHDLeL5CnUbUg8CVwyugXZDXDQbhck -MMA/AoIBAE/ShY1efgIU6iI4dr3aQOghTwNyZq5opoE/4Kzfv1+ZRBZaU61MeIqv -6JT/ljqJD83nfEwVCPrq4AGm3wwGgioGcMGibewXZS7FRvvi6KOpA1SrtJmfnP+j -10UG4ABJYplBewaMgmrk8RSOAZwMCLIr2Qj2Wox0vPKX0Po2ob9MPBopHpUZxoIE -MgbERUqsJD9tTU+Maq+P9KQCzbCzkMDwuc7UxsqqlmQplTq/28pN3uXFRC2dL2e+ -SQ1KajPbe/Nv7SpVnQ3brOWdUcs9fIZa56QyV6tU1XpLwKVnhW1aynPEzORkVW7p -6MYsTKBHInNxcAXlRPsyE8ooOfduO0kCggEBAI6yl6Cqv/Yc8wEkews2aIS0oUav -HF9QGoSWP/yJcX7w4C09L1jemdqJxIzZRJ5dN298PIKdEDuQT59FwC0qgIzNgG9q -7VI6XZXh3+W9jC7wmp89eUbrj7yPpkREJg3bP9C6d4cFxJQCUACukDfRz896WIUf -VKJLsXeebs0Ond6+hDX+HKPoCKdpbvIDUZd5FUJkNFh5EoSwkuo5mCAyTTWYkKSl -JuiUdViT+RkvX3XzxVVBgZsS70mu/Iur/Qbz74rbMeEoReAfOYtXC22rzMD3rQsZ -/uzCpGWsh32ywI/C+ESWSLAo+HZGL0gbrILQbnBknX2Yq8iUvnkB7W8/igs= ------END RSA PRIVATE KEY----- \ No newline at end of file diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/client.req b/test/mocks/pnfsimulator/netconfsimulator/tls/client.req deleted file mode 100644 index ace54c096..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/client.req +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIE0zCCArsCAQAwWjELMAkGA1UEBhMCUEwxCzAJBgNVBAgMAkROMRAwDgYDVQQH -DAdXcm9jbGF3MQ4wDAYDVQQKDAVOb2tpYTENMAsGA1UECwwETWFubzENMAsGA1UE -AwwET25hcDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALWQSjpwDKQC -o0ThHnfxUmflHNuzkcMOT37QcLGASn/uy5ExYs6B4bn8v6dGCsstwU+xzCcjAgdR -QTWnPKNoO7HpxeOm2j7UA+r+x3Wh9UwyXcj/OpyuqiOLGMUk7Ug2A3+LUJoB4FE7 -6Y2YhQ0gkrLYptNi9NhgmslvMhGHU0GxS+4jO+PlaSrdyuLigmbPzaWw0MCHgEZ5 -1ZBPhFSaNv8QLsP1al86UyGyAtUmA90bkRIWo37HH+fjElRwz8capWV9kQPlcNx9 -COnnoFoUGk2EtbjWpXLxSh6LFiJ24tpW8oOglzYRrc3+nITdhTUsE7LvOelQtfdR -0xv5tfmMafi5q4rPvuEtkDme6uBvy/Wh9uPUYIzbwl9qI9G0i5ZW1Yoj7xHIqNpe -Mp3+twZb/lP1oz26b+Ufa/8O15pNriLzN5svuT8MkVNc/4MK0lOLx7bddqWSn474 -xZBCsZE7Ts0d2XWCMOYShzc0xE7nVTHkIPKoJuEXhB1fQ0P68MmYPwYG7FvoDceN -2ZPn+IGIfn8c7oVEcWEy1H3EAGvJPTWBiQNYkezNNK00vH9nNbgPPeLZbKgS8Nra -Z4uRKHl50TWySjBmuJJ6g64ZYmV+mOO+fWniSOTSayDdPwSAmpm70CIrO5WAgtry -7oqfLz+nXYw37KW0HTaGIlnIyXIkMKfdAgMBAAGgNDAYBgkqhkiG9w0BCQIxCwwJ -Y29sbGVjdG9yMBgGCSqGSIb3DQEJBzELDAljb2xsZWN0b3IwDQYJKoZIhvcNAQEL -BQADggIBAG4zPJVwotinJdDfBY8sGj6ARcWNtRuCmLj4Xri6pzzvUCaSLFAvIkd1 -Tdm7uIrfUMU+/stvu2E1myWJGnITL8njUahMqrTwI0yZF3Do8bw12kr9lf3wDNLT -CvPApGpUEegcGQS/pp6ksa7zd4iDkWPLqf4CqnooDKprPQXz2HL2clBCmSrD2u61 -zTVey/G6FCU1tfAXisykmF2pElC8AJpY9EkY/ShSwk31n3ARe0XZAqo9NfcwvgAx -isqevdXQ+D/FROjVwSKb8CB1rANn36ziZRMz02cyVj3FLbOgSBsrAfunbLNDyQ9z -C3FYNA/tTtaPlwL8aOz0T5N6iyjmpqcvlFFFB+H5zg1tP0rcYwGnto3d85GgBYBF -BK+ikAzYgZlpB48VceMQydZk3aMOcUIVSWpzsVhr9GkUYmYE6DxSZlzXGs75FkFf -aP7/Qqf8Ut8G8fZV2QziOcuMbCnZ2fZl/lLLHO6A4e86bDyUjqPQK/LPylvJGgmY -CivXpuBVA7j5SZZ4YnwqtWe4xh5vgbxZU7sq9omHnJaLfINHfQepeHcL4mWRo1oP -xnacKz0ju2rlPNRN2jFciFQnZTUvmWO5KvoipadyjWqd7QzM0J4rdW56+a4tR1LA -0JiV+yzsq9NB6/wKGGtwjYOEhr5AJOEb3qJPNJ45KI3nag2l3HWj ------END CERTIFICATE REQUEST----- \ No newline at end of file diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/server.req b/test/mocks/pnfsimulator/netconfsimulator/tls/server.req deleted file mode 100644 index 7e3e70a0d..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/server.req +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIIEuTCCAqECAQAwWjELMAkGA1UEBhMCUEwxCzAJBgNVBAgMAkROMRAwDgYDVQQH -DAdXcm9jbGF3MQ4wDAYDVQQKDAVOb2tpYTENMAsGA1UECwwETWFubzENMAsGA1UE -AwwET25hcDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALFl14dsyahU -bDm8WxD2VPGHOy8CccW77WFyxbUUM0JxfawM8cJC8AZlb2RRVNmwsq5mtQa5XWnp -rZBx1BaMmN+ek201QSec5m3Nwesz6m7w8xIn+JJqrerdQ6vDqKTsCIINhekHgNAb -3QdRnIE2dSk8ORZgVTPxNMyLG832U/8lGic2yi+P/jB3j4Ianx33k18GUb851H60 -DSDYkT1QDP97DSw/2k2YThljBcUKaKKuajJpA+IwL2s7vDbaJj1neIuE+tDSKZAS -TPzUJSS9d0yFk090wI42idZ9szByP+v08hBQDc4Uo0CWUrSxebKJ8Z7k347U3uG6 -MEjY6FqjL7y4oZo670fjiKiOnJVRxFDdj/5DR37hFGjHg1x6BSRt4aJ4SSdYuNu5 -X2LGijqJ6FBeKc+TZfj4g1eH2bLvEI03Z0V1Q2p8qq59jVJAb5U2qwPRU30JRrFY -R84kPj8xV1xi3tZke0T0nszCLnDa5oCImm1Q31Ncbe1ZruSNNmGhpjGqe+nGaLOg -jSQaoYfe982i9hhsEIgLOtOLSOYSRsIwd6tWoH5WrsrkotTawby9dMDA7ghkQ8lL -xkuLkcm/VIKrqCofkP1KNi0NzAa4F3HXhwN8xd/UrbYz5jjjh0s6DOxX5Eu5P1+7 -JIGnuSc2Trd2iHSob2Cf97a5OrQ7/farAgMBAAGgGjAYBgkqhkiG9w0BCQcxCwwJ -Y29sbGVjdG9yMA0GCSqGSIb3DQEBCwUAA4ICAQCJb4dJS4ddeL/IzuOA6kKpqOz/ -YJUECLCRPSvdf5DCH/ezf5L+UE8WUpcvSkRo36rwBPR/R2hDnshfKUYYZoi5UqzT -+Y7E3Kdrim4K9MGJGVTqtIYqoNS0jgbmX2zw7FDXHBVfP2TQhalzBO4BMshB916o -IWs8esTRNhXZ7P4hDOkYyWp4qPeOjzdUgqEQosz+OkB+RdVpKfs3sG0eqZRDVnHz -Hk7cfpn6m9OZf+0aLlAlhs1d9KvvdmUn0vC3QVktPLXZpa1XNTrE7tml3crYNmU0 -JSuP7MBwgjJMBe400aIXIKssqVUJjlAzNARFWo/84Fzb6QuyfVwNp1tMzBAFFDc3 -BOv891fwIKAOKRSSui2Eq3nxt6+8JTTx8YeuppS79V50XNl6PolY5jDEkxED7sst -ScpU7rOURDfgT2EdqjWzSmW7JzBuuTkAz4T/lg4dAspKacVi9hG28Jt+gX6xlM5Y -qS43o2YhSze4PfOgjkUIvqSiDa6uORMJPi5iCwGVpomKfMtZCmXrPiCyQg6u8TqJ -LXA9pm++mehgj79kl+yb8A2eQvIqEb8eOG/CzZjW5IZxLZgKk/AjAcBn0yhhIrVq -6rBaIlVbXOdxMsxxVgyktziA7DFCt/1TvQylSn9hWaBkpdjVlbFmMyuNU+KHZA41 -8raJhp+mC5IUG/98UQ== ------END CERTIFICATE REQUEST----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/server_cert.crt b/test/mocks/pnfsimulator/netconfsimulator/tls/server_cert.crt deleted file mode 100644 index 5909026f9..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/server_cert.crt +++ /dev/null @@ -1,30 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFKDCCAxACAWQwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UEBhMCUEwxCzAJBgNV -BAgMAkRTMRAwDgYDVQQHDAdXcm9jbGF3MQ4wDAYDVQQKDAVOb2tpYTENMAsGA1UE -CwwETWFubzENMAsGA1UEAwwET25hcDAeFw0xOTExMDYxNTEzMjJaFw0yMzExMDUx -NTEzMjJaMFoxCzAJBgNVBAYTAlBMMQswCQYDVQQIDAJETjEQMA4GA1UEBwwHV3Jv -Y2xhdzEOMAwGA1UECgwFTm9raWExDTALBgNVBAsMBE1hbm8xDTALBgNVBAMMBE9u -YXAwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCxZdeHbMmoVGw5vFsQ -9lTxhzsvAnHFu+1hcsW1FDNCcX2sDPHCQvAGZW9kUVTZsLKuZrUGuV1p6a2QcdQW -jJjfnpNtNUEnnOZtzcHrM+pu8PMSJ/iSaq3q3UOrw6ik7AiCDYXpB4DQG90HUZyB -NnUpPDkWYFUz8TTMixvN9lP/JRonNsovj/4wd4+CGp8d95NfBlG/OdR+tA0g2JE9 -UAz/ew0sP9pNmE4ZYwXFCmiirmoyaQPiMC9rO7w22iY9Z3iLhPrQ0imQEkz81CUk -vXdMhZNPdMCONonWfbMwcj/r9PIQUA3OFKNAllK0sXmyifGe5N+O1N7hujBI2Oha -oy+8uKGaOu9H44iojpyVUcRQ3Y/+Q0d+4RRox4NcegUkbeGieEknWLjbuV9ixoo6 -iehQXinPk2X4+INXh9my7xCNN2dFdUNqfKqufY1SQG+VNqsD0VN9CUaxWEfOJD4/ -MVdcYt7WZHtE9J7Mwi5w2uaAiJptUN9TXG3tWa7kjTZhoaYxqnvpxmizoI0kGqGH -3vfNovYYbBCICzrTi0jmEkbCMHerVqB+Vq7K5KLU2sG8vXTAwO4IZEPJS8ZLi5HJ -v1SCq6gqH5D9SjYtDcwGuBdx14cDfMXf1K22M+Y444dLOgzsV+RLuT9fuySBp7kn -Nk63doh0qG9gn/e2uTq0O/32qwIDAQABMA0GCSqGSIb3DQEBCwUAA4ICAQBqW8/0 -u85VTUWA8tpfjqgmMd9WdM5YVty/oRQ3sT+1k6mdPF2u8HgTD5vNR71XEkpQuNbZ -9UrJ1UOgcbxcodDh2v2Jv5faSyQBnmkSjagyH+7goN/mcM+CtIZQsdp8drzlty/M -x1CeVW54jVrInk01yS3cATCdxqkel9nhTT0qcPOmHxugTyTwApzwN4dRMf1WHQ9B -U1K95yWvscZdY2cMKRw3Ps90+AU8eSoAbV1qQEl95qcWani7LPNfc8nii3nCINBR -KTdbP1uG8hck4BFxOZye6mbNMx086T7O3Buzcve5O/3isCCZQhV6PZIE7zL5+hyY -RLx7MxUUETy4QFapGCfOGvixK8QM/xXJone2CjnmptiRJjC11Imv84bL3KUziKPR -DTyX2f4oKEwaVpbfJgyyxMmoNUAB2NaKNAW9NhvYjVqmCUvgrvL7L6WZTe9N5gkX -H7cQZ7PyAdgGKet0b0Spr8NfBATyZKNI6ZRcGJduO7sOblqAsC6GToq7Jcz9xkYd -ItNdhoDohZIDwW1XnHuNKgE1tEXm1KAbdlGrUEOTsyuK4bz4kDdVu58/nFT4ZYnC -2HSyLwsNNeKChwdVFL8d/Rj9ojjVyUBH6wuQHRAcs0Ui2Cpy+OPWcNjDuHjkiw2J -KEzFqRi6zQqj1y2Sjv1HQpn8dxppKOsV6rjoXQ== ------END CERTIFICATE----- diff --git a/test/mocks/pnfsimulator/netconfsimulator/tls/server_key.pem b/test/mocks/pnfsimulator/netconfsimulator/tls/server_key.pem deleted file mode 100644 index b10a07608..000000000 --- a/test/mocks/pnfsimulator/netconfsimulator/tls/server_key.pem +++ /dev/null @@ -1,51 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIJKQIBAAKCAgEAsWXXh2zJqFRsObxbEPZU8Yc7LwJxxbvtYXLFtRQzQnF9rAzx -wkLwBmVvZFFU2bCyrma1BrldaemtkHHUFoyY356TbTVBJ5zmbc3B6zPqbvDzEif4 -kmqt6t1Dq8OopOwIgg2F6QeA0BvdB1GcgTZ1KTw5FmBVM/E0zIsbzfZT/yUaJzbK -L4/+MHePghqfHfeTXwZRvznUfrQNINiRPVAM/3sNLD/aTZhOGWMFxQpooq5qMmkD -4jAvazu8NtomPWd4i4T60NIpkBJM/NQlJL13TIWTT3TAjjaJ1n2zMHI/6/TyEFAN -zhSjQJZStLF5sonxnuTfjtTe4bowSNjoWqMvvLihmjrvR+OIqI6clVHEUN2P/kNH -fuEUaMeDXHoFJG3honhJJ1i427lfYsaKOonoUF4pz5Nl+PiDV4fZsu8QjTdnRXVD -anyqrn2NUkBvlTarA9FTfQlGsVhHziQ+PzFXXGLe1mR7RPSezMIucNrmgIiabVDf -U1xt7Vmu5I02YaGmMap76cZos6CNJBqhh973zaL2GGwQiAs604tI5hJGwjB3q1ag -flauyuSi1NrBvL10wMDuCGRDyUvGS4uRyb9UgquoKh+Q/Uo2LQ3MBrgXcdeHA3zF -39SttjPmOOOHSzoM7FfkS7k/X7skgae5JzZOt3aIdKhvYJ/3trk6tDv99qsCAwEA -AQKCAgEAiN5OgAoLPHiGV7VffaLQvtjbbNWx+iGYcMsghylisyzlDU2faYZDsmuo -mfm2QY73DV/o45s423KTmxJ31D395OpwTJ39+xYvIyDRMSsJATeeErAMNMtiDAdT -Ir7+6t/BYLYWT0ietfIJgpAQ9BCULJBuazlAA6diWT4q4anf/McfeonnTPMH51UX -wAXSJkjRx0sU3zk7HdbFGkZ9KJUOsj66Vx2czKlp+GRSG0iAmqN/BA3KFUWgEFgy -Sw/c2RtwAhVDfsHnl2THSXpUfhhAZyXYFkG6Hv8tMfQhwIsljmOaL8PUIuABZN+W -SBt2Da4oYbOsWIMcw4PnpQzVmLi3JtajPMI5vJJQtNbgEKQwl7Xewhyfjdy61vVZ -k3UBKzeRX78pW9BXpBrLlp3AcU3/jE+HihWzkaz5mXD2raOPJRXGHr9di2egttQx -Fxdc4YRWTH/k6Eo/M20A7q1RiIkwKthKru0Ju2U0g4Szwn0vuAqs1+QEMhbZ/Z79 -p9KzKg6g+X125W4JxNLWSli0uQmmyYkUYsBXXPMRmlpqjhXN35plRPdlLVm6WgOT -QhGta69Az4+rVJis5zlYXVBF7P8ympP5IDKAeBWbEfm6ZW2dWF3R8KOD1LA86Ctw -+n5NUoLQutGl5qrpFHEYyQO0RhJApFe808Gj4XZ0NbRKWYZYNuECggEBAOQVG7LF -LDRWMe8t2aYsblOkJqdz5Nv+wvN7t7rRGeUZJ0mcy8QbqbRbYCbpelNYJQaV/qUM -pDJc6D0xmdocGmKO5gTy6RxXGynB0pQW6Z3BavpQiCsQy0SsNGtdrP7nJ6uKwgfI -WBlzQxk1RhLet60jcik9bRvc0x4TI03qIAVKfXk5XrSuvXxDaEFFfBIwclucK00g -qkWDmVLaZbKisSgAod8DHZC2HroNbePQphGpPZPu5MfUKRhD0cjJmc90NIW1Teph -cbjcl4bMfjZgjZgxMu+EKweqwikMolzMeR6QNlwDOER9BnXOrW9RLIOa2KWDLHTu -7BKubWYEr2G9eoUCggEBAMcci/OGkAeB+aw6GgqRHxQVzbV05ItO8OZa1TdP5/s9 -8ZcqbcxejhdTGw92OjI5mjlc4r8DPrJy9AHkZNoUYcuS8qPK3x1k+roqvtXnGFeP -xvEMRXQIv+GQe+aF75qMS2+hUq11daP8KmkqDvife5sPcS0zf1vdkeoj2fPOIC/G -NMw5EjQEMHFj5I9N5tQr47GkWgKDaaM24tW4jxMMuDAnVH70iXbZm6GdqBGTPGV1 -cwM5KJKbP4d0WMnAm1NLCtGpxXzFiRD6xLWdikntdaM5eGOthkhbENadiEXYPfyb -fCdV3XtIDYTbs41VruI4I/QR9kqXJD4dTJpve9Ozq28CggEAOn+zd/mcadwFuKvQ -3A8fSPKcO2y9MTO5esurhw3kj18RNY8ysBzMPQcGtVRC3KeJ75N/GYQRhR1RL4jO -RiPZHJg8JN7MrUkmHWKqCPOLfbvDHWqUUj9fc0CbvUHsggB1q0jOlUJsXjKy7f88 -9tAK2ixyNmOb3X6Y42jTMEOxbMn7PqFZSgxba0i6r6sLtHqaiiaW8JRFN8kWBSsg -1F1oBLOM0O8yoRAk92FEYx77ySHYOl4Wba5bz+5tGwuiGJRceELVNh1CFsD1WEyQ -vo+rIXLU9pu2kaPZYr/r0NNc6Vrhpl3pC5/pjUOyNg/i0+peUK1BNMim4e+8/WKM -PQxlJQKCAQEAmM9e1TpLpYdqD3TT8ZIo0Ohe5MlecU/XcGL7yiSIPHjwxfwpIjTb -Rilg1j/9L/inVSjlWIVsA9ZXUHBxujD0USFpGK2lCFEsX95YcZ+XPfQ5UVwCnaft -Y3bYsDXQisLrTjP4WOmRrJXmEqnVrZfwbDOwv2kLcHye9JwpNITYjPHIKYgPYV5p -s0xf6F94LRO1/urMrasfUsTX2AB5xbv4S/STU4/nRBCD8cgmab6fFprJ9wpSChod -6p4vWj94tbcdCYYK69RKen6Ko3vR2yTkKK39qDpPmY5SYPOr1za7c/f8k8/BWFEX -FwTqSykcO7+sUC/M3rgad5VS6h9vYC0+/wKCAQA5ANtXDECYCLTor0PHFxnRswfo -7qZNn7HrrisRcJjdHsnGyW2KNQjrVYmidEBzN/AWpmr2qfSRp3xh++oLswYeJ2cR -HC87Ws6xy17Mcd39sB9poE6XWfoTb4YYotrp1A2rJMaNbFOvkoPpMWJRzvgOgR9I -XNvUFBlIJ/iNr9r08XzElEcqlonR10RwxpASHgq9PnNd6kxNCIzMJVBDnW1lpYHn -PucG5sjhMjpuDNXvo0rKUoJEs37N2KeTngTWscGhdPfcIFJrw4d6Yyo89ORcc+Sc -G+vn3AHyzlIPXMfG8cDWTKA+rfGQhKSp6+OWBKX/ZatFD8a0X0L4aBoKXpUk ------END RSA PRIVATE KEY----- diff --git a/test/mocks/pnfsimulator/pnfsimulator/.gitignore b/test/mocks/pnfsimulator/pnfsimulator/.gitignore deleted file mode 100644 index 3fa204a3b..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.idea -target -*.iml -logs diff --git a/test/mocks/pnfsimulator/pnfsimulator/Dockerfile b/test/mocks/pnfsimulator/pnfsimulator/Dockerfile deleted file mode 100644 index aafea0e45..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM openjdk:8-jre-alpine -ADD target/libs /app/libs -ADD target/pnfsimulator-5.0.0-SNAPSHOT.jar /app/pnf-simulator.jar -CMD apk update -CMD apk add ca-certificates -ADD certificates /usr/local/share/ca-certificates/ -RUN update-ca-certificates -CMD java -Dspring.config.location=file:/app/application.properties -cp /app/libs/*:/app/pnf-simulator.jar org.onap.pnfsimulator.Main diff --git a/test/mocks/pnfsimulator/pnfsimulator/README.md b/test/mocks/pnfsimulator/pnfsimulator/README.md deleted file mode 100644 index 6caa64410..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/README.md +++ /dev/null @@ -1,333 +0,0 @@ -# PNF Simulator -Simulator that generates VES events related to PNF PNP integration. - -## Usage of simulator -### Setting up -Preferred way to start simulator is to use `docker-compose up -d` command. -All required docker images will be downloaded from ONAP Nexus, however there is possibility to build those -images locally. It can be achieve by invoking `mvn clean package docker:build` from top directory. - -### API -Simulator provides REST endpoints which can be used to trigger sending events to VES. - -*Periodic event sending* -To trigger sending use following endpoint *http://:5000/simulator/start*. -Supported method: *POST* -Headers: - - Content-Type - application/json -Parameters: - - simulatorParams: - repeatCount - determines how many events will be sent - repeatInterval - time (in seconds) between events - vesServerUrl - valid path to VES Collector - templateName - name of template file (check *Templates* section) - patch - part of event which will be merged into template - - -Sample Request: - - { - "simulatorParams": { - "repeatCount": 5, - "repeatInterval": 2, - "vesServerUrl": "http://VES-HOST:8080/eventListener/v7" - }, - "templateName": "validExampleMeasurementEvent.json", - "patch": { - "event": { - "commonEventHeader": { - "eventId": "PATCHED_eventId", - "sourceName": "PATCHED_sourceName", - "version": 3.0 - } - } - } - } - -*One-time event sending* -Enables direct, immediate event sending without need to have template deployed on backend. -Keywords are supported,thus once passed, will also be substituted with proper strings. -Passed event body must be valid and complete event according to VES Collector interface. -To trigger sending use following endpoint *http://:5000/simulator/event*. - -Supported method: *POST* -Headers: - - Content-Type - application/json -Parameters: - - vesServerUrl - valid URL to VES Collector event listener - event - body of event to be sent directly to VES Collector (it can contain keyword expressions) - - -Sample Request: - - { - "vesServerUrl": "http://VES-HOST:8080/eventListener/v7", - "event": { - "commonEventHeader": { - "eventId": "#RandomString(20)", - "sourceName": "PATCHED_sourceName", - "version": 3.0 - } - } - } - -### Changing simulator configuration -Utility of default configuration has been introduced so as to facilitate sending requests. so far only vesServerUrl states default simulator configuration. -On simulator startup, vesServerUrl is initialized with default value, but must be replaced with correct VES server url by user. -Once vesServerUrl is properly set on simulator, this parameter does not need to be incorporated into every trigger event request. -If user does not provide vesServerUrl in trigger request, default value will be used. -If use does provide vesServerUrl in trigger request, then passed value will be used instead of default one (default value will not be overwritten by provided one). - -It is possible to get and update configuration (current target vesServerUrl) using offered REST API - */simulator/config* endpoint is exposed for that. -To get current configuration *GET* method must be used. -To update vesServerUrl *PUT* method is used, example request: - - { - "vesServerUrl": "http://10.154.164.117:8080/eventListener/v7" - } - -Note: passed vesServerUrl must be wellformed URL. - - -### Running simulator -The recommended way is to checkout PNF Simulator project from ONAP Git repository and use *simulator*.sh script. -If you copy *simulator.sh* script to another location, keep in mind to copy also *docker-compose.yml* and directories: *config and templates*. -In order to run simulator, invoke ./simulator.sh -e build to build required images and then invoke ./simulator.sh -e start -Script downloads if necessary needed Docker images and runs instances of these images. -After simulator start it is advisable to setup default value for target vesServerUrl. - -Example request: - - PUT to http://:/simulator/config - - { - "vesServerUrl": "PUT HERE VALID URL TO YOUR VES EVENT LISTENER" - } - -### Templates -Template is a draft event. Merging event with patch will result in valid VES event. Template itself should be a correct VES event as well as valid json object. -In order to apply custom template, just copy it to ./templates directory. -*notification.json* and *registration.json* are available by default in *./templates* directory. - -#### Template management -The simulator provides means for managing templates. Supported actions: adding, editing (overriding) and deleting are available via HTTP endpoint */template* - -```GET /template/list``` -Lists all templates known to the simulator. - -```GET /template/get-content/{name}``` -Gets template content based on *name* path variable. - -```POST /template/upload?override=true``` -Saves template content under *name* path variable. The non-mandatory parameter *override* allows overwriting an existing template. - -Sample payload: -``` -{ - "name": "someTemplate", - "template": { - "commonEventHeader": { - "domain": "notification", - "eventName": "vFirewallBroadcastPackets" - }, - "notificationFields": { - "arrayOfNamedHashMap": [{ - "name": "A20161221.1031-1041.bin.gz", - "hashMap": { - "fileformatType": "org.3GPP.32.435#measCollec" - } - }] - } - } -} -``` - -### Searching for key-value conditions in stored templates -Simulator allows to search through stored templates and retrieve names of those that satisfy given criteria passed in form of key-value pairs (See examples below). -Following data types are supported in search as values: --integer --string --double --boolean -Searching for null values as well as incorporating regex expression with intention to find a match is not supported. -Search expression must be valid JSON, thus no duplicate keys are allowed - user could specify the same parameter multiple times, but only last occurrence will be applied to query. -Example search expression: - -{"domain": "notification", "sequence": 1, "startEpochMicrosec": 1531616794, "sampleDouble": 2.5} - -will find all templates that contain all of passed key-value entries. There is an AND condition beetwen given criteria - all of them must be satisfied to qualify template as matching item. - Keys of search expressions are searched in case insensitive way as well as string values. -Where it comes to values of numerical and boolean type exact match is expected. - -API usage: - -```POST /template/search``` -Produces query that returns templates that contain searched criteria - -Sample payload: -``` -{ - "searchExpr": { - "domain": "notification", - "sequence": 1, - "startEpochMicrosec": 1531616794, - "sampleDouble": 2.5 - } -} -``` -Sample response: -``` -[notification.json] -``` - - -Note: Manually deployed templates, or actually existing ones, but modified inside the templates catalog '/app/templates', will be automatically synchronized with schemas stored inside the database. That means that a user can dynamically change the template content using vi editor at simulator container, as well as use any editor at any machine and then push the changes to the template folder. All the changes will be processed 'on the fly' and accessible via the rest API. - -### Periodic events -Simulator has ability to send event periodically. Rest API support parameters: -* repeatCount - count of times that event will be sent to VES -* repeatInterval - interval (in second) between two events. -(Checkout example to see how to use them) - -### Patching -User is able to provide patch in request, which will be merged into template. - -Warning: Patch should be a valid json object (no json primitives nor json arrays are allowed as a full body of patch). - -This mechanism allows to override part of template. -If in "patch" section there are additional parameters (absent in template), those parameters with values will be added to event. -Patching mechanism supports also keywords that enables automatic value generation of appropriate type - -### Keyword support -Simulator supports corresponding keywords: -- \#RandomInteger(start,end) - substitutes keyword with random positive integer within given range (range borders inclusive) -- \#RandomPrimitiveInteger(start,end) - the same as #RandomInteger(start,end), but returns long as result -- \#RandomInteger - substitutes keyword with random positive integer -- \#RandomString(length) - substitutes keyword with random ASCII string with specified length -- \#RandomString - substitutes keyword with random ASCII string with length of 20 characters -- \#Timestamp - substitutes keyword with current timestamp in epoch (calculated just before sending event) -- \#TimestampPrimitive - the same as \#Timestamp, but returns long as result -- \#Increment - substitutes keyword with positive integer starting from 1 - for each consecutive event, value of increment property is incremented by 1 - -Additional hints and restrictions: -All keywords without 'Primitive' in name return string as result. To specify keyword with 2 arguments e.g. #RandomInteger(start,end) no whitespaces between arguments are allowed. -Maximal value of arguments for RandomInteger is limited to the java integer range. Minimal is always 0. (Negative values are prohibited and wont be treated as a correct parts of keyword). -RandomInteger with parameters will automatically find minimal and maximal value form the given attributes so no particular order of those is expected. - -How does it work? -When user do not want to fill in parameter values that are not relevant from user perspective but are mandatory by end system, then keyword feature should be used. -In template, keyword strings are substituted in runtime with appropriate values autogenerated by simulator. -Example can be shown below: - -Example template with keywords: - - { - "event": { - "commonEventHeader": { - "eventId": "123#RandomInteger(8,8)", - "eventType": "pnfRegistration", - "startEpochMicrosec": "#Timestamp", - "vesEventListenerVersion": "7.0.1", - "lastEpochMicrosec": 1539239592379 - }, - "pnfRegistrationFields": { - "pnfRegistrationFieldsVersion":"2.0", - "serialNumber": "#RandomString(7)", - "vendorName": "Nokia", - "oamV4IpAddress": "val3", - "oamV6IpAddress": "val4" - } - } - } - -Corresponding result of keyword substitution (event that will be sent): - - { - "event": { - "commonEventHeader": { - "eventId": "1238", - "eventType": "pnfRegistration", - "startEpochMicrosec": "154046405117", - "vesEventListenerVersion": "7.0.1", - "lastEpochMicrosec": 1539239592379 - }, - "pnfRegistrationFields": { - "pnfRegistrationFieldsVersion":"2.0", - "serialNumber": "6061ZW3", - "vendorName": "Nokia", - "oamV4IpAddress": "val3", - "oamV6IpAddress": "val4" - } - } - } - - -### Logging -Every start of simulator will generate new logs that can be found in docker pnf-simualtor container under path: -/var/log/ONAP/pnfsimulator/pnfsimulator_output.log - -### Swagger -Detailed view of simulator REST API is available via Swagger UI -Swagger UI is available on *http://:5000/swagger-ui.html* - -### History -User is able to view events history. -In order to browse history, go to *http://:8081/db/pnf_simulator/eventData* - -### TLS Support -Simulator is able to communicate with VES using HTTPS protocol. -CA certificates are incorporated into simulator docker image, thus no additional actions are required from user. - -Certificates can be found in docker container under path: */usr/local/share/ca-certificates/* - -Simulator works with VES that uses both self-signed certificate (already present in keystore) and VES integrated to AAF. - - -## Developers Guide - -### Integration tests -Integration tests are located in folder 'integration'. Tests are using docker-compose from root folder. -This docker-compose has pnfsimulator image set on nexus3.onap.org:10003/onap/pnf-simulator:5.0.0-SNAPSHOT. -To test your local changes before running integration tests please build project using: - - 'mvn clean package docker:build' - -then go to 'integration' folder and run: - - 'mvn test' - -### Client certificate authentication -Simulator can cooperate with VES server in different security types in particular ```auth.method=certBasicAuth``` which means that it needs to authenticate using client private certificate. - -Warning: according to VES implementation which uses certificate with Common Name set to DCAELOCAL we decided not to use strict hostname verification, so at least this parameter is skipped during checking of the client certificate. - -#### How to generate client correct keystore for pnf-simulator - The Root CA cert is available in certs folder in VES repository. The password for rootCA.key is collector. - - The procedure of generating client's certificate: - 1. Generate a private key for the SSL client: ```openssl genrsa -out client.key 2048``` - 2. Use the client’s private key to generate a cert request: ```openssl req -new -key client.key -out client.csr``` - 3. Issue the client certificate using the cert request and the CA cert/key: ```openssl x509 -req -in client.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out client.crt -days 500 -sha256``` - 4. Convert the client certificate and private key to pkcs#12 format: openssl pkcs12 -export -inkey client.key -in client.cer -out client.p12 - 5. Copy pkcs file into pnf simulators folder: ```/app/store/``` - -#### How to generate correct truststore for pnf-simulator - Create truststore with rootCA.crt: - 1. ```keytool -import -file rootCA.crt -alias firstCA -keystore trustStore``` - 2. Copy truststore to ```/app/store/``` - -#### How to refresh configuration of app -Depends your needs, you are able to change client certificate, replace trustStore to accept new server certificate change keystore and truststore passwords or completely disable client cert authentication. - -For this purpose: -1. Go to the pnf simulator container into the /app folder. -2. If you want to replace keystore or truststore put them into the /app/store folder. -3. Edit /app/application.properties file as follow: -- ssl.clientCertificateEnabled=true (to disable/enable client authentication) -- ssl.clientCertificateDir=/app/store/client.p12 (to replace keystore file) -- ssl.clientCertificatePassword=collector (to replace password for keystore) -- ssl.trustStoreDir=/app/store/trustStore (to replace truststore file) -- ssl.trustStorePassword=collector (to replace password for truststore) -4. Refresh configuration sending simple POST request to correct actuator endpoint at: ```curl http://localhost:5001/refresh -H 'Content-type: application/json' -X POST --data '{}'``` diff --git a/test/mocks/pnfsimulator/pnfsimulator/certificates/AAF_RootCA.crt b/test/mocks/pnfsimulator/pnfsimulator/certificates/AAF_RootCA.crt deleted file mode 100644 index e9a50d7ea..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/certificates/AAF_RootCA.crt +++ /dev/null @@ -1,31 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIFPjCCAyagAwIBAgIJAJ6u7cCnzrWdMA0GCSqGSIb3DQEBCwUAMCwxDjAMBgNV -BAsMBU9TQUFGMQ0wCwYDVQQKDARPTkFQMQswCQYDVQQGEwJVUzAeFw0xODA0MDUx -NDE1MjhaFw0zODAzMzExNDE1MjhaMCwxDjAMBgNVBAsMBU9TQUFGMQ0wCwYDVQQK -DARPTkFQMQswCQYDVQQGEwJVUzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC -ggIBAMA5pkgRs7NhGG4ew5JouhyYakgYUyFaG121+/h8qbSdt0hVQv56+EA41Yq7 -XGie7RYDQK9NmAFF3gruE+6X7wvJiChp+Cyd7sFMnb65uWhxEdxWTM2BJFrgfzUn -H8ZCxgaCo3XH4PzlKRy2LQQJEJECwl/RZmRCXijMt5e9h8XoZY/fKkKcZZUsWNCM -pTo266wjvA9MXLmdgReRj0+vrCjrNqy+htwJDztoiHWiYPqT6o8EvGcgjNqjlZx7 -NUNf8MfLDByqKF6+wRbHv1GKjn3/Vijd45Fv8riyRYROiFanvbV6jIfBkv8PZbXg -2VDWsYsgp8NAvMxK+iV8cO+Ck3lBI2GOPZbCEqpPVTYbLUz6sczAlCXwQoPzDIZY -wYa3eR/gYLY1gP2iEVHORag3bLPap9ZX5E8DZkzTNTjovvLk8KaCmfcaUMJsBtDd -ApcUitz10cnRyZc1sX3gE1f3DpzQM6t9C5sOVyRhDcSrKqqwb9m0Ss04XAS9FsqM -P3UWYQyqDXSxlUAYaX892u8mV1hxnt2gjb22RloXMM6TovM3sSrJS0wH+l1nznd6 -aFXftS/G4ZVIVZ/LfT1is4StoyPWZCwwwly1z8qJQ/zhip5NgZTxQw4mi7ww35DY -PdAQOCoajfSvFjqslQ/cPRi/MRCu079heVb5fQnnzVtnpFQRAgMBAAGjYzBhMB0G -A1UdDgQWBBRTVTPyS+vQUbHBeJrBKDF77+rtSTAfBgNVHSMEGDAWgBRTVTPyS+vQ -UbHBeJrBKDF77+rtSTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAN -BgkqhkiG9w0BAQsFAAOCAgEAPx/IaK94n02wPxpnYTy+LVLIxwdq/kawNd6IbiMz -L87zmNMDmHcGbfoRCj8OkhuggX9Lx1/CkhpXimuYsZOFQi5blr/u+v4mIbsgbmi9 -7j+cUHDP0zLycvSvxKHty51LwmaX9a4wkJl5zBU4O1sd/H9tWcEmwJ39ltKoBKBx -c94Zc3iMm5ytRWGj+0rKzLDAXEWpoZ5bE5PLJauA6UDCxDLfs3FwhbS7uDggxYvf -jySF5FCNET94oJ+m8s7VeHvoa8iPGKvXrIqdd7XDHnqJJlVKr7m9S0fMbyEB8ci2 -RtOXDt93ifY1uhoEtEykn4dqBSp8ezvNMnwoXdYPDvTd9uCAFeWFLVreBAWxd25h -PsBTkZA5hpa/rA+mKv6Af4VBViYr8cz4dZCsFChuioVebe9ighrfjB//qKepFjPF -CyjzKN1u0JKm/2x/ORqxkTONG8p3uDwoIOyimUcTtTMv42bfYD88RKakqSFXE9G+ -Z0LlaKABqfjK49o/tsAp+c5LoNlYllKhnetO3QAdraHwdmC36BhoghzR1jpX751A -cZn2VH3Q4XKyp01cJNCJIrua+A+bx6zh3RyW6zIIkbRCbET+UD+4mr8WIcSE3mtR -ZVlnhUDO4z9//WKMVzwS9Rh8/kuszrGFI1KQozXCHLrce3YP6RYZfOed79LXaRwX -dYY= ------END CERTIFICATE----- diff --git a/test/mocks/pnfsimulator/pnfsimulator/certificates/dcaelocal.crt b/test/mocks/pnfsimulator/pnfsimulator/certificates/dcaelocal.crt deleted file mode 100644 index 1be5a6fb2..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/certificates/dcaelocal.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDSDCCAjCgAwIBAgIEWAkZ5jANBgkqhkiG9w0BAQUFADBmMQswCQYDVQQGEwJV -UzELMAkGA1UECBMCTkoxEzARBgNVBAcTCk1pZGRsZXRvd24xDTALBgNVBAoTBERD -QUUxEjAQBgNVBAsTCU9QRU4tRENBRTESMBAGA1UEAxMJRENBRUxPQ0FMMB4XDTE2 -MTAyMDE5MjQyMloXDTE3MDExODE5MjQyMlowZjELMAkGA1UEBhMCVVMxCzAJBgNV -BAgTAk5KMRMwEQYDVQQHEwpNaWRkbGV0b3duMQ0wCwYDVQQKEwREQ0FFMRIwEAYD -VQQLEwlPUEVOLURDQUUxEjAQBgNVBAMTCURDQUVMT0NBTDCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBALoR0omXk1Xou3TdDydwhCF9V0ZSgQtMlMr8qYxe -wLg/UGZbTea5HHqBmjWTVEKFGea7V7pnEiGWCPftIy/4D8ZSDaEQQ0WYCf6jNxeI -T6PSiM+db/TwPToqPNMQwoftpsAEkJEJFB9rgUXoDD9FY5kUQW+fYOLyUeOb/rDE -cRnSZX2qp1M/jAm1puIeNQcqiPExOMHqnN2bIgAZoHaFucdyOQUxuhIAgxoqe8Zt -s451hm94g42F92I8KLy4EyOhXmSMjaLmgOqdjOPyBubOde4R39+6KAyQNGAnm5I4 -xq2J80R7qU0+4nnfjs2ScfAB/HUsWoVaGr9Ii4e34CW8JG8CAwEAATANBgkqhkiG -9w0BAQUFAAOCAQEARqQmWg1gtwbgPbamWy0vdNWLQZm78y1ETR0ro9cazD25sD5/ -anDJ2RA97pGQFgncAI+Fzg4YygWBIext0OE92wQeKaHkxSujAe09F0wPcwc00Vyq -NtBPcP17n18FkpFW1hkurlWiHOpGDRW2MmwhLj4lSFJmxMBAbzlfKrTBgj116UT+ -d4AGyuovS4LkmBWYFN//yoddGyrO26ar1M9ORdbDkjzOK4DkioTx3bwbdKPW7V4a -+Ns1KDFZ7FpjcWPZc6uDV4lBIhNUZuQZLy5hWBUeNhh4i2lL6xMrPzRa5kV1M7og -ipv/ReVCixJqsGhx+8I4OPUbPoUYzRF+JmYUzA== ------END CERTIFICATE----- \ No newline at end of file diff --git a/test/mocks/pnfsimulator/pnfsimulator/config/config.json b/test/mocks/pnfsimulator/pnfsimulator/config/config.json deleted file mode 100644 index af45632f3..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/config/config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "simulatorParams": { - "vesServerUrl": "http://VES-HOST:VES-PORT/eventListener/v7", - "repeatInterval": 10, - "repeatCount": 2 - }, - "templateName": "notification.json", - "patch": {} -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/db/pnf_simulator.js b/test/mocks/pnfsimulator/pnfsimulator/db/pnf_simulator.js deleted file mode 100644 index f5a03c3d0..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/db/pnf_simulator.js +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -const res = [ - db.createUser({ user: 'pnf_simulator_user', pwd: 'zXcVbN123!', roles: ['readWrite', 'dbAdmin'] }), - db.simulatorConfig.insert({"vesServerUrl": "http://xdcae-ves-collector.onap:8080/eventListener/v7"}), - db.createCollection("template"), - db.createView("flatTemplatesView", "template", [{"$project":{"keyValues":{"$objectToArray": "$$ROOT.flatContent"}}}]) -]; - -printjson(res); diff --git a/test/mocks/pnfsimulator/pnfsimulator/deployment/PnP_PNF_sim_heat_template.yml b/test/mocks/pnfsimulator/pnfsimulator/deployment/PnP_PNF_sim_heat_template.yml deleted file mode 100644 index 6f9b5f02f..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/deployment/PnP_PNF_sim_heat_template.yml +++ /dev/null @@ -1,118 +0,0 @@ -description: Heat template that deploys PnP PNF simulator -heat_template_version: '2013-05-23' -parameters: - flavor_name: {description: Type of instance (flavor) to be used, label: Flavor, - type: string} - image_name: {description: Image to be used for compute instance, label: Image name - or ID, type: string} - key_name: {description: Public/Private key pair name, label: Key pair name, type: string} - public_net_id: {description: Public network that enables remote connection to VNF, - label: Public network name or ID, type: string} - private_net_id: {type: string, description: Private network id, label: Private network name or ID} - private_subnet_id: {type: string, description: Private subnet id, label: Private subnetwork name or ID} - proxy: {type: string, description: Proxy, label: Proxy, default: ""} -resources: - PNF_PnP_simualtor: - type: OS::Nova::Server - properties: - key_name: { get_param: key_name } - image: { get_param: image_name } - flavor: { get_param: flavor_name } - networks: - - port: { get_resource: PNF_PnP_simualtor_port0 } - user_data_format: RAW - user_data: - str_replace: - template: | - #!/bin/bash - - set_versions () { - DOCKER_COMPOSE_VERSION=1.22.0 - } - - - enable_root_ssh () { - sed -i 's/PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config - sed -i 's/PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config - service sshd restart - echo -e "arthur\narthur" | passwd root - } - - update_os () { - dnf -y install fedora-upgrade - } - - docker_remove () { - dnf -y remove docker \ - docker-client \ - docker-client-latest \ - docker-common \ - docker-latest \ - docker-latest-logrotate \ - docker-logrotate \ - docker-selinux \ - docker-engine-selinux \ - docker-engine - } - - docker_install_and_configure () { - dnf -y install dnf-plugins-core - dnf config-manager \ - --add-repo \ - https://download.docker.com/linux/fedora/docker-ce.repo - dnf -y install docker-ce - systemctl start docker - mkdir -p /etc/systemd/system/docker.service.d/ - cat > /etc/systemd/system/docker.service.d/override.conf<< EOF - [Service] - Environment="HTTP_PROXY=$proxy" - Environment="HTTPS_PROXY=$proxy" - EOF - systemctl daemon-reload - systemctl restart docker - } - docker_compose_install () { - curl -L https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose - chmod +x /usr/local/bin/docker-compose - } - pnf_sim_file_checkout () { - cd /root; git clone https://gerrit.onap.org/r/integration - printf "{\n "simulatorParams": {\n "vesServerUrl": "http://VES-HOST:VES-PORT/eventListener/v7",\n "testDuration": "10",\n "messageInterval": "1"\n },\n "commonEventHeaderParams": {\n "eventName": "pnfRegistration_Nokia_5gDu",\n "nfNamingCode": "gNB",\n "nfcNamingCode": "oam",\n "sourceName": "NOK6061ZW3",\n "sourceId": "val13",\n "reportingEntityName": "NOK6061ZW3"\n },\n "pnfRegistrationParams": {\n "serialNumber": "6061ZW3",\n "vendorName": "Nokia",\n "oamV4IpAddress": "val3",\n "oamV6IpAddress": "val4",\n "unitFamily": "BBU",\n "modelNumber": "val6",\n "softwareVersion": "val7",\n "unitType": "val8"\n }\n}" > integration/test/mocks/pnfsimulator/config/config.json - } - - start_simulator () { - docker login -u docker -p docker nexus3.onap.org:10003 - cd ~/integration/test/mocks/pnfsimulator - ./simulator.sh start - } - - set_versions - enable_root_ssh - update_os - docker_remove - docker_install_and_configure - docker_compose_install - pnf_sim_file_checkout - start_simulator - params: - $proxy: { get_param: proxy } - PNF_PnP_simualtor_port0: - type: OS::Neutron::Port - properties: - network_id: { get_param: private_net_id } - security_groups: - - default - fixed_ips: - - subnet_id: { get_param: private_subnet_id } - PNF_PnP_simualtor_public: - type: OS::Neutron::FloatingIP - properties: - floating_network_id: { get_param: public_net_id } - port_id: { get_resource: PNF_PnP_simualtor_port0 } -outputs: - PNF_PnP_simualtor_private_ip: - description: IP address of PNF_PnP_simualtor in private network - value: { get_attr: [ PNF_PnP_simualtor, first_address ] } - PNF_PnP_simualtor_public_ip: - description: Floating IP address of PNF_PnP_simualtor in public network - value: { get_attr: [ PNF_PnP_simualtor_public, floating_ip_address ] } diff --git a/test/mocks/pnfsimulator/pnfsimulator/docker-compose.yml b/test/mocks/pnfsimulator/pnfsimulator/docker-compose.yml deleted file mode 100644 index 23797fed3..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/docker-compose.yml +++ /dev/null @@ -1,38 +0,0 @@ -version: '3' - -services: - - mongo: - image: mongo - restart: always - environment: - MONGO_INITDB_ROOT_USERNAME: root - MONGO_INITDB_ROOT_PASSWORD: zXcVbN123! - MONGO_INITDB_DATABASE: pnf_simulator - volumes: - - ./db:/docker-entrypoint-initdb.d - ports: - - "27017:27017" - - mongo-express: - image: mongo-express - restart: always - ports: - - 8081:8081 - environment: - ME_CONFIG_MONGODB_ADMINUSERNAME: root - ME_CONFIG_MONGODB_ADMINPASSWORD: zXcVbN123! - - pnf-simulator: - image: nexus3.onap.org:10003/onap/pnfsimulator - ports: - - "5000:5000" - volumes: - - ./logs:/var/log - - ./templates:/app/templates - - ./store:/app/store - - ./src/main/resources/application.properties:/app/application.properties - restart: on-failure - depends_on: - - mongo - - mongo-express diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/pom.xml b/test/mocks/pnfsimulator/pnfsimulator/integration/pom.xml deleted file mode 100644 index 21c2f3c49..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/pom.xml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - 4.0.0 - - - org.onap.simulator - simulator-parent - 5.0.0-SNAPSHOT - - - pnf-simulator-integration - - - dl.bintray.com - https://dl.bintray.com/palantir/releases - - - - - 1.8 - 1.8 - - - - - - org.assertj - assertj-core - 3.9.1 - test - - - - org.springframework.boot - spring-boot-starter - 2.0.2.RELEASE - - - org.springframework.boot - spring-boot-starter-web - 2.0.2.RELEASE - - - - io.rest-assured - rest-assured - 3.2.0 - - - org.mongodb - mongo-java-driver - 3.9.1 - - - - org.springframework - spring-test - 5.0.4.RELEASE - test - - - org.springframework.boot - spring-boot-starter-test - 2.0.1.RELEASE - test - - - com.google.code.gson - gson - 2.8.2 - - - com.palantir.docker.compose - docker-compose-rule-junit4 - 0.34.0 - - - - - - - - - onap-license - none - - - onap-java-style - none - - - maven-checkstyle-plugin - 2.17 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12.1 - - - - **/*Suite.java - - - - - - diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/Main.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/Main.java deleted file mode 100644 index 7288c2a28..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/Main.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.pnfsimulator.integration; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; - -@SpringBootApplication -@EnableAsync -public class Main { - - public static void main(String[] args) { - SpringApplication.run(Main.class, args); - } -} - - diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorController.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorController.java deleted file mode 100644 index 70e0c609c..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorController.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RequestMapping("ves-simulator") -@RestController -public class VesSimulatorController { - - private final VesSimulatorService vesSimulatorService; - private final Gson gson; - - @Autowired - public VesSimulatorController(VesSimulatorService vesSimulatorService, Gson gson) { - this.vesSimulatorService = vesSimulatorService; - this.gson = gson; - } - - @PostMapping("eventListener/v5") - String sendEventToDmaapV5(@RequestBody String body) { - System.out.println("Received event" + body); - JsonObject jsonObject = gson.fromJson(body, JsonObject.class); - vesSimulatorService.sendEventToDmaapV5(jsonObject); - return "MessageAccepted"; - } - - @PostMapping("eventListener/v7") - String sendEventToDmaapV7(@RequestBody String body) { - System.out.println("Received event" + body); - JsonObject jsonObject = gson.fromJson(body, JsonObject.class); - vesSimulatorService.sendEventToDmaapV7(jsonObject); - return "MessageAccepted"; - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorService.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorService.java deleted file mode 100644 index 65e5d3e13..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/java/org/onap/pnfsimulator/integration/VesSimulatorService.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import com.google.gson.JsonObject; -import org.springframework.stereotype.Service; - -@Service -public class VesSimulatorService { - - void sendEventToDmaapV5(JsonObject jsonObject) { - //JUST FOR TESTING PURPOSE - } - - void sendEventToDmaapV7(JsonObject jsonObject) { - //JUST FOR TESTING PURPOSE - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/application.properties b/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/application.properties deleted file mode 100644 index 205ed95fb..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8000 \ No newline at end of file diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/keystore b/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/keystore deleted file mode 100644 index 26a16f756..000000000 Binary files a/test/mocks/pnfsimulator/pnfsimulator/integration/src/main/resources/keystore and /dev/null differ diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/BasicAvailabilityTest.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/BasicAvailabilityTest.java deleted file mode 100644 index 9f11a00a0..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/BasicAvailabilityTest.java +++ /dev/null @@ -1,235 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import static io.restassured.RestAssured.given; -import static io.restassured.RestAssured.when; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.hamcrest.Matchers.equalTo; - -import com.google.gson.JsonObject; -import java.io.IOException; -import java.net.Inet4Address; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collections; -import java.util.UUID; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.mockito.internal.util.Timer; -import org.mockito.internal.verification.VerificationOverTimeImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = {Main.class, TestConfiguration.class}, webEnvironment = WebEnvironment.DEFINED_PORT) -public class BasicAvailabilityTest { - - @Autowired - VesSimulatorController vesSimulatorController; - - @Autowired - VesSimulatorService vesSimulatorService; - - private final String ACTION_START = "start"; - - private String currenVesSimulatorIp; - - @Before - public void setUp() throws Exception { - currenVesSimulatorIp = getCurrentIpAddress(); - } - - @After - public void tearDown() { - Mockito.reset(vesSimulatorService); - } - - @Test - public void simulatorShouldFailWhenTriggeredNonexistentTemplate(){ - //given - String startUrl = prepareRequestUrl(ACTION_START); - String body = "{\n" - + "\"templateName\": \"any_nonexistent_template.json\",\n" - + "\"patch\":{},\n" - + "\"simulatorParams\": {\n" - + "\"vesServerUrl\": \"https://" + currenVesSimulatorIp + ":9443/ves-simulator/eventListener/v5\",\n" - + "\"repeatInterval\": 1,\n" - + "\"repeatCount\": 1\n" - + "}\n" - + "}"; - - //when - given() - .contentType("application/json") - .body(body) - .when() - .post(startUrl) - .then() - .statusCode(400) - .body("message", equalTo("Cannot start simulator - template any_nonexistent_template.json not found.")); - } - - @Test - public void whenTriggeredSimulatorShouldSendSingleEventToVes() { - //given - String startUrl = prepareRequestUrl(ACTION_START); - String body = "{\n" - + "\"templateName\": \"notification.json\",\n" - + "\"patch\":{},\n" - + "\"simulatorParams\": {\n" - + "\"vesServerUrl\": \"https://" + currenVesSimulatorIp + ":9443/ves-simulator/eventListener/v5\",\n" - + "\"repeatInterval\": 1,\n" - + "\"repeatCount\": 1\n" - + "}\n" - + "}"; - ArgumentCaptor parameterCaptor = ArgumentCaptor.forClass(JsonObject.class); - - //when - given() - .contentType("application/json") - .body(body) - .when() - .post(startUrl) - .then() - .statusCode(200) - .body("message", equalTo("Request started")); - - Mockito.verify(vesSimulatorService, - Mockito.timeout(3000)) - .sendEventToDmaapV5(parameterCaptor.capture()); - - assertThat(parameterCaptor.getValue() - .getAsJsonObject("event") - .getAsJsonObject("commonEventHeader") - .get("domain").getAsString()).isEqualTo("notification"); - } - - @Test - public void simulatorShouldCorrectlyRespondOnCancellAllEvent() { - //given - String ACTION_CANCEL_ALL = "cancel"; - String cancelAllUrl = prepareRequestUrl(ACTION_CANCEL_ALL); - - //when - when() - .post(cancelAllUrl) - .then() - .statusCode(200) - .body("message", equalTo("Event(s) was cancelled")); - - } - - @Test - public void simulatorBeAbleToUseNewlyAddedTemplate() throws IOException { - //given - String templateBody = "{\"fake\":\"template\"}\n"; - String fileName = UUID.randomUUID() + ".json"; - String requestBody = "{\n" - + "\"templateName\": \"" + fileName + "\",\n" - + "\"patch\":{},\n" - + "\"simulatorParams\": {\n" - + "\"vesServerUrl\": \"https://" + currenVesSimulatorIp + ":9443/ves-simulator/eventListener/v5\",\n" - + "\"repeatInterval\": 1,\n" - + "\"repeatCount\": 1\n" - + "}\n" - + "}"; - ArgumentCaptor parameterCaptor = ArgumentCaptor.forClass(JsonObject.class); - - //when - Path newFile = Files.createFile(Paths.get("..", "templates", fileName)); - Files.write(newFile, templateBody.getBytes()); - - given() - .contentType("application/json") - .body(requestBody) - .when() - .post(prepareRequestUrl(ACTION_START)); - - Files.delete(newFile); - - //then - Mockito.verify(vesSimulatorService, Mockito.timeout(3000)) - .sendEventToDmaapV5(parameterCaptor.capture()); - assertThat(parameterCaptor.getValue() - .get("fake").getAsString()).isEqualTo("template"); - - } - - @Test - public void whenTriggeredSimulatorShouldSendGivenAmountOfEventsToVes() { - //given - String startUrl = prepareRequestUrl(ACTION_START); - String body = "{\n" - + "\"templateName\": \"notification.json\",\n" - + "\"patch\":{},\n" - + "\"simulatorParams\": {\n" - + "\"vesServerUrl\": \"https://" + currenVesSimulatorIp + ":9443/ves-simulator/eventListener/v5\",\n" - + "\"repeatInterval\": 1,\n" - + "\"repeatCount\": 4\n" - + "}\n" - + "}"; - ArgumentCaptor parameterCaptor = ArgumentCaptor.forClass(JsonObject.class); - - //when - given() - .contentType("application/json") - .body(body) - .when() - .post(startUrl) - .then() - .statusCode(200) - .body("message", equalTo("Request started")); - - VerificationOverTimeImpl verificator = new VerificationOverTimeImpl(100, Mockito.times(4), false, new Timer(6000)); - Mockito.verify(vesSimulatorService, verificator).sendEventToDmaapV5(parameterCaptor.capture()); - - for (JsonObject value : parameterCaptor.getAllValues()) { - assertThat(value - .getAsJsonObject("event") - .getAsJsonObject("commonEventHeader") - .get("domain").getAsString()).isEqualTo("notification"); - } - } - - private String prepareRequestUrl(String action) { - return "http://0.0.0.0:5000/simulator/" + action; - } - - private String getCurrentIpAddress() throws SocketException { - return Collections.list(NetworkInterface.getNetworkInterfaces()).stream() - .flatMap(i -> Collections.list(i.getInetAddresses()).stream()) - .filter(ip -> ip instanceof Inet4Address) - .map(e -> (Inet4Address) e) - .findFirst() - .orElseThrow(RuntimeException::new) - .getHostAddress(); - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/OptionalTemplatesTest.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/OptionalTemplatesTest.java deleted file mode 100644 index a5ffe4d47..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/OptionalTemplatesTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import static io.restassured.RestAssured.given; -import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.hamcrest.Matchers.equalTo; - -import com.google.gson.JsonObject; -import com.mongodb.MongoClient; -import com.mongodb.MongoClientOptions; -import com.mongodb.MongoCredential; -import com.mongodb.ServerAddress; -import com.mongodb.client.FindIterable; -import com.mongodb.client.MongoCollection; -import com.mongodb.client.MongoCursor; -import com.mongodb.client.MongoDatabase; -import java.time.Instant; -import java.net.Inet4Address; -import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; -import java.util.Collections; -import org.assertj.core.api.Assertions; -import org.bson.Document; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = {Main.class, TestConfiguration.class}, webEnvironment = WebEnvironment.DEFINED_PORT) -public class OptionalTemplatesTest { - - private static final String PNF_SIMULATOR_DB = "pnf_simulator"; - private static final String COMMON_EVENT_HEADER = "commonEventHeader"; - private static final String PNF_SIMULATOR_DB_PSWD = "zXcVbN123!"; - private static final String PNF_SIMULATOR_DB_USER = "pnf_simulator_user"; - private static final String PATCHED = "patched"; - private static final String SINGLE_EVENT_URL = "http://0.0.0.0:5000/simulator/event"; - - @Autowired - VesSimulatorController vesSimulatorController; - - @Autowired - private VesSimulatorService vesSimulatorService; - - private String currentVesSimulatorIp; - - @Before - public void setUp() throws Exception { - currentVesSimulatorIp = getCurrentIpAddress(); - } - - @After - public void tearDown() { - Mockito.reset(vesSimulatorService); - } - - @Test - public void whenTriggeredSimulatorWithoutTemplateShouldSendSingleEventToVes() { - //given - long currentTimestamp = Instant.now().getEpochSecond(); - - String body = "{\n" - + "\"vesServerUrl\": \"https://" + currentVesSimulatorIp + ":9443/ves-simulator/eventListener/v5\",\n" - + "\"event\": { \n" - + "\"commonEventHeader\": {\n" - + "\"eventId1\": \"#RandomString(20)\",\n" - + "\"eventId2\": \"#RandomInteger(10,10)\",\n" - + "\"eventId3\": \"#Increment\",\n" - + "\"eventId4\": \"#RandomPrimitiveInteger(10,10)\",\n" - + "\"eventId5\": \"#TimestampPrimitive\",\n" - + "\"sourceName\": \"Single_sourceName\",\n" - + "\"version\": 3" - + "}\n" - + "}\n" - + "}"; - ArgumentCaptor parameterCaptor = ArgumentCaptor.forClass(JsonObject.class); - - //when - given() - .contentType("application/json") - .body(body) - .when() - .post(SINGLE_EVENT_URL) - .then() - .statusCode(202) - .body("message", equalTo("One-time direct event sent successfully")); - - //then - long afterExecution = Instant.now().getEpochSecond(); - Mockito.verify(vesSimulatorService, - Mockito.timeout(3000)) - .sendEventToDmaapV5(parameterCaptor.capture()); - - JsonObject value = parameterCaptor.getValue(); - assertThat(value - .getAsJsonObject(COMMON_EVENT_HEADER) - .get("sourceName").getAsString()).isEqualTo("Single_sourceName"); - assertThat(value - .getAsJsonObject(COMMON_EVENT_HEADER) - .get("eventId1").getAsString().length()).isEqualTo(20); - assertThat(value - .getAsJsonObject(COMMON_EVENT_HEADER) - .get("eventId2").getAsString()).isEqualTo("10"); - assertThat(value - .getAsJsonObject(COMMON_EVENT_HEADER) - .get("eventId3").getAsString()).isEqualTo("1"); - assertThat(value - .getAsJsonObject(COMMON_EVENT_HEADER) - .get("eventId4").getAsInt()).isEqualTo(10); - assertThat(value - .getAsJsonObject(COMMON_EVENT_HEADER) - .get("eventId5").getAsLong()).isBetween(currentTimestamp, afterExecution); - } - - @Test - public void whenTriggeredSimulatorWithoutTemplateEventShouldBeVisibleInDB() throws UnknownHostException { - //given - String body = "{\n" - + "\"vesServerUrl\": \"https://" + currentVesSimulatorIp + ":9443/ves-simulator/eventListener/v5\",\n" - + "\"event\": { \n" - + "\"commonEventHeader\": {\n" - + "\"sourceName\": \"HistoricalEvent\",\n" - + "\"version\": 3" - + "}\n" - + "}\n" - + "}"; - ArgumentCaptor parameterCaptor = ArgumentCaptor.forClass(JsonObject.class); - - //when - given() - .contentType("application/json") - .body(body) - .when() - .post(SINGLE_EVENT_URL) - .then() - .statusCode(202) - .body("message", equalTo("One-time direct event sent successfully")); - - //then - Mockito.verify(vesSimulatorService, - Mockito.timeout(3000)) - .sendEventToDmaapV5(parameterCaptor.capture()); - - Document sourceNameInMongoDB = findSourceNameInMongoDB(); - Assertions.assertThat(sourceNameInMongoDB.get(PATCHED)) - .isEqualTo("{\"commonEventHeader\":{\"sourceName\":\"HistoricalEvent\",\"version\":3}}"); - } - - private Document findSourceNameInMongoDB() throws UnknownHostException { - MongoCredential credential = MongoCredential - .createCredential(PNF_SIMULATOR_DB_USER, PNF_SIMULATOR_DB, PNF_SIMULATOR_DB_PSWD.toCharArray()); - MongoClient mongoClient = new MongoClient(new ServerAddress(Inet4Address.getLocalHost(), 27017), - credential, MongoClientOptions.builder().build()); - MongoDatabase pnfSimulatorDb = mongoClient.getDatabase(PNF_SIMULATOR_DB); - MongoCollection table = pnfSimulatorDb.getCollection("eventData"); - Document searchQuery = new Document(); - searchQuery.put(PATCHED, new Document("$regex", ".*" + "HistoricalEvent" + ".*")); - FindIterable findOfPatched = table.find(searchQuery); - Document dbObject = null; - MongoCursor cursor = findOfPatched.iterator(); - if (cursor.hasNext()) { - dbObject = cursor.next(); - } - return dbObject; - } - - private String getCurrentIpAddress() throws SocketException { - return Collections.list(NetworkInterface.getNetworkInterfaces()).stream() - .flatMap(i -> Collections.list(i.getInetAddresses()).stream()) - .filter(ip -> ip instanceof Inet4Address) - .map(e -> (Inet4Address) e) - .findFirst() - .orElseThrow(RuntimeException::new) - .getHostAddress(); - } - -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/SearchInTemplatesTest.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/SearchInTemplatesTest.java deleted file mode 100644 index 9d4ff3b8e..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/SearchInTemplatesTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import static io.restassured.RestAssured.given; -import static java.nio.file.Files.readAllBytes; - -import io.restassured.http.Header; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import org.hamcrest.Matchers; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.util.ResourceUtils; - -public class SearchInTemplatesTest { - - private static final String UPLOAD = "upload"; - private static final String SEARCH = "search"; - private static final String APPLICATION_JSON = "application/json"; - private static final String CONTENT_TYPE = "Content-Type"; - - @BeforeClass - public static void setUp() throws IOException { - for (File file : readFileFromTemplatesFolder()) { - byte[] body = readAllBytes(file.toPath()); - - given() - .body(body) - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(UPLOAD) + "?override=true") - .then() - .statusCode(201); - } - } - - @Test - public void shouldFindNothingWhenNonexistentValueIsProvided(){ - given() - .body("{\"searchExpr\": { \"child3\": \"nonexistentValue\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.empty()); - } - - @Test - public void shouldFindNothingWhenNonexistentKeyIsProvided(){ - given() - .body("{\"searchExpr\": { \"nonexistentKey\": \"Any value 1\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.empty()); - } - - @Test - public void shouldFindNothingWhenPartOfKeyIsProvided(){ - given() - .body("{\"searchExpr\": { \"child\": \"Any value 1\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.empty()); - } - - @Test - public void shouldFindNothingWhenPartOfValueIsProvided(){ - given() - .body("{\"searchExpr\": { \"child5\": \"Any\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.empty()); - } - - @Test - public void shouldBeAbleToSearchForString(){ - given() - .body("{\"searchExpr\": { \"child1\": \"Any value 1\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_array.json", "complicated_template.json", "simple_template.json")); - - given() - .body("{\"searchExpr\": { \"child2\": \"any value 4\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_array.json")); - } - - @Test - public void shouldBeAbleToSearchForManyStrings(){ - given() - .body("{\"searchExpr\": { \"child1\": \"Any value 1\", \"child2\": \"any value 2\"}}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("simple_template.json", "complicated_template.json")); - } - - @Test - public void shouldBeAbleToSearchForStarSign(){ - given() - .body("{\"searchExpr\": { \"child2\": \"*\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("complicated_template.json")); - } - - @Test - public void shouldBeAbleToSearchForQuestionMark(){ - given() - .body("{\"searchExpr\": { \"child1\": \"?\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("complicated_template.json")); - } - - @Test - public void shouldBeAbleToSearchForBrackets(){ - given() - .body("{\"searchExpr\": { \"parent2\": \"[]\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_array.json")); - } - - @Test - public void shouldInformThatSearchForNullsIsProhibited(){ - given() - .body("{\"searchExpr\": { \"child3\": null }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(400); - } - - @Test - public void shouldBeAbleToSearchForURI(){ - given() - .body("{\"searchExpr\": { \"child3\": \"https://url.com?param1=test¶m2=*\" }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("complicated_template.json")); - } - - @Test - public void shouldBeAbleToSearchForFloats(){ - given() - .body("{\"searchExpr\": { \"child2\": 4.44 }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_array.json")); - - given() - .body("{\"searchExpr\": { \"child5\": 4.4 }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("complicated_template.json", "template_with_floats.json")); - } - - @Test - public void shouldBeAbleToSearchForIntegers(){ - given() - .body("{\"searchExpr\": { \"child2\": 1 }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_array.json", "template_with_ints.json")); - - given() - .body("{\"searchExpr\": { \"child2\": 4 }}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_array.json")); - } - - @Test - public void shouldBeAbleToSearchForBooleans(){ - given() - .body("{\"searchExpr\": { \"child4\": true}}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_booleans.json")); - - given() - .body("{\"searchExpr\": { \"parent2\": false}}") - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(SEARCH)) - .then() - .statusCode(200) - .body("", Matchers.hasItems("template_with_booleans.json")); - } - - - private static String prepareRequestUrl(String action) { - return "http://0.0.0.0:5000/template/" + action; - } - - private static File[] readFileFromTemplatesFolder() throws FileNotFoundException { - return ResourceUtils.getFile("classpath:templates/search").listFiles(); - } - -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TemplatesManagementTest.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TemplatesManagementTest.java deleted file mode 100644 index 7e74dd493..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TemplatesManagementTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import static io.restassured.RestAssured.given; - -import io.restassured.http.Header; -import io.restassured.path.json.JsonPath; -import io.restassured.path.json.config.JsonPathConfig; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Map; -import org.hamcrest.Matchers; -import org.json.JSONException; -import org.json.JSONObject; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.ResourceUtils; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = {Main.class, TestConfiguration.class}, webEnvironment = WebEnvironment.DEFINED_PORT) -public class TemplatesManagementTest { - - private static final String LIST_URL = "list"; - private static final String GET_URL = "get/"; - private static final String UPLOAD = "upload"; - private static final String NOTIFICATION_JSON = "notification.json"; - private static final String REGISTRATION_JSON = "registration.json"; - private static final String UPLOAD_TEMPLATE_JSON = "upload_template.json"; - private static final String OVERWRITE_TEMPLATE_JSON = "overwrite_template.json"; - private static final String OVERWRITTEN_TEMPLATE_JSON = "overwritten_template.json"; - private static final String APPLICATION_JSON = "application/json"; - private static final String CONTENT_TYPE = "Content-Type"; - private static final String FORCE_FLAG = "?override=true"; - private static final String CONTENT = "content"; - private static final String TEMPLATE = "template"; - private static final String ID = "id"; - - @Test - public void whenCallingGetShouldReceiveNotificationTemplate() throws IOException { - given() - .when() - .get(prepareRequestUrl(GET_URL) + NOTIFICATION_JSON) - .then() - .statusCode(200) - .body(ID, Matchers.equalTo(NOTIFICATION_JSON)) - .body(CONTENT, Matchers.equalTo(readTemplateFromResources(NOTIFICATION_JSON).getMap(CONTENT))); - } - - @Test - public void whenCallingGetShouldReceiveRegistrationTemplate() throws IOException { - given() - .when() - .get(prepareRequestUrl(GET_URL) + REGISTRATION_JSON) - .then() - .statusCode(200) - .body(ID, Matchers.equalTo(REGISTRATION_JSON)) - .body(CONTENT, Matchers.equalTo(readTemplateFromResources(REGISTRATION_JSON).getMap(CONTENT))); - } - - @Test - public void whenCallingListShouldReceiveAllPredefinedTemplates() throws IOException { - Map registration = readTemplateFromResources(REGISTRATION_JSON).getMap(CONTENT); - Map notification = readTemplateFromResources(NOTIFICATION_JSON).getMap(CONTENT); - - given() - .when() - .get(prepareRequestUrl(LIST_URL)) - .then() - .statusCode(200) - .body(CONTENT, Matchers.hasItems( - registration, - notification - )); - } - - @Test - public void whenCallingUploadAndGetShouldReceiveNewTemplate() throws IOException { - byte[] body = Files.readAllBytes(readFileFromTemplatesFolder(UPLOAD_TEMPLATE_JSON)); - - given() - .body(body) - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(UPLOAD)) - .then() - .statusCode(201); - - given() - .when() - .get(prepareRequestUrl(GET_URL) + UPLOAD_TEMPLATE_JSON) - .then() - .statusCode(200) - .body(ID, Matchers.equalTo(UPLOAD_TEMPLATE_JSON)) - .body(CONTENT, Matchers.equalTo(readTemplateFromResources(UPLOAD_TEMPLATE_JSON).getMap(TEMPLATE))); - } - - @Test - public void whenCallingOverrideAndGetShouldReceiveNewTemplate() throws IOException, JSONException { - byte[] body = Files.readAllBytes(readFileFromTemplatesFolder(OVERWRITE_TEMPLATE_JSON)); - - given() - .body(body) - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(UPLOAD)) - .then() - .statusCode(201); - - JSONObject overwrittenBody = new JSONObject(new String(body)); - JSONObject overwrittenTemplate = new JSONObject("{\"field1\": \"overwritten_field1\"}"); - overwrittenBody.put(TEMPLATE, overwrittenTemplate); - - given() - .body(overwrittenBody.toString().getBytes()) - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(UPLOAD)) - .then() - .statusCode(409); - - given() - .body(overwrittenBody.toString().getBytes()) - .header(new Header(CONTENT_TYPE, APPLICATION_JSON)) - .when() - .post(prepareRequestUrl(UPLOAD + FORCE_FLAG)) - .then() - .statusCode(201); - - given() - .when() - .get(prepareRequestUrl(GET_URL) + OVERWRITE_TEMPLATE_JSON) - .then() - .statusCode(200) - .body(ID, Matchers.equalTo(OVERWRITE_TEMPLATE_JSON)) - .body(CONTENT, Matchers.equalTo(readTemplateFromResources(OVERWRITTEN_TEMPLATE_JSON).getMap(CONTENT))); - } - - private String prepareRequestUrl(String action) { - return "http://0.0.0.0:5000/template/" + action; - } - - private JsonPath readTemplateFromResources(String templateName) throws IOException { - byte[] content = Files.readAllBytes(readFileFromTemplatesFolder(templateName)); - return new JsonPath(new String(content)).using(new JsonPathConfig("UTF-8")); - } - - private Path readFileFromTemplatesFolder(String templateName) throws FileNotFoundException { - return ResourceUtils.getFile("classpath:templates/"+templateName).toPath(); - } - -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TestConfiguration.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TestConfiguration.java deleted file mode 100644 index 19ae050c5..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/TestConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration; - -import org.mockito.Mockito; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -@Configuration -public class TestConfiguration { - - @Bean - @Primary - VesSimulatorService provideVesSimulatorService() { - return Mockito.mock(VesSimulatorService.class); - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/suites/DockerBasedTestsSuite.java b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/suites/DockerBasedTestsSuite.java deleted file mode 100644 index cc2ac588f..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/java/org/onap/pnfsimulator/integration/suites/DockerBasedTestsSuite.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.integration.suites; - -import com.palantir.docker.compose.DockerComposeRule; -import com.palantir.docker.compose.connection.waiting.HealthChecks; -import org.junit.ClassRule; -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; -import org.onap.pnfsimulator.integration.BasicAvailabilityTest; -import org.onap.pnfsimulator.integration.OptionalTemplatesTest; -import org.onap.pnfsimulator.integration.SearchInTemplatesTest; -import org.onap.pnfsimulator.integration.TemplatesManagementTest; - -@RunWith(Suite.class) -@SuiteClasses({BasicAvailabilityTest.class, TemplatesManagementTest.class, OptionalTemplatesTest.class, - SearchInTemplatesTest.class}) -public class DockerBasedTestsSuite { - - @ClassRule - public static DockerComposeRule docker = DockerComposeRule.builder() - .file("../docker-compose.yml") - .waitingForService("pnf-simulator", HealthChecks.toHaveAllPortsOpen()) - .waitingForService("mongo", HealthChecks.toHaveAllPortsOpen()) - .build(); - -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/application.properties b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/application.properties deleted file mode 100644 index c3e147200..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/application.properties +++ /dev/null @@ -1,6 +0,0 @@ -server.port=9443 -security.require-ssl=true -server.ssl.key-store=src/main/resources/keystore -server.ssl.key-store-password=collector -server.ssl.keyStoreType=JKS -server.ssl.keyAlias=tomcat \ No newline at end of file diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/notification.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/notification.json deleted file mode 100644 index 0b4ff2ead..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/notification.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "id": "notification.json", - "content": { - "event": { - "commonEventHeader": { - "domain": "notification", - "eventName": "vFirewallBroadcastPackets", - "eventId": "4cfc-91cf-31a46", - "priority": "Normal", - "reportingEntityName": "myVNF", - "sequence": 1, - "sourceName": "ClosedLoopVNF", - "startEpochMicrosec": 1531616794, - "lastEpochMicrosec": 1531719042, - "vesEventListenerVersion": "7.0.1", - "version": "4.0.1" - }, - "notificationFields": { - "changeIdentifier": "PM_MEAS_FILES", - "changeType": "FileReady", - "arrayOfNamedHashMap": [ - { - "name": "A20161221.1031-1041.bin.gz", - "hashMap": { - "fileformatType": "org.3GPP.32.435#measCollec", - "fileFormatVersion": "V10", - "location": "ftpes://192.169.0.1:22/ftp/rop/A20161224.1030-1045.bin.gz", - "compression": "gzip" - } - }, - { - "name": "A20161222.1042-1102.bin.gz", - "hashMap": { - "fileFormatType": "org.3GPP.32.435#measCollec", - "fileFormatVersion": "V10", - "location": "ftpes://192.168.0.102:22/ftp/rop/A20161224.1045-1100.bin.gz", - "compression": "gzip" - } - } - ], - "notificationFieldsVersion": "2.0" - } - } - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwrite_template.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwrite_template.json deleted file mode 100644 index 55bf7636e..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwrite_template.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "overwrite_template.json", - "template": { - "field1": "field1" - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwritten_template.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwritten_template.json deleted file mode 100644 index 28e7381b3..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/overwritten_template.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "id": "overwrite_template.json", - "content": { - "field1": "overwritten_field1" - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/registration.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/registration.json deleted file mode 100644 index 8b7908ead..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/registration.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "id": "registration.json", - "content": { - "event": { - "commonEventHeader": { - "eventId": "registration_39239592", - "eventType": "pnfRegistration", - "reportingEntityName": "NOK6061ZW3", - "domain": "pnfRegistration", - "nfcNamingCode": "oam", - "sequence": 0, - "sourceId": "val13", - "internalHeaderFields": {}, - "priority": "Normal", - "sourceName": "NOK6061ZW3", - "eventName": "pnfRegistration_Nokia_5gDu", - "version": "4.0.1", - "nfNamingCode": "gNB", - "startEpochMicrosec": 1539239592379, - "vesEventListenerVersion": "7.0.1", - "lastEpochMicrosec": 1539239592379 - }, - "pnfRegistrationFields": { - "pnfRegistrationFieldsVersion": "2.0", - "serialNumber": "6061ZW3", - "vendorName": "Nokia", - "oamV4IpAddress": "val3", - "oamV6IpAddress": "val4", - "unitFamily": "BBU", - "modelNumber": "val6", - "softwareVersion": "val7", - "unitType": "val8" - } - } - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/complicated_template.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/complicated_template.json deleted file mode 100644 index 962600da1..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/complicated_template.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "complicated_template.json", - "template": { - "parent": { - "child1": "Any value 1", - "child2": { - "parent": { - "child1": "Any value 1", - "child2": "Any value 2", - "child3": { - "child4": "Any value 4" - }, - "child4": [ - "Any value 1", - "Any value 2, Any value 3" - ], - "child5": [ - "Any value 4", - 1, - 2, - 4.4, - { - "child6": [ - 1, - 2, - 4.4 - ] - } - ] - } - }, - "child3": { - "child4": "Any value 4" - } - }, - "parent2": "Any value 2", - "parent3": { - "child1": "?", - "child2": "*", - "child3": "https://url.com?param1=test¶m2=*" - } - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/simple_template.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/simple_template.json deleted file mode 100644 index d209a9e35..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/simple_template.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "simple_template.json", - "template": { - "parent": { - "child1": "Any value 1", - "child2": "Any value 2", - "child3": { - "child4": "Any value 4" - } - } - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_array.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_array.json deleted file mode 100644 index 0ed4326da..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_array.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "template_with_array.json", - "template": { - "parent": { - "child1": [ - { - "child1": "Any value 1", - "child2": [ - 4, - 4.44 - ] - } - ], - "child2": [ - 1, - "Any value 4", - 3.3, - 5 - ] - }, - "parent2": "[]" - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_booleans.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_booleans.json deleted file mode 100644 index 49546632f..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_booleans.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "template_with_booleans.json", - "template": { - "parent": { - "child1": true, - "child3": { - "child4": true - } - }, - "parent2": false - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_floats.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_floats.json deleted file mode 100644 index 2b8caf4a0..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_floats.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "template_with_floats.json", - "template": { - "parent": { - "child1": 6.4, - "child2": 1.2, - "child3": { - "child5": 4.4, - "child2": "1" - } - } - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_ints.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_ints.json deleted file mode 100644 index 369b0b457..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/search/template_with_ints.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "template_with_ints.json", - "template": { - "parent": { - "child1": 6, - "child2": 1, - "child3": { - "child4": 4 - } - } - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/upload_template.json b/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/upload_template.json deleted file mode 100644 index df3ae28a2..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/integration/src/test/resources/templates/upload_template.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "upload_template.json", - "template": { - "field1": "field1" - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/pom.xml b/test/mocks/pnfsimulator/pnfsimulator/pom.xml deleted file mode 100644 index 43ec50571..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/pom.xml +++ /dev/null @@ -1,371 +0,0 @@ - - - - - - 4.0.0 - - - org.onap.simulator - simulator-parent - 5.0.0-SNAPSHOT - - - pnfsimulator - 5.0.0-SNAPSHOT - - pnfsimulator - - - UTF-8 - 1.8 - 1.8 - yyyyMMdd'T'HHmmss - - org.onap.pnfsimulator.Main - latest - 5.1.0 - 5.1.0 - 2.1.0.RELEASE - onap/${project.artifactId} - - libs - ${project.build.directory}/${dependency.directory.name} - - - nexus3.onap.org:10003 - http://nexus3.onap.org - - - - - org.springframework.boot - spring-boot-starter - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-data-mongodb - ${spring.boot.version} - - - org.springframework.boot - spring-boot-starter-actuator - ${spring.boot.version} - - - org.springframework.cloud - spring-cloud-config-client - 2.1.4.RELEASE - - - ch.qos.logback - logback-classic - 1.2.3 - - - ch.qos.logback - logback-core - 1.2.3 - - - org.slf4j - slf4j-api - 1.7.25 - - - commons-io - commons-io - 2.6 - - - org.json - json - 20180130 - - - com.google.code.gson - gson - 2.8.2 - - - org.apache.httpcomponents - httpclient - 4.5.5 - - - com.google.guava - guava - 21.0 - - - commons-cli - commons-cli - 1.4 - - - org.apache.commons - commons-lang3 - 3.7 - - - org.projectlombok - lombok - 1.18.2 - provided - - - com.fasterxml.jackson.datatype - jackson-datatype-jdk8 - 2.9.7 - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - 2.9.7 - - - io.vavr - vavr-match - 0.9.2 - - - io.vavr - vavr - 0.9.2 - - - - - org.junit.jupiter - junit-jupiter-engine - ${junit.jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-migrationsupport - ${junit.jupiter.version} - test - - - org.assertj - assertj-core - 3.9.1 - test - - - org.mockito - mockito-core - 2.18.3 - test - - - org.springframework - spring-test - 5.0.4.RELEASE - test - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - test - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - org.quartz-scheduler - quartz - 2.2.1 - - - org.quartz-scheduler - quartz-jobs - 2.2.1 - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - src/assembly/resources.xml - ${project.artifactId}-${project.version} - - - - package - - single - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - ${maven.compiler.source} - ${maven.compiler.target} - true - true - - - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - - ${simulator.main.class} - ${maven.build.timestamp} - - - - - - pl.project13.maven - git-commit-id-plugin - 2.2.4 - - - get-commit-info - - revision - - - - - ${project.basedir}/.git - true - git.commit.id.abbrev - - - - maven-surefire-plugin - 2.19 - - - org.junit.platform - junit-platform-surefire-provider - 1.1.1 - - - - true - true - false - - - - org.apache.maven.plugins - maven-dependency-plugin - - ${dependency.directory.location} - runtime - true - - - - copy-external-dependencies - package - - copy-dependencies - - - - - - io.fabric8 - docker-maven-plugin - 0.31.0 - - - build-image - - push - - - - - - - ${onap.nexus.dockerregistry.daily}/${docker.image.name} - - ${project.basedir} - ${project.basedir}/Dockerfile - - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.1 - - - org/onap/pnfsimulator/Main.class - - - - - default-prepare-agent - - prepare-agent - - - - report - prepare-package - - report - - - - - - - diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/assembly/resources.xml b/test/mocks/pnfsimulator/pnfsimulator/src/assembly/resources.xml deleted file mode 100644 index 35dd3b2e2..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/assembly/resources.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - resources - - zip - - - - - - simulator.sh - - unix - 0755 - - - - docker-compose.yml - - unix - 0644 - - - config - config - - **/* - - - - deployment - deployment - - **/* - - - - diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java deleted file mode 100644 index e0eace2d0..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/Main.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator; - -import javax.annotation.PostConstruct; - -import org.onap.pnfsimulator.filesystem.WatcherService; -import org.onap.pnfsimulator.template.FsToDbTemplateSynchronizer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; - -@SpringBootApplication -@EnableAsync -public class Main { - - private final WatcherService watcherService; - private final FsToDbTemplateSynchronizer fsToDbTemplateSynchronizer; - - @Autowired - public Main(WatcherService watcherService, - FsToDbTemplateSynchronizer fsToDbTemplateSynchronizer) { - this.watcherService = watcherService; - this.fsToDbTemplateSynchronizer = fsToDbTemplateSynchronizer; - } - - public static void main(String[] args) { - SpringApplication.run(Main.class, args); - } - - @PostConstruct - public void createWatchers() { - fsToDbTemplateSynchronizer.synchronize(); - watcherService.createWatcher(); - } -} - - diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java deleted file mode 100644 index 6e0e18eb5..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/SwaggerConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator; - -import org.onap.pnfsimulator.simulator.client.utils.ssl.SSLAuthenticationHelper; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableConfigurationProperties(SSLAuthenticationHelper.class) -@EnableSwagger2 -public class SwaggerConfig { - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("org.onap.pnfsimulator")) - .paths(PathSelectors.any()) - .build(); - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java deleted file mode 100644 index f9a167b93..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Row.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.db; - -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Field; - -public abstract class Row { - @Id - @Field("_id") - protected String id; - - public String getId() { - return id; - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Storage.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Storage.java deleted file mode 100644 index ad98ce0af..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/db/Storage.java +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.db; - -import com.google.gson.JsonObject; - -import java.util.List; -import java.util.Optional; - -public interface Storage { - - List getAll(); - - Optional get(String rowId); - - void persist(T row); - - boolean tryPersistOrOverwrite(T row, boolean overwrite); - - void delete(String rowId); - - List getIdsByContentCriteria(JsonObject queryJson); -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventData.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventData.java deleted file mode 100644 index 23b1c21a7..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventData.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.event; - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; -import org.springframework.data.annotation.Id; -import org.springframework.data.mongodb.core.mapping.Field; - -@Builder -@Getter -@Setter -public class EventData { - @Id - private String id; - - @Field("template") - @JsonInclude - private String template; - - @Field("patched") - @JsonInclude - private String patched; - - @Field("input") - @JsonInclude - private String input; - - @Field("keywords") - @JsonInclude - private String keywords; - - @Field("incrementValue") - @JsonInclude - private int incrementValue; - - protected EventData(String id, String template, String patched, String input, String keywords, int incrementValue) { - this.id = id; - this.template = template; - this.patched = patched; - this.input = input; - this.keywords = keywords; - this.incrementValue = incrementValue; - } - - @Override - public String toString() { - return "EventData{" - + "id='" + id + '\'' - + ", template='" + template + '\'' - + ", patched='" + patched + '\'' - + ", input='" + input + '\'' - + ", keywords='" + keywords + '\'' - + '}'; - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataRepository.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataRepository.java deleted file mode 100644 index d1a66ab0a..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataRepository.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.event; - -import org.springframework.data.mongodb.repository.MongoRepository; - -public interface EventDataRepository extends MongoRepository { -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java deleted file mode 100644 index 3568f0178..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/event/EventDataService.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * PNF-REGISTRATION-HANDLER - * ================================================================================ - * Copyright (C) 2018 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.event; - -import com.google.gson.JsonObject; -import java.util.List; -import java.util.Optional; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class EventDataService { - private final EventDataRepository repository; - - @Autowired - public EventDataService(EventDataRepository repository) { - this.repository = repository; - } - - private EventData persistEventData(String templateString, String patchedString, String inputString, String keywordsString) { - EventData eventData = EventData.builder() - .template(templateString) - .patched(patchedString) - .input(inputString) - .keywords(keywordsString) - .build(); - return repository.save(eventData); - } - - public EventData persistEventData(JsonObject templateJson, JsonObject patchedJson, JsonObject inputJson, - JsonObject keywordsJson) { - return persistEventData(templateJson.toString(), - patchedJson.toString(), - inputJson.toString(), - keywordsJson.toString()); - } - - public List getAllEvents() { - return repository.findAll(); - } - - public Optional getById(String id) { - return repository.findById(id); - } -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherConfig.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherConfig.java deleted file mode 100644 index 3535e3322..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherConfig.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.filesystem; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.task.TaskExecutor; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -@Configuration -public class WatcherConfig { - - @Bean - public TaskExecutor watcherTaskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setThreadNamePrefix("pnfsimulator_fs_watcher"); - executor.initialize(); - return executor; - } - -} diff --git a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessor.java b/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessor.java deleted file mode 100644 index 56a569671..000000000 --- a/test/mocks/pnfsimulator/pnfsimulator/src/main/java/org/onap/pnfsimulator/filesystem/WatcherEventProcessor.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Simulator - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.pnfsimulator.filesystem; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardWatchEventKinds; -import java.nio.file.WatchEvent; -import java.nio.file.WatchEvent.Kind; -import java.time.Instant; -import java.util.Arrays; -import java.util.Optional; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import lombok.extern.slf4j.Slf4j; -import org.bson.json.JsonParseException; -import org.onap.pnfsimulator.db.Storage; -import org.onap.pnfsimulator.template.Template; -import org.bson.Document; - -@Slf4j -public enum WatcherEventProcessor { - CREATED(StandardWatchEventKinds.ENTRY_CREATE) { - @Override - public void processEvent(Path path, Storage