summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java
diff options
context:
space:
mode:
authorDenes Nemeth <denes.nemeth@nokia.com>2018-03-24 14:00:54 +0100
committerDenes Nemeth <denes.nemeth@nokia.com>2018-03-25 21:32:03 +0200
commitc82c886215ed34953a51dff0710c6bd15cb80ee4 (patch)
tree783f928ba8e033bbf55b6cffa343c7ea47c40b59 /nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java
parent1489e4215e075ab3ffe8f7158559a38778cd0b34 (diff)
Removing jackson to mitigate cve-2017-4995
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com> Issue-ID: VFC-728 Change-Id: Ib495d4706361cc39527dfe86463aa505d9564afa
Diffstat (limited to 'nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java')
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java
index 6bcce07f..22a9d06c 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java
@@ -17,19 +17,16 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring;
import com.nokia.cbam.lcm.v32.model.*;
-import junit.framework.TestCase;
import org.junit.Test;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
-import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.mock.http.MockHttpInputMessage;
import org.springframework.mock.http.MockHttpOutputMessage;
+import org.threeten.bp.OffsetDateTime;
-import java.io.IOException;
-import java.io.InputStream;
-
+import static com.google.common.collect.Iterables.filter;
import static junit.framework.TestCase.assertEquals;
public class TestRealConfig {
@@ -41,22 +38,26 @@ public class TestRealConfig {
public void test() throws Exception {
HttpMessageConverters converters = new RealConfig().customConverters();
//verify
- converters.getConverters().get(0).canRead(VnfIdentifierCreationNotification.class, MediaType.APPLICATION_JSON);
- converters.getConverters().get(0).canRead(VnfIdentifierDeletionNotification.class, MediaType.APPLICATION_JSON);
- converters.getConverters().get(0).canRead(VnfInfoAttributeValueChangeNotification.class, MediaType.APPLICATION_JSON);
- converters.getConverters().get(0).canRead(VnfLifecycleChangeNotification.class, MediaType.APPLICATION_JSON);
- converters.getConverters().get(0).canRead(String.class, MediaType.APPLICATION_JSON);
+ GsonHttpMessageConverter httpMessageConverter1 = filter(converters.getConverters(), GsonHttpMessageConverter.class).iterator().next();
+ httpMessageConverter1.canRead(VnfIdentifierCreationNotification.class, MediaType.APPLICATION_JSON);
+ httpMessageConverter1.canRead(VnfIdentifierDeletionNotification.class, MediaType.APPLICATION_JSON);
+ httpMessageConverter1.canRead(VnfInfoAttributeValueChangeNotification.class, MediaType.APPLICATION_JSON);
+ httpMessageConverter1.canRead(VnfLifecycleChangeNotification.class, MediaType.APPLICATION_JSON);
+ httpMessageConverter1.canRead(String.class, MediaType.APPLICATION_JSON);
- HttpMessageConverter<VnfLifecycleChangeNotification> httpMessageConverter = (HttpMessageConverter<VnfLifecycleChangeNotification>) converters.getConverters().get(0);
MockHttpOutputMessage out = new MockHttpOutputMessage();
VnfLifecycleChangeNotification not = new VnfLifecycleChangeNotification();
not.setNotificationType(VnfNotificationType.VNFLIFECYCLECHANGENOTIFICATION);
not.setVnfInstanceId("vnfId");
- httpMessageConverter.write(not, MediaType.APPLICATION_JSON, out);
+ OffsetDateTime now = OffsetDateTime.now();
+ not.setTimestamp(now);
+ httpMessageConverter1.write(not, MediaType.APPLICATION_JSON, out);
String write = out.getBodyAsString();
HttpInputMessage x = new MockHttpInputMessage(write.getBytes());
- VnfLifecycleChangeNotification deserialized = (VnfLifecycleChangeNotification) httpMessageConverter.read(VnfLifecycleChangeNotification.class, x);
+ VnfLifecycleChangeNotification deserialized = (VnfLifecycleChangeNotification) httpMessageConverter1.read(VnfLifecycleChangeNotification.class, x);
assertEquals("vnfId", deserialized.getVnfInstanceId());
+ assertEquals(now, deserialized.getTimestamp());
+
}
}