aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator
diff options
context:
space:
mode:
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/sdnc-simulator')
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/pom.xml15
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/configration/WebSecurityConfigImpl.java49
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/AbstractCacheServiceProvider.java54
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java1
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/resources/application.yaml13
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java25
6 files changed, 98 insertions, 59 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/pom.xml
index 22994ff0..0806d88c 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/pom.xml
+++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/pom.xml
@@ -13,6 +13,11 @@
</properties>
<dependencies>
<dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.onap.sdnc.northbound</groupId>
<artifactId>generic-resource-api-client</artifactId>
<version>${version.generic-resource-api-client}</version>
@@ -27,6 +32,16 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-tomcat</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/configration/WebSecurityConfigImpl.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/configration/WebSecurityConfigImpl.java
new file mode 100644
index 00000000..261b66d7
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/configration/WebSecurityConfigImpl.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.sdncsimulator.configration;
+
+import static org.onap.so.sdncsimulator.utils.Constants.OPERATIONS_URL;
+import org.onap.so.simulator.configuration.SimulatorSecurityConfigurer;
+import org.onap.so.simulator.model.UserCredentials;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+
+/**
+ * @author waqas.ikram@ericsson.com
+ *
+ */
+@Configuration
+@EnableWebSecurity
+public class WebSecurityConfigImpl extends SimulatorSecurityConfigurer {
+
+ @Autowired
+ public WebSecurityConfigImpl(final UserCredentials userCredentials) {
+ super(userCredentials.getUsers());
+ }
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.csrf().disable().authorizeRequests().antMatchers(OPERATIONS_URL + "/**/**").authenticated().and()
+ .httpBasic();
+ }
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/AbstractCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/AbstractCacheServiceProvider.java
deleted file mode 100644
index 55e6f541..00000000
--- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/AbstractCacheServiceProvider.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
- * ================================================================================
- * 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.
- *
- * SPDX-License-Identifier: Apache-2.0
- * ============LICENSE_END=========================================================
- */
-package org.onap.so.sdncsimulator.providers;
-
-import java.util.concurrent.ConcurrentHashMap;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cache.Cache;
-import org.springframework.cache.CacheManager;
-
-/**
- * @author Waqas Ikram (waqas.ikram@est.tech)
- */
-public abstract class AbstractCacheServiceProvider {
-
- private final Logger LOGGER = LoggerFactory.getLogger(this.getClass());
-
- private final CacheManager cacheManager;
-
- public AbstractCacheServiceProvider(final CacheManager cacheManager) {
- this.cacheManager = cacheManager;
- }
-
- protected void clearCahce(final String name) {
- final Cache cache = cacheManager.getCache(name);
- if (cache != null) {
- final ConcurrentHashMap<?, ?> nativeCache = (ConcurrentHashMap<?, ?>) cache.getNativeCache();
- LOGGER.info("Clear all entries from cahce: {}", cache.getName());
- nativeCache.clear();
- }
- }
-
- protected Cache getCache(final String name) {
- return cacheManager.getCache(name);
- }
-
-}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java
index 9436d224..37773e1f 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java
@@ -47,6 +47,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiServicestatusServ
import org.onap.sdnc.northbound.client.model.GenericResourceApiServicetopologyServiceTopology;
import org.onap.sdnc.northbound.client.model.GenericResourceApiServicetopologyidentifierServiceTopologyIdentifier;
import org.onap.so.sdncsimulator.models.OutputRequest;
+import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/resources/application.yaml
index bcd8d5fc..95b28455 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/resources/application.yaml
+++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/resources/application.yaml
@@ -2,4 +2,15 @@ server:
port: 9994
tomcat:
max-threads: 4
-ssl-enable: false \ No newline at end of file
+ssl-enable: false
+spring:
+ security:
+ users:
+ - username: mso
+ #password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+ password: $2a$04$f8SB6cW/VI26QvYM6z.GXu7hlEmwnFtePenD8zF18mS3Atu3QNqr2
+ role: VID
+ - username: admin
+ #password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+ password: $2a$04$f8SB6cW/VI26QvYM6z.GXu7hlEmwnFtePenD8zF18mS3Atu3QNqr2
+ role: VID \ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java
index 36e12089..bcfff95e 100644
--- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/test/java/org/onap/so/sdncsimulator/controller/OperationsControllerTest.java
@@ -26,6 +26,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.Base64;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,6 +35,7 @@ import org.onap.so.sdncsimulator.models.InputRequest;
import org.onap.so.sdncsimulator.models.OutputRequest;
import org.onap.so.sdncsimulator.providers.ServiceOperationsCacheServiceProvider;
import org.onap.so.sdncsimulator.utils.Constants;
+import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -66,6 +68,8 @@ public class OperationsControllerTest {
private static final String SERVICE_TOPOLOGY_OPERATION_URL = "/GENERIC-RESOURCE-API:service-topology-operation/";
+ private static final String PASSWORD = "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U";
+
@LocalServerPort
private int port;
@@ -75,6 +79,10 @@ public class OperationsControllerTest {
@Autowired
private ServiceOperationsCacheServiceProvider cacheServiceProvider;
+ @Autowired
+ private UserCredentials userCredentials;
+
+
@Test
public void test_postServiceOperationInformation_successfullyAddedToCache() throws Exception {
@@ -127,9 +135,7 @@ public class OperationsControllerTest {
}
private HttpHeaders getHttpHeaders() {
- final HttpHeaders requestHeaders = new HttpHeaders();
- requestHeaders.setContentType(MediaType.APPLICATION_JSON);
- return requestHeaders;
+ return getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
}
@@ -149,10 +155,21 @@ public class OperationsControllerTest {
return new String(Files.readAllBytes(path));
}
- private static File getFile(final String file) throws IOException {
+ private File getFile(final String file) throws IOException {
return new ClassPathResource(file).getFile();
}
+ private HttpHeaders getHttpHeaders(final String username) {
+ final HttpHeaders requestHeaders = new HttpHeaders();
+ requestHeaders.add("Authorization", getBasicAuth(username));
+ requestHeaders.setContentType(MediaType.APPLICATION_JSON);
+ return requestHeaders;
+ }
+
+ private String getBasicAuth(final String username) {
+ return "Basic " + new String(Base64.getEncoder().encodeToString((username + ":" + PASSWORD).getBytes()));
+ }
+
@After
public void after() {
cacheServiceProvider.clearAll();