aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src
diff options
context:
space:
mode:
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/aai-simulator/src')
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/configration/WebSecurityConfigImpl.java34
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/AbstractCacheServiceProvider.java55
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java1
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java1
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java1
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java1
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml17
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java8
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java14
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java14
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java1
12 files changed, 44 insertions, 111 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/configration/WebSecurityConfigImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/configration/WebSecurityConfigImpl.java
index eb92c246..1dc483f7 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/configration/WebSecurityConfigImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/configration/WebSecurityConfigImpl.java
@@ -20,15 +20,12 @@
package org.onap.so.aaisimulator.configration;
import org.onap.so.aaisimulator.utils.Constants;
+import org.onap.so.simulator.configuration.SimulatorSecurityConfigurer;
+import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-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.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* @author waqas.ikram@ericsson.com
@@ -36,36 +33,17 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
*/
@Configuration
@EnableWebSecurity
-public class WebSecurityConfigImpl extends WebSecurityConfigurerAdapter {
+public class WebSecurityConfigImpl extends SimulatorSecurityConfigurer {
- private final String username;
- private final String password;
- private final String role;
-
- public WebSecurityConfigImpl(@Value("${spring.security.username}") final String username,
- @Value("${spring.security.password}") final String password,
- @Value("${spring.security.role}") final String role) {
- this.username = username;
- this.password = password;
- this.role = role;
+ @Autowired
+ public WebSecurityConfigImpl(final UserCredentials userCredentials) {
+ super(userCredentials.getUsers());
}
-
@Override
protected void configure(final HttpSecurity http) throws Exception {
http.csrf().disable().authorizeRequests().antMatchers(Constants.BUSINESS_URL + "/**/**").authenticated().and()
.httpBasic();
}
- @Bean
- public BCryptPasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-
- @Autowired
- public void configureGlobal(final AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication().passwordEncoder(passwordEncoder()).withUser(username).password(password)
- .roles(role);
- }
-
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/AbstractCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/AbstractCacheServiceProvider.java
deleted file mode 100644
index 35e35917..00000000
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/AbstractCacheServiceProvider.java
+++ /dev/null
@@ -1,55 +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.aaisimulator.service.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@ericsson.com
- *
- */
-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/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
index 374737ec..1d12a94d 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/CustomerCacheServiceProviderImpl.java
@@ -28,6 +28,7 @@ import org.onap.aai.domain.yang.ServiceInstances;
import org.onap.aai.domain.yang.ServiceSubscription;
import org.onap.aai.domain.yang.ServiceSubscriptions;
import org.onap.so.aaisimulator.utils.Constants;
+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/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java
index 7e8450f7..156abd24 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/NodesCacheServiceProviderImpl.java
@@ -23,6 +23,7 @@ import static org.onap.so.aaisimulator.utils.Constants.NODES_CACHE;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.onap.so.aaisimulator.models.NodeServiceInstance;
+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/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java
index 32590cb0..58a8b1e6 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/OwnEntityCacheServiceProviderImpl.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import org.onap.aai.domain.yang.OwningEntity;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
+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/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java
index 047a3881..3ddefbe6 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/ProjectCacheServiceProviderImpl.java
@@ -25,6 +25,7 @@ import java.util.Optional;
import org.onap.aai.domain.yang.Project;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipList;
+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/aai-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
index d4f42992..25be8dab 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/resources/application.yaml
@@ -3,15 +3,14 @@ server:
tomcat:
max-threads: 4
ssl:
- key-store: classpath:keystore/org.onap.so.p12
- key-store-password: 'u!@JQoYD])@ykq.NKM,O7iA.'
- keyStoreType: PKCS12
+ key-store: classpath:keystore/org.onap.so.p12
+ key-store-password: u!@JQoYD])@ykq.NKM,O7iA.
+ keyStoreType: PKCS12
ssl-enable: true
-
spring:
security:
- username: aai
- #password: aai.onap.org:demo123456!
- password: $2a$04$crRntT01fAF4kb48mxlvgu68/silcLg.czC1LxQsKTdWuDBPpO3YO
- role: VID
- \ No newline at end of file
+ users:
+ - username: aai
+ #password: aai.onap.org:demo123456!
+ password: $2a$04$crRntT01fAF4kb48mxlvgu68/silcLg.czC1LxQsKTdWuDBPpO3YO
+ role: VID \ No newline at end of file
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
index 478651cc..ef49716a 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/BusinessControllerTest.java
@@ -48,8 +48,8 @@ import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.RequestError;
import org.onap.so.aaisimulator.utils.ServiceException;
import org.onap.so.aaisimulator.utils.TestUtils;
+import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -83,8 +83,8 @@ public class BusinessControllerTest {
@Autowired
private TestRestTemplate restTemplate;
- @Value("${spring.security.username}")
- private String username;
+ @Autowired
+ private UserCredentials userCredentials;
@Autowired
private CustomerCacheServiceProvider cacheServiceProvider;
@@ -384,7 +384,7 @@ public class BusinessControllerTest {
}
private HttpHeaders getHttpHeaders() {
- return TestUtils.getHttpHeaders(username);
+ return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
}
private String getServiceInstance() throws Exception, IOException {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
index 59246f56..50ab04c6 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/NodesControllerTest.java
@@ -44,8 +44,8 @@ import org.onap.so.aaisimulator.service.providers.CustomerCacheServiceProvider;
import org.onap.so.aaisimulator.service.providers.NodesCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
+import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -75,8 +75,8 @@ public class NodesControllerTest {
@Autowired
private TestRestTemplate restTemplate;
- @Value("${spring.security.username}")
- private String username;
+ @Autowired
+ private UserCredentials userCredentials;
@Autowired
private NodesCacheServiceProvider nodesCacheServiceProvider;
@@ -175,6 +175,6 @@ public class NodesControllerTest {
}
private HttpHeaders getHttpHeaders() {
- return TestUtils.getHttpHeaders(username);
+ return TestUtils.getHttpHeaders(userCredentials.getUsers().iterator().next().getUsername());
}
}
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
index a443a458..7f825db8 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/OwningEntityControllerTest.java
@@ -38,8 +38,8 @@ import org.onap.so.aaisimulator.models.Result;
import org.onap.so.aaisimulator.service.providers.OwnEntityCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
+import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -74,8 +74,8 @@ public class OwningEntityControllerTest {
@Autowired
private TestRestTemplate restTemplate;
- @Value("${spring.security.username}")
- private String username;
+ @Autowired
+ private UserCredentials userCredentials;
@Autowired
private OwnEntityCacheServiceProvider cacheServiceProvider;
@@ -153,7 +153,11 @@ public class OwningEntityControllerTest {
}
private <T> ResponseEntity<T> invokeHttpGet(final String url, final Class<T> clazz) {
- return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders(username)), clazz);
+ return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders(getUsername())), clazz);
+ }
+
+ private String getUsername() {
+ return userCredentials.getUsers().iterator().next().getUsername();
}
private ResponseEntity<Void> invokeHttpPut(final String url, final Object obj) {
@@ -162,7 +166,7 @@ public class OwningEntityControllerTest {
}
private HttpEntity<?> getHttpEntity(final Object obj) {
- return new HttpEntity<>(obj, getHttpHeaders(username));
+ return new HttpEntity<>(obj, getHttpHeaders(getUsername()));
}
private String getOwningEntityEndPointUrl() {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
index 1b702513..e7b067db 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/controller/ProjectControllerTest.java
@@ -36,8 +36,8 @@ import org.onap.so.aaisimulator.models.Result;
import org.onap.so.aaisimulator.service.providers.ProjectCacheServiceProvider;
import org.onap.so.aaisimulator.utils.Constants;
import org.onap.so.aaisimulator.utils.TestUtils;
+import org.onap.so.simulator.model.UserCredentials;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
@@ -74,8 +74,8 @@ public class ProjectControllerTest {
@Autowired
private TestRestTemplate restTemplate;
- @Value("${spring.security.username}")
- private String username;
+ @Autowired
+ private UserCredentials userCredentials;
@Autowired
private ProjectCacheServiceProvider cacheServiceProvider;
@@ -147,7 +147,7 @@ public class ProjectControllerTest {
}
private <T> ResponseEntity<T> invokeHttpGet(final String url, final Class<T> clazz) {
- return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders(username)), clazz);
+ return restTemplate.exchange(url, HttpMethod.GET, new HttpEntity<>(getHttpHeaders(getUsername())), clazz);
}
private ResponseEntity<Void> invokeHttpPut(final String url, final Object obj) {
@@ -156,7 +156,11 @@ public class ProjectControllerTest {
}
private HttpEntity<?> getHttpEntity(final Object obj) {
- return new HttpEntity<>(obj, getHttpHeaders(username));
+ return new HttpEntity<>(obj, getHttpHeaders(getUsername()));
+ }
+
+ private String getUsername() {
+ return userCredentials.getUsers().iterator().next().getUsername();
}
private String getProjectEndPointUrl() {
diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
index fecfd85a..4dfe9c2c 100644
--- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
+++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/test/java/org/onap/so/aaisimulator/utils/TestUtils.java
@@ -33,7 +33,6 @@ import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
* @author waqas.ikram@ericsson.com
*
*/
-
public class TestUtils {
private static final String PASSWORD = "aai.onap.org:demo123456!";