summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/modules
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/modules')
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml10
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt107
-rw-r--r--ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt48
4 files changed, 59 insertions, 108 deletions
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
index 0cae94690..011edae95 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/pom.xml
@@ -44,7 +44,15 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-webflux</artifactId>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt
index 21d05e620..e6a66800b 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/rest/service/RestClientServiceTest.kt
@@ -23,8 +23,8 @@ import com.fasterxml.jackson.databind.ObjectMapper
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking
-import org.apache.catalina.connector.Connector
-import org.junit.Ignore
+import org.junit.After
+import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties
@@ -34,18 +34,17 @@ import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
-import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory
-import org.springframework.boot.web.servlet.server.ServletWebServerFactory
+import org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory
+import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory
+import org.springframework.boot.web.server.WebServer
import org.springframework.context.annotation.Bean
-import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpMethod
-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
-import org.springframework.security.crypto.password.PasswordEncoder
-import org.springframework.stereotype.Component
+import org.springframework.http.server.reactive.HttpHandler
+import org.springframework.security.config.web.server.ServerHttpSecurity
+import org.springframework.security.core.userdetails.MapReactiveUserDetailsService
+import org.springframework.security.core.userdetails.User
+import org.springframework.security.core.userdetails.UserDetails
+import org.springframework.security.web.server.SecurityWebFilterChain
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@@ -63,10 +62,9 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class])
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
-@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class,
- BlueprintPropertyConfiguration::class,
- SampleController::class, BluePrintProperties::class,
- BluePrintProperties::class])
+@ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, SampleController::class,
+ SecurityConfiguration::class,
+ BlueprintPropertyConfiguration::class, BluePrintProperties::class])
@TestPropertySource(properties =
[
"server.port=8443",
@@ -76,7 +74,7 @@ import kotlin.test.assertNotNull
"server.ssl.keyStoreType=PKCS12",
"server.ssl.keyAlias=tomcat",
"blueprintsprocessor.restclient.sample.type=basic-auth",
- "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8080",
+ "blueprintsprocessor.restclient.sample.url=http://127.0.0.1:8081",
"blueprintsprocessor.restclient.sample.username=admin",
"blueprintsprocessor.restclient.sample.password=jans",
"blueprintsprocessor.restclient.test.type=ssl-basic-auth",
@@ -87,12 +85,31 @@ import kotlin.test.assertNotNull
"blueprintsprocessor.restclient.test.sslTrust=src/test/resources/keystore.p12",
"blueprintsprocessor.restclient.test.sslTrustPassword=changeit"
])
-@Ignore
class RestClientServiceTest {
@Autowired
lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
+ @Autowired
+ lateinit var httpHandler : HttpHandler
+
+ lateinit var http : WebServer
+
+ fun localPort() = http.port
+
+ @Before
+ fun start() {
+ // Second Http server required for non-SSL requests to be processed along with the https server.
+ val factory: ReactiveWebServerFactory = NettyReactiveWebServerFactory(8081)
+ this.http = factory.getWebServer(this.httpHandler)
+ this.http.start()
+ }
+
+ @After
+ fun stop() {
+ this.http.stop()
+ }
+
@Test
fun testPatch() {
val restClientService = bluePrintRestLibPropertyService
@@ -118,7 +135,7 @@ class RestClientServiceTest {
fun testSimpleBasicAuth() {
val json: String = "{\n" +
" \"type\" : \"basic-auth\",\n" +
- " \"url\" : \"http://localhost:8080\",\n" +
+ " \"url\" : \"http://localhost:8081\",\n" +
" \"username\" : \"admin\",\n" +
" \"password\" : \"jans\"\n" +
"}"
@@ -308,49 +325,25 @@ open class SampleController {
* Security configuration required for basic authentication with username and
* password for any request in the server.
*/
-@Configuration
-@EnableWebSecurity
-open class SecurityConfig : WebSecurityConfigurerAdapter() {
-
- @Throws(Exception::class)
- override fun configure(http: HttpSecurity) {
- http
- .csrf().disable()
- .authorizeRequests().anyRequest().authenticated()
- .and()
- .httpBasic()
- }
+open class SecurityConfiguration {
- @Autowired
- @Throws(Exception::class)
- open fun configureGlobal(auth: AuthenticationManagerBuilder) {
- auth.inMemoryAuthentication()
- .withUser("admin")
- .password(passwordEncoder().encode("jans"))
+ @Bean
+ open fun userDetailsService(): MapReactiveUserDetailsService {
+ val user: UserDetails = User.withDefaultPasswordEncoder()
+ .username("admin")
+ .password("jans")
.roles("USER")
+ .build()
+ return MapReactiveUserDetailsService(user)
}
@Bean
- open fun passwordEncoder(): PasswordEncoder {
- return BCryptPasswordEncoder()
- }
-}
-
-/**
- * Http server required for http request to be processed along with the https
- * server.
- */
-@Component
-class HttpServer {
- @Bean
- fun servletContainer(): ServletWebServerFactory {
-
- val connector = Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL)
- connector.port = 8080
-
- val tomcat = TomcatServletWebServerFactory()
- tomcat.addAdditionalTomcatConnectors(connector)
- return tomcat
+ open fun springSecurityFilterChain(http: ServerHttpSecurity): SecurityWebFilterChain {
+ return http
+ .csrf().disable()
+ .authorizeExchange().anyExchange().authenticated()
+ .and().httpBasic()
+ .and().build()
}
}
diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
index 5072b3c6a..ce5acd400 100644
--- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
+++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/selfservice/api/BluePrintProcessingGRPCHandlerTest.kt
@@ -22,7 +22,6 @@ import com.google.protobuf.util.JsonFormat
import io.grpc.stub.StreamObserver
import io.grpc.testing.GrpcServerRule
import org.junit.Assert
-import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -42,7 +41,6 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.BeforeTest
-@Ignore
@RunWith(SpringRunner::class)
@DirtiesContext
@EnableAutoConfiguration
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt
deleted file mode 100644
index 12ef9733a..000000000
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxyTest.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
-
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
-
-import kotlin.test.assertNotNull
-import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
-import org.springframework.test.context.TestPropertySource
-import org.springframework.test.context.junit4.SpringRunner
-import kotlin.test.BeforeTest
-
-@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BluePrintPython::class, PythonExecutorProperty::class, String::class])
-@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
-class BlueprintPythonInterpreterProxyTest {
-
- lateinit var blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy
-
- @Autowired
- lateinit var pythonExecutorProperty: PythonExecutorProperty
-
- @BeforeTest
- fun init() {
- val blueprintBasePath = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
- val pythonPath: MutableList<String> = arrayListOf()
- pythonPath.add(blueprintBasePath)
- pythonPath.addAll(pythonExecutorProperty.modulePaths)
- val pythonClassName = "PythonTestScript"
- val content = JacksonUtils.getContent("./src/test/resources/PythonTestScript.py")
-
- val blueprintPython = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf())
- blueprintPython.content = content
- blueprintPython.pythonClassName = pythonClassName
- blueprintPython.moduleName = "Unit test - Blueprint Python Script [Class Name = $pythonClassName]"
-
- blueprintPythonInterpreterProxy = BlueprintPythonInterpreterProxy(blueprintPython)
- }
-
- @Test
- fun getPythonInterpreter() {
- val pythonObject = blueprintPythonInterpreterProxy.getPythonInstance(hashMapOf())
- assertNotNull(pythonObject, "failed to get python interpreter")
- }
-} \ No newline at end of file