diff options
Diffstat (limited to 'src')
11 files changed, 160 insertions, 37 deletions
diff --git a/src/main/java/org/onap/aai/datarouter/Application.java b/src/main/java/org/onap/aai/datarouter/Application.java index 245797c..42b459d 100644 --- a/src/main/java/org/onap/aai/datarouter/Application.java +++ b/src/main/java/org/onap/aai/datarouter/Application.java @@ -24,20 +24,29 @@ import java.util.HashMap; import javax.annotation.PostConstruct; import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.eclipse.jetty.util.security.Password; +import org.onap.aai.config.EdgesConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.boot.web.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; +import org.springframework.context.annotation.FilterType; @SpringBootApplication +@ComponentScan(basePackages = {"org.onap.aai.config", "org.onap.aai.setup", "org.onap.aai.datarouter"}, excludeFilters = { +@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, +value = EdgesConfiguration.class)}) +@PropertySource(value = "file:${CONFIG_HOME}/schemaIngest.properties") public class Application extends SpringBootServletInitializer{ private static final String CAMEL_URL_MAPPING = "/*"; private static final String CAMEL_SERVLET_NAME = "CamelServlet"; + private static final String JETTY_OBFUSCATION_PATTERN = "OBF:"; @Autowired private Environment env; @@ -50,8 +59,6 @@ public class Application extends SpringBootServletInitializer{ HashMap<String, Object> props = new HashMap<>(); props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword)); new Application().configure(new SpringApplicationBuilder(Application.class).properties(props)).run(args); - - } @Bean @@ -62,7 +69,7 @@ public class Application extends SpringBootServletInitializer{ } /** - * Set required trust store system properties using values from application.properties + * Set required system properties using values from application.properties and schemaIngest.properties */ @PostConstruct public void setSystemProperties() { @@ -77,8 +84,18 @@ public class Application extends SpringBootServletInitializer{ throw new IllegalArgumentException("Env property server.ssl.key-store-password not set"); } } - } + String schemaServiceKeyStorePassword = env.getProperty("schema.service.ssl.key-store-password"); + if( (schemaServiceKeyStorePassword != null) && (schemaServiceKeyStorePassword.startsWith(JETTY_OBFUSCATION_PATTERN))){ + System.setProperty("schema.service.ssl.key-store-password", Password.deobfuscate(schemaServiceKeyStorePassword)); + } + + String schemaServiceTrustStorePassword = env.getProperty("schema.service.ssl.trust-store-password"); + if ( (schemaServiceTrustStorePassword != null) && (schemaServiceTrustStorePassword.startsWith(JETTY_OBFUSCATION_PATTERN)) ){ + System.setProperty("schema.service.ssl.trust-store-password", Password.deobfuscate(schemaServiceTrustStorePassword)); + } + + } }
\ No newline at end of file diff --git a/src/main/java/org/onap/aai/datarouter/config/SchemaConfiguration.java b/src/main/java/org/onap/aai/datarouter/config/SchemaConfiguration.java new file mode 100644 index 0000000..afcfba0 --- /dev/null +++ b/src/main/java/org/onap/aai/datarouter/config/SchemaConfiguration.java @@ -0,0 +1,43 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.aai.datarouter.config; + +import org.onap.aai.setup.AAIConfigTranslator; +import org.onap.aai.setup.ConfigTranslator; +import org.onap.aai.setup.SchemaLocationsBean; +import org.onap.aai.setup.SchemaVersions; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +@Configuration +@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true) +@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true) +public class SchemaConfiguration { + + @Bean(name = "configTranslator") + @ConditionalOnProperty(name = "schema.translator.list", havingValue = "config", matchIfMissing = true) + public ConfigTranslator configTranslator(SchemaLocationsBean schemaLocationsBean, SchemaVersions schemaVersions) { + return new AAIConfigTranslator(schemaLocationsBean, schemaVersions); + } +} diff --git a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java index b76e7ee..aa9b4fa 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyTest.java @@ -34,6 +34,7 @@ import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.datarouter.Application; import org.onap.aai.datarouter.util.NodeUtils; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersions; @@ -44,7 +45,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") +@ContextConfiguration(classes = {Application.class}) public class EntityEventPolicyTest { private EntityEventPolicyConfig eventPolicyConfig; private EntityEventPolicy policy; diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java index cf9f013..8f15751 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeAggregateGenericVnfProcessorTest.java @@ -34,6 +34,7 @@ import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.datarouter.Application; import org.onap.aai.datarouter.util.NodeUtils; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersions; @@ -43,7 +44,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") +@ContextConfiguration(classes = {Application.class}) public class SpikeAggregateGenericVnfProcessorTest { private SpikeEventPolicyConfig eventPolicyConfig; private SpikeAggregateGenericVnfProcessor policy; @@ -53,13 +54,13 @@ public class SpikeAggregateGenericVnfProcessorTest { private SchemaVersions schemaVersions; @Autowired private SchemaLocationsBean schemaLocationsBean; - + @Before public void init() throws Exception { eventPolicyConfig = new SpikeEventPolicyConfig(); eventPolicyConfig.setSearchKeystorePwd("password"); eventPolicyConfig.setSourceDomain("JUNIT"); - + eventPolicyConfig.setSchemaVersions(schemaVersions); eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java index 6791ac3..bbde7e3 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeAutosuggestProcessorTest.java @@ -34,6 +34,7 @@ import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.datarouter.Application; import org.onap.aai.datarouter.util.NodeUtils; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersions; @@ -43,7 +44,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") +@ContextConfiguration(classes = {Application.class}) public class SpikeAutosuggestProcessorTest { private SpikeEventPolicyConfig eventPolicyConfig; private SpikeAutosuggestIndexProcessor policy; @@ -53,17 +54,17 @@ public class SpikeAutosuggestProcessorTest { private SchemaVersions schemaVersions; @Autowired private SchemaLocationsBean schemaLocationsBean; - + @Before public void init() throws Exception { - + eventPolicyConfig = new SpikeEventPolicyConfig(); eventPolicyConfig.setSearchKeystorePwd("password"); eventPolicyConfig.setSourceDomain("JUNIT"); - + eventPolicyConfig.setSchemaVersions(schemaVersions); eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); - + searchDb = new InMemorySearchDatastore(); policy = new SpikeAutosuggestProcessorStubbed(eventPolicyConfig).withSearchDb(searchDb); diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java index b78ba0e..514bd0b 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyTest.java @@ -34,6 +34,7 @@ import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.datarouter.Application; import org.onap.aai.datarouter.util.NodeUtils; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersions; @@ -43,24 +44,24 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") +@ContextConfiguration(classes = {Application.class}) public class SpikeEntityEventPolicyTest { private SpikeEntityEventPolicyConfig eventPolicyConfig; private SpikeEntityEventPolicy policy; private InMemorySearchDatastore searchDb; - + @Autowired private SchemaVersions schemaVersions; @Autowired private SchemaLocationsBean schemaLocationsBean; - + @Before public void init() throws Exception { - + eventPolicyConfig = new SpikeEntityEventPolicyConfig(); eventPolicyConfig.setSearchKeystorePwd("password"); eventPolicyConfig.setSourceDomain("JUNIT"); - + eventPolicyConfig.setSchemaVersions(schemaVersions); eventPolicyConfig.setSchemaLocationsBean(schemaLocationsBean); diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java index 56af3ea..ef9c1db 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorTest.java @@ -34,6 +34,7 @@ import org.apache.commons.io.IOUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.onap.aai.datarouter.Application; import org.onap.aai.datarouter.util.NodeUtils; import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersions; @@ -43,7 +44,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration("file:src/test/resources/spring-beans/data-router-oxm.xml") +@ContextConfiguration(classes = {Application.class}) public class SpikeEntitySearchProcessorTest { private SpikeEventPolicyConfig eventPolicyConfig; private SpikeEntitySearchProcessor policy; diff --git a/src/test/resources/config/schemaIngest.properties b/src/test/resources/config/schemaIngest.properties index 3c51c3d..dc70df1 100644 --- a/src/test/resources/config/schemaIngest.properties +++ b/src/test/resources/config/schemaIngest.properties @@ -1,16 +1,37 @@ # Properties for the SchemaLocationsBean # Properties required by the aai-common - aai-schema-ingest lib as of 1.3.0 schema.configuration.location=N/A -schema.nodes.location=src/test/resources/oxm-reader/oxm +schema.nodes.location=${APP_HOME}/target/oxm/${testShemaUnpackVersion}/oxm schema.edges.location= # These versions need to exist if they are included in the list -schema.version.list=v8,v9,v10,v11,v12,v13 +schema.version.list=v10,v11,v12,v13,v14,v15 # Decalares the oxm version to load -schema.version.api.default=v13 +schema.version.api.default=v15 # Don't use these properties in our application, need to be set to prevent an exception on startup (see SchemaVersions bean) -schema.version.depth.start=v13 -schema.version.related.link.start=v13 -schema.version.app.root.start=v13 -schema.version.namespace.change.start=v13 -schema.version.edge.label.start=v13
\ No newline at end of file +schema.version.depth.start=v15 +schema.version.related.link.start=v15 +schema.version.app.root.start=v15 +schema.version.namespace.change.start=v15 +schema.version.edge.label.start=v15 + +#This property is used to enable or disable schema service, possible values are: schema-service or config +schema.translator.list=config + +#These properties are needed when schema service is enabled +schema.service.base.url=https://localhost:8443/aai/schema-service/v1/ +schema.service.nodes.endpoint=nodes?version= +schema.service.edges.endpoint=edgerules?version= +schema.service.versions.endpoint=versions +schema.local=true +schema.filename=mockrequests +#Default rest client is the two-way-ssl +#schema.service.client=two-way-ssl +#Replace the below with the A&AI client key store +schema.service.ssl.key-store=${CONFIG_HOME}/auth/client-cert-onap.p12 +#Replace the below with the A&AI tomcat trust store +schema.service.ssl.trust-store=${CONFIG_HOME}/auth/tomcat_keystore +schema.service.ssl.trust-store-password=OBF:1y0q1uvc1uum1uvg1pil1pjl1uuq1uvk1uuu1y10 +#OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o +schema.service.ssl.key-store-password=OBF:1y0q1uvc1uum1uvg1pil1pjl1uuq1uvk1uuu1y10 +spring.application.name=datarouter diff --git a/src/test/resources/schemaIngest.properties b/src/test/resources/schemaIngest.properties deleted file mode 100644 index d56d2ef..0000000 --- a/src/test/resources/schemaIngest.properties +++ /dev/null @@ -1,4 +0,0 @@ -# Properties for the SchemaLocationsBean -schemaConfig=NA -nodeDir=src/test/resources/oxm-reader/oxm/ -edgeDir=
\ No newline at end of file diff --git a/src/test/resources/spring-beans/data-router-oxm.xml b/src/test/resources/spring-beans/data-router-oxm.xml index 90e7e97..d386b5d 100644 --- a/src/test/resources/spring-beans/data-router-oxm.xml +++ b/src/test/resources/spring-beans/data-router-oxm.xml @@ -5,10 +5,9 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd"> - <context:property-placeholder location="file:src/test/resources/config/schemaIngest.properties" ignore-unresolvable="true" /> - - <bean id="schemaVersions" class="org.onap.aai.setup.SchemaVersions"/> - - <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"/> - + <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor" autowire="byName"/> + <bean id="oxmModelLoader" class="org.onap.aai.schema.OxmModelLoader" > + <constructor-arg ref="nodeIngestor"/> + </bean> + </beans> diff --git a/src/test/resources/spring-beans/entity-event-policy.xml b/src/test/resources/spring-beans/entity-event-policy.xml new file mode 100644 index 0000000..8edfcb4 --- /dev/null +++ b/src/test/resources/spring-beans/entity-event-policy.xml @@ -0,0 +1,42 @@ +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + + <bean id="eepConfig" class="org.onap.aai.datarouter.policy.EntityEventPolicyConfig" > + <property name="sourceDomain" value="uINT5" /> + <property name="searchBaseUrl" value="https://au4txvcaaas100.auk4.aic.cip.att.com:9509" /> + <property name="searchEndpoint" value="services/search-data-service/v1/search/indexes/" /> + <property name="searchEndpointDocuments" value = "documents" /> + <property name="searchEntitySearchIndex" value="entitysearchindex-uint5.test" /> + <property name="searchEntityAutoSuggestIndex" value="entityautosuggestindex-uint5.test" /> + <property name="searchAggregationVnfIndex" value="aggregate_generic-vnf_index" /> + <property name="searchTopographySearchIndex" value="topographysearchindex-uint5.test" /> + <property name="searchCertName" value="aai-client-cert.p12" /> + <property name="searchKeystorePwd" value="OBF:1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o" /> + <property name="searchKeystore" value="tomcat_keystore" /> + <property name="schemaVersions" ref="schemaVersions" /> + <property name="schemaLocationsBean" ref="schemaLocationsBean" /> + </bean> + + <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor" autowire="byName"/> + <bean id="entityEventPolicy" class="org.onap.aai.datarouter.policy.EntityEventPolicy" init-method="startup" > + <constructor-arg ref="eepConfig"/> + </bean> +<!-- + <bean id="consumerBeanEntityEvent" class="com.ecomp.DMaapEventClientWrapper" > + <constructor-arg name="host" value="uebsb91kcdc.it.att.com:3905,uebsb92kcdc.it.att.com:3905,uebsb93kcdc.it.att.com:3905" /> + <constructor-arg name="topic" value="AAI-EVENT" /> + <constructor-arg name="username" value="m08479@aai.ecomp.att.com" /> + <constructor-arg name="password" value="OBF:1qab1lbw1kfr1ffg1hzn1i231fhe1kcn1lfm1qcr" /> + <constructor-arg name="consumerGroup" value="datarouter-uint5" /> + <constructor-arg name="consumerId" value="datarouter-uint5" /> + <constructor-arg name="timeoutMs" value="15000" /> + <constructor-arg name="messageLimit" value="10000" /> + <constructor-arg name="transportType" value="HTTPAAF" /> + <constructor-arg name="protocol" value="https" /> + <constructor-arg name="filter"> <null /> </constructor-arg> + </bean> +--> +</beans> |