summaryrefslogtreecommitdiffstats
path: root/nokiav2/driver/src/test/java/org
diff options
context:
space:
mode:
authorDenes Nemeth <denes.nemeth@nokia.com>2018-03-23 08:43:06 +0100
committerDenes Nemeth <denes.nemeth@nokia.com>2018-03-23 08:50:40 +0100
commit1e7ee1f6bd1d4753d99eaee5d78b1e28956f0709 (patch)
tree3c85858305dcd0ad15c5a48416f6eb06c25093b1 /nokiav2/driver/src/test/java/org
parentc768c4af82b40cf1825604a4df36b68f189c194a (diff)
Fix snapshot dependency and security
Change-Id: Ief922144c5c9cd46a147fb697279d947f667889e Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com> Issue-ID: VFC-728
Diffstat (limited to 'nokiav2/driver/src/test/java/org')
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestRealConfig.java27
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestSecurityConfig.java18
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java4
-rw-r--r--nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java1
4 files changed, 43 insertions, 7 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 6caeb3a9..6bcce07f 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
@@ -16,13 +16,21 @@
package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.spring;
-import com.nokia.cbam.lcm.v32.model.VnfIdentifierCreationNotification;
-import com.nokia.cbam.lcm.v32.model.VnfIdentifierDeletionNotification;
-import com.nokia.cbam.lcm.v32.model.VnfInfoAttributeValueChangeNotification;
-import com.nokia.cbam.lcm.v32.model.VnfLifecycleChangeNotification;
+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.mock.http.MockHttpInputMessage;
+import org.springframework.mock.http.MockHttpOutputMessage;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import static junit.framework.TestCase.assertEquals;
public class TestRealConfig {
@@ -38,6 +46,17 @@ public class TestRealConfig {
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);
+
+ 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);
+ String write = out.getBodyAsString();
+ HttpInputMessage x = new MockHttpInputMessage(write.getBytes());
+ VnfLifecycleChangeNotification deserialized = (VnfLifecycleChangeNotification) httpMessageConverter.read(VnfLifecycleChangeNotification.class, x);
+ assertEquals("vnfId", deserialized.getVnfInstanceId());
}
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestSecurityConfig.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestSecurityConfig.java
index 5d0d88b7..39a8e648 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestSecurityConfig.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/spring/TestSecurityConfig.java
@@ -21,6 +21,7 @@ import org.mockito.Mockito;
import org.springframework.security.config.annotation.ObjectPostProcessor;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.security.web.util.matcher.AnyRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
@@ -38,7 +39,7 @@ public class TestSecurityConfig {
* this can only fully be tested from CT by starting the web service
*/
@Test
- public void testSpringBootApplicationInit() throws Exception {
+ public void testNoHttpSecurity() throws Exception {
HttpSecurity http = new HttpSecurity(Mockito.mock(ObjectPostProcessor.class), Mockito.mock(AuthenticationManagerBuilder.class), new HashMap<>());
//when
new SecurityConfig().configure(http);
@@ -48,4 +49,19 @@ public class TestSecurityConfig {
assertTrue(AnyRequestMatcher.class.isAssignableFrom(requestMatchers.get(0).getClass()));
}
+ /**
+ * verify that no web security is performed
+ * this can only fully be tested from CT by starting the web service
+ */
+ @Test
+ public void testNoWebSecurity() throws Exception {
+ WebSecurity webSecurity = new WebSecurity(Mockito.mock(ObjectPostProcessor.class));
+ WebSecurity.IgnoredRequestConfigurer ignorer = Mockito.mock(WebSecurity.IgnoredRequestConfigurer.class);
+ ReflectionTestUtils.setField(webSecurity, "ignoredRequestRegistry", ignorer);
+ //when
+ new SecurityConfig().configure(webSecurity);
+ //verify
+ Mockito.verify(ignorer).anyRequest();
+ }
+
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
index ee206537..bed25400 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestJobManager.java
@@ -425,7 +425,7 @@ public class TestJobManager extends TestBase {
fail();
} catch (RuntimeException e) {
assertEquals(expectedException, e.getCause());
- verify(logger).error("Unable to retrieve operation parameters", expectedException);
+ verify(logger).error("Unable to retrieve operation parameters of operation with " + operation.getId() +" identifier", expectedException);
}
assertTrue(jobManager.hasOngoingJobs());
}
@@ -447,7 +447,7 @@ public class TestJobManager extends TestBase {
fail();
} catch (RuntimeException e) {
assertEquals(expectedException, e.getCause());
- verify(logger).error("Unable to retrieve VNF", expectedException);
+ verify(logger).error("Unable to retrieve VNF with myVnfId identifier", expectedException);
}
assertTrue(jobManager.hasOngoingJobs());
}
diff --git a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java
index e4960b2b..ffbda145 100644
--- a/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java
+++ b/nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/TestSelfRegistrationManager.java
@@ -127,6 +127,7 @@ public class TestSelfRegistrationManager extends TestBase {
assertEquals(SelfRegistrationManager.SERVICE_NAME, microserviceRequest.getServiceName());
assertEquals("/api/NokiaSVNFM/v1", microserviceRequest.getUrl());
assertEquals("v1", microserviceRequest.getVersion());
+ assertEquals(false, microserviceRequest.isEnable_ssl());
//1 means internal service to ONAP
assertEquals("1", microserviceRequest.getVisualRange());
}