From 756e7210cf13c6ef9bae8f785d3f46112c136f7d Mon Sep 17 00:00:00 2001 From: Jakub Dudycz Date: Fri, 1 Mar 2019 17:39:09 +0100 Subject: Fix ssl related bug in xnf simulator Fix bug when xnf simnulator was using same SecurityKeys object instance for every new VesClient, which resulted in fault while trying to connect to collector. With new implementation simulator reuses same HvVesProdcuer from SDK for every VesEvent request received and creates new Producer for every WireFrameEvent request. This allows to continue testing cases in which there is need to assert if connection was dropped from malicious client. Change-Id: I5f51a58de85cccf7de6ab2392f86259502be31dd Issue-ID: DCAEGEN2-1291 Signed-off-by: Jakub Dudycz Signed-off-by: Filip Krzywka --- .../org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt | 11 ----------- .../org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt | 7 +++++-- 2 files changed, 5 insertions(+), 13 deletions(-) (limited to 'sources/hv-collector-xnf-simulator/src/test') diff --git a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt index daf30617..14061532 100644 --- a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/HvVesClientTest.kt @@ -44,17 +44,6 @@ internal class HvVesClientTest : Spek({ val hvVesProducer: HvVesProducer = mock() val cut = HvVesClient(hvVesProducer) - describe("handling ves events stream") { - - val vesEvents = Flux.empty() - whenever(hvVesProducer.send(any())).thenReturn(Mono.empty()) - cut.sendVesEvents(vesEvents) - - it("should perform sending operation") { - verify(hvVesProducer).send(vesEvents) - } - } - describe("handling raw message stream") { val rawMessages = Flux.empty() diff --git a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt index 123f12ae..29281cdc 100644 --- a/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt +++ b/sources/hv-collector-xnf-simulator/src/test/kotlin/org/onap/dcae/collectors/veshv/main/XnfSimulatorTest.kt @@ -23,6 +23,7 @@ import arrow.core.Left import arrow.core.None import arrow.core.Right import com.nhaarman.mockitokotlin2.any +import com.nhaarman.mockitokotlin2.eq import com.nhaarman.mockitokotlin2.mock import com.nhaarman.mockitokotlin2.verify import com.nhaarman.mockitokotlin2.whenever @@ -39,6 +40,7 @@ import org.onap.dcae.collectors.veshv.ves.message.generator.api.VesEventParamete import org.onap.dcae.collectors.veshv.ves.message.generator.api.VesEventType import org.onap.dcae.collectors.veshv.ves.message.generator.factory.MessageGeneratorFactory import org.onap.dcae.collectors.veshv.ves.message.generator.generators.VesEventGenerator +import org.onap.dcaegen2.services.sdk.services.hvves.client.producer.api.options.PayloadType import org.onap.ves.VesEventOuterClass import org.onap.ves.VesEventOuterClass.CommonEventHeader import reactor.core.publisher.Flux @@ -120,13 +122,14 @@ internal class XnfSimulatorTest : Spek({ whenever(generatorFactory.createVesEventGenerator()).thenReturn(vesEventGenerator) whenever(vesEventGenerator.createMessageFlux(vesEventParams)).thenReturn(generatedMessages) whenever(clientFactory.create()).thenReturn(vesClient) - whenever(vesClient.sendVesEvents(generatedMessages)).thenReturn(Mono.just(Unit)) + + whenever(vesClient.sendRawPayload(any(), eq(PayloadType.PROTOBUF))).thenReturn(Mono.just(Unit)) // when cut.startSimulation(json).map { it.unsafeRunSync() } // then - verify(vesClient).sendVesEvents(generatedMessages) + verify(vesClient).sendRawPayload(any(), eq(PayloadType.PROTOBUF)) } } }) \ No newline at end of file -- cgit 1.2.3-korg