From 846c78de8dff13cd5780b4501bbb5e261a62ae38 Mon Sep 17 00:00:00 2001 From: Jerry Flood Date: Wed, 10 Oct 2018 18:10:43 -0400 Subject: Update CMSO dev project to pass all Robot ETE test Issue-ID: OPTFRA-373 Change-Id: I05cffb239909bf6ed68c9c79f17b203357d8b057 Signed-off-by: Jerry Flood Signed-off-by: Jerry Flood --- .../cmso-dbchangelog/onap-cmso-v1-schema.sql | 4 +- cmso-robot/red.xml | 27 ++-- cmso-robot/robot/assets/test_properties.py | 22 ++- cmso-robot/robot/resources/scheduler_common.robot | 10 +- .../scheduler_requests/create_schedule.robot | 2 +- cmso-robot/robot/testsuites/VtmAccess.robot | 105 -------------- cmso-service/etc/config/cmso.properties | 25 +--- cmso-service/pom.xml | 9 +- .../main/java/org/onap/optf/cmso/Application.java | 1 + .../onap/optf/cmso/ApplicationPropertiesFiles.java | 46 ++++++ .../main/java/org/onap/optf/cmso/AuthProvider.java | 66 +++++++++ .../optf/cmso/CMSEnvironmentPostProcessor.java | 7 +- .../java/org/onap/optf/cmso/SecurityConfig.java | 61 ++++++++ .../org/onap/optf/cmso/model/ApprovalType.java | 19 +-- .../cmso/model/ChangeManagementChangeWindow.java | 19 +-- .../optf/cmso/model/ChangeManagementDetail.java | 15 +- .../optf/cmso/model/ChangeManagementGroup.java | 37 ++--- .../optf/cmso/model/ChangeManagementSchedule.java | 17 +-- .../java/org/onap/optf/cmso/model/DomainData.java | 13 +- .../java/org/onap/optf/cmso/model/Schedule.java | 19 +-- .../org/onap/optf/cmso/model/ScheduleApproval.java | 13 +- .../org/onap/optf/cmso/model/ScheduleEvent.java | 19 +-- .../cmso/service/rs/BaseSchedulerServiceImpl.java | 5 +- .../onap/optf/cmso/service/rs/HealthCheckImpl.java | 6 +- .../onap/optf/cmso/sostatus/MsoStatusClient.java | 8 +- .../src/main/resources/META-INF/spring.factories | 1 + .../src/main/resources/application.properties | 8 +- .../main/resources/swagger-ui/dist/swagger.json | 2 +- .../java/org/onap/optf/cmso/service/H2Test.java | 47 ------ .../optf/cmso/service/rs/CMSOServiceImplTest.java | 158 --------------------- 30 files changed, 328 insertions(+), 463 deletions(-) delete mode 100644 cmso-robot/robot/testsuites/VtmAccess.robot create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/ApplicationPropertiesFiles.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java create mode 100644 cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java create mode 100644 cmso-service/src/main/resources/META-INF/spring.factories delete mode 100644 cmso-service/src/test/java/org/onap/optf/cmso/service/H2Test.java delete mode 100644 cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java diff --git a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql index 4a99994..470cb3d 100644 --- a/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql +++ b/cmso-database/src/main/resources/cmso-dbchangelog/onap-cmso-v1-schema.sql @@ -1,6 +1,6 @@ -CREATE DATABASE IF NOT EXISTS CMSCHEDULER; -USE CMSCHEDULER; +CREATE DATABASE IF NOT EXISTS CMSO; +USE CMSO; CREATE TABLE IF NOT EXISTS DOMAINS ( domain VARCHAR(256) NOT NULL, diff --git a/cmso-robot/red.xml b/cmso-robot/red.xml index 368d2e8..6d935dd 100644 --- a/cmso-robot/red.xml +++ b/cmso-robot/red.xml @@ -34,24 +34,23 @@ 1.0 PROJECT - - - - - - - - - - - - - + + + + + + + + + + + + - + true 1024 diff --git a/cmso-robot/robot/assets/test_properties.py b/cmso-robot/robot/assets/test_properties.py index cab823d..9afd43d 100644 --- a/cmso-robot/robot/assets/test_properties.py +++ b/cmso-robot/robot/assets/test_properties.py @@ -3,25 +3,19 @@ from os.path import isfile, join # Should be provided in Jenkins job -GLOBAL_SCHEDULER_HOST = "dummy-host" -GLOBAL_SCHEDULER_PORT = dummy-port -GLOBAL_SCHEDULER_PROTOCOL = "https" -GLOBAL_VID_USERID = "onap-user" +GLOBAL_SCHEDULER_URL = "http://127.0.0.1:8080" +GLOBAL_SCHEDULER_USER = "onap-user" GLOBAL_SCHEDULER_PASSWORD = "pwd" -GLOBAL_SCHEDULER_USER = "dummy-user" +GLOBAL_CALLBACK_USERID = "onap-user" +GLOBAL_CALLBACK_PASSWORD = "onap-user" + GLOBAL_APPLICATION_ID= "schedulertest" -GLOBAL_VTM_URL="http://localhost:25055" -GLOBAL_LISTCHANGE_PATH="/service=searchchangerecord.vtm.att.com/vtm/searchChangeRecord/v1/listChangeRecords/version=1.0.0/envContext=TEST/routeOffer=DEFAULT" +GLOBAL_CALLBACK_URL="http://localhost:8900/scheduler/v1/loopbacktest/vid" + -GLOBAL_VTM_PROTO="http" -GLOBAL_VTM_HOST="dummy-host" -GLOBAL_VTM_CLOSE_PORT=31127 -GLOBAL_VTM_USER="dummy-user" -GLOBAL_VTM_PASSWORD="dummy-pwd" -GLOBAL_VID_CALLBACK_URL="http://localhost:8900/scheduler/v1/loopbacktest/vid" cmFailurePath= "robot/assets/templates/FailureCasesChangeManagement" GLOBAL_CM_FAILURE_TEMPLATES= [f for f in listdir(cmFailurePath) if isfile(join(cmFailurePath, f))] @@ -37,5 +31,5 @@ DELETE_TICKET_ENVS = [ {"scheduler" : "dummy", "vtm" : "dummy"}, ] -NODES = "dummy,dummy,dummy,dummy"; +NODES = "node1,node2,node3,node4"; \ No newline at end of file diff --git a/cmso-robot/robot/resources/scheduler_common.robot b/cmso-robot/robot/resources/scheduler_common.robot index 7fa8a59..0784d71 100644 --- a/cmso-robot/robot/resources/scheduler_common.robot +++ b/cmso-robot/robot/resources/scheduler_common.robot @@ -9,8 +9,8 @@ Library String Resource misc.robot *** Variables *** *** Variables *** -${SCHEDULER_PATH} /scheduler/v1 -${CHANGE_MANAGEMENT_PATH} ${SCHEDULER_PATH}/ChangeManagement +${SCHEDULER_PATH} /cmso/v1 +${CHANGE_MANAGEMENT_PATH} ${SCHEDULER_PATH} ${valid_status_codes} 200 202 400 404 204 409 #**************** Test Case Variables ****************** @@ -41,7 +41,7 @@ Get Change Management Post Scheduler [Documentation] Runs a scheduler POST request [Arguments] ${alias} ${data_path} ${data}={} - ${url}= Catenate ${GLOBAL_SCHEDULER_PROTOCOL}://${GLOBAL_SCHEDULER_HOST}:${GLOBAL_SCHEDULER_PORT} + ${url}= Catenate ${GLOBAL_SCHEDULER_URL} ${uuid}= Generate UUID ${proxies}= Create Dictionary no=pass ${session}= Create Session ${alias} ${url} @@ -57,7 +57,7 @@ Post Scheduler Delete Scheduler [Documentation] Runs a scheduler POST request [Arguments] ${alias} ${data_path} - ${url}= Catenate ${GLOBAL_SCHEDULER_PROTOCOL}://${GLOBAL_SCHEDULER_HOST}:${GLOBAL_SCHEDULER_PORT} + ${url}= Catenate ${GLOBAL_SCHEDULER_URL} ${uuid}= Generate UUID ${proxies}= Create Dictionary no=pass ${session}= Create Session ${alias} ${url} @@ -72,7 +72,7 @@ Delete Scheduler Get Scheduler [Documentation] Runs a scheduler GET request [Arguments] ${alias} ${data_path} - ${url}= Catenate ${GLOBAL_SCHEDULER_PROTOCOL}://${GLOBAL_SCHEDULER_HOST}:${GLOBAL_SCHEDULER_PORT} + ${url}= Catenate ${GLOBAL_SCHEDULER_URL} ${uuid}= Generate UUID ${proxies}= Create Dictionary no=pass ${session}= Create Session ${alias} ${url} diff --git a/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot b/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot index 7264b05..c7b79e7 100644 --- a/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot +++ b/cmso-robot/robot/resources/scheduler_requests/create_schedule.robot @@ -24,7 +24,7 @@ Create Schedule ${dict}= Create Dictionary serviceInstanceId=${uuid} parent_service_model_name=${uuid} ${callbackData}= Fill JSON Template File ${VID_TEMPLATES}/VidCallbackData.json.template ${dict} ${callbackDataString}= Json Escape ${callbackData} - ${map}= Create Dictionary uuid=${uuid} callbackUrl=${GLOBAL_VID_CALLBACK_URL} callbackData=${callbackDataString} testid=${testid} workflow=${workflow} userId=${GLOBAL_VID_USERID} + ${map}= Create Dictionary uuid=${uuid} callbackUrl=${GLOBAL_CALLBACK_URL} callbackData=${callbackDataString} testid=${testid} workflow=${workflow} userId=${GLOBAL_CALLBACK_USERID} ${nodelist}= Split String ${NODES} , ${nn}= Catenate 1 # Support up to 4 ChangeWindows diff --git a/cmso-robot/robot/testsuites/VtmAccess.robot b/cmso-robot/robot/testsuites/VtmAccess.robot deleted file mode 100644 index 4a9c0aa..0000000 --- a/cmso-robot/robot/testsuites/VtmAccess.robot +++ /dev/null @@ -1,105 +0,0 @@ -*** Settings *** -Documentation Creates VID VNF Instance - -Library String -Library OperatingSystem -Library StringTemplater -Library Collections -Library XML - -Resource ../resources/scheduler_common.robot -Resource ../resources/vtm_common.robot -*** Variables **** -${AOTS_USER} ${GLOBAL_VID_USERID} -${ASSETSSTRING} dummy-id - -*** Test Cases *** -Test1 - ${display} Create List actualStartDate actualEndDate dateModified assetId - ${assets}= Create List dummy - ${status}= Create List New Assigned Planning Scheduled Pending WorkInProgress Resolved - ${filter}= Create Dictionary plannedStartDateFrom=1505389844 assetId=${assets} - vTM Query Template vtm display=${display} filter=${filter} - -Delete Tickets - ${tickets} Create List dummy-id - :for ${ticket} in @{tickets} - \ vTM Close Ticket vtm ${ticket} ${GLOBAL_VID_USERID} - -Delete Old Tickets Atomic - @{assets}= Split String ${ASSETS} separator=, - ${end_time}= Get Current Date UTC - 1440 minutes result_format=timestamp exclude_millis=False - ${end_time}= Convert Date ${end_time} epoch - ${end_time}= Evaluate int(${end_time}) - ${display} Create List actualStartDate actualEndDate dateModified assetId - ${status}= Create List New Assigned Planning Scheduled Pending WorkInProgress Resolved - ${filter}= Create Dictionary plannedStartDateFrom=0 plannedEndDateTo=${end_time} assetId=@{assets} status=${status} - ${resp}= vTM Query Template vtm display=${display} filter=${filter} - Log ${resp.json()} - ${list}= Get From Dictionary ${resp.json()} changeInfo - ${changeIds}= Create Dictionary - :for ${ticket} in @{list} - \ ${changeId}= Get From Dictionary ${ticket} changeId - \ Set To Dictionary ${changeIds} ${changeId}=1 - # Weed out dupes if any - ${idlist} Get Dictionary Keys ${changeIds} - :for ${changeId} in @{idlist} - \ vTM Close Ticket vtm ${changeId} ${AOTS_USER} - -Delete Old Scheduler Tickets - :for ${env} in @{DELETE_TICKET_ENVS} - \ Set Global Variable ${GLOBAL_SCHEDULER_HOST} ${env['scheduler']} - \ Set Global Variable ${GLOBAL_VTM_HOST} ${env['vtm']} - \ Delete Scheduler Tickets For ENV - - -Cancel Tickets - ${tickets} Create List dummy-id - :for ${ticket} in @{tickets} - \ vTM Cancel Ticket vtm ${ticket} - - -Delete Schedule - ${uuid}= Catenate dummy-id - ${resp}= Delete Change Management auth schedules/${uuid} - - -*** Keywords *** -Delete Scheduler Tickets For ENV - # Make sure that the Scheduler in the config and the vTM system are the same. - # We will match the tickets to be deleted to the tickets in the scheduler DB - # to ensure we don't clobber other folks test data! - ${scheduler_tickets}= Get Scheduler Tickets - # ELiminate dupes - @{assets} Get Dictionary Values ${scheduler_tickets} - @{assets}= Remove Duplicates ${assets} - ${end_time}= Get Current Date UTC - 1440 minutes result_format=timestamp exclude_millis=False - ${end_time}= Convert Date ${end_time} epoch - ${end_time}= Evaluate int(${end_time}) - ${display} Create List actualStartDate actualEndDate dateModified assetId requesterId - ${status}= Create List New Assigned Planning Scheduled Pending WorkInProgress Resolved - ${filter}= Create Dictionary plannedStartDateFrom=0 plannedEndDateTo=${end_time} assetId=@{assets} status=${status} - ${resp}= vTM Query Template vtm display=${display} filter=${filter} - Log ${resp.json()} - ${list}= Get From Dictionary ${resp.json()} changeInfo - - ## Get list of tickets that are both in our DB and in AOTS - ${changeIds}= Create Dictionary - :for ${ticket} in @{list} - \ ${changeId}= Get From Dictionary ${ticket} changeId - \ ${status} ${value}= Run Keyword and Ignore Error Get From Dictionary ${scheduler_tickets} ${changeId} - \ Run Keyword If '${status}'=='PASS' Set To Dictionary ${changeIds} ${changeId}=1 - # Weed out dupes if any and only cance ones in our DB! - ${idlist} Get Dictionary Keys ${changeIds} - :for ${changeId} in @{idlist} - \ vTM Cancel Ticket vtm ${changeId} - -Get Scheduler Tickets - ${resp}= Get Change Management auth schedules/scheduleDetails - ${dict}= Create Dictionary - Log ${resp.json()} - :for ${details} in @{resp.json()} - \ ${status} ${value}= Run Keyword and Ignore Error Get From Dictionary ${details} aotsChangeId - \ ${assetId}= Get From Dictionary ${details} vnfName - \ Run Keyword If '${status}'=='PASS' Set To Dictionary ${dict} ${value}=${assetId} - [Return] ${dict} diff --git a/cmso-service/etc/config/cmso.properties b/cmso-service/etc/config/cmso.properties index 6f50e60..f103c57 100644 --- a/cmso-service/etc/config/cmso.properties +++ b/cmso-service/etc/config/cmso.properties @@ -32,18 +32,11 @@ ### ### MySQL DB. -spring.datasource.url=jdbc:mariadb://localhost:3305/cmso +spring.datasource.url=jdbc:mariadb://localhost:3306/cmso spring.datasource.driver-class-name=org.mariadb.jdbc.Driver -spring.datasource.username=cmso -cmso.database.password=enc:bfodXf8qRfCqMvlxVBYNWQ== - -### -### -### H2 DB. -#spring.datasource.url=jdbc:h2:file:./h2db;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=true;MODE=MYSQL -#spring.datasource.driver-class-name=org.h2.Driver -#spring.datasource.username=sa -#spring.datasource.password=sa +spring.datasource.username=root +spring.datasource.password=beer +cmso.database.password=beer spring.datasource.initialize=false spring.datasource.tomcat.max-wait=10000 @@ -51,23 +44,19 @@ spring.datasource.tomcat.initialSize=5 spring.datasource.tomcat.max-active=25 spring.datasource.tomcat.test-on-borrow=true -spring.jpa.show-sql=false +spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=none spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.EJB3NamingStrategy spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +spring.jpa.hibernate.id.new_generator_mappings=false +hibernate.id.new_generator_mappings=false logging.level.org.hibernate.SQL=TRACE logging.level.org.hibernate=TRACE # -#@BP.name="Enable AAF authentication" -#@BP.description="Log level for -#@BP.type=enum(true,false) -##BP.default=true -#@BP.required=false -#@BP.volatility=1 cmso.aaf.enabled=false # Enable swagger - Enable in development and test only diff --git a/cmso-service/pom.xml b/cmso-service/pom.xml index 5317b98..a36cb32 100644 --- a/cmso-service/pom.xml +++ b/cmso-service/pom.xml @@ -40,7 +40,6 @@ oparent 1.2.0 - org.onap.optf.cmso cmso-service 0.1.0-SNAPSHOT @@ -67,8 +66,7 @@ UTF-8 UTF-8 yyyyMMdd'T'HHmmss'Z' - - 1.4.197 + 2.2.1 ${basedir}/src/main/resources/swagger-ui/dist @@ -251,10 +249,11 @@ - com.h2database - h2 + org.mariadb.jdbc + mariadb-java-client + au.com.dius diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java index 7327124..f0580bd 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/Application.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/Application.java @@ -97,6 +97,7 @@ public class Application extends SpringBootServletInitializer { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); int port = Integer.parseInt(dispatchPort); tomcat.addAdditionalTomcatConnectors(createStandardConnector(port)); + org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter ss = null; return tomcat; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/ApplicationPropertiesFiles.java b/cmso-service/src/main/java/org/onap/optf/cmso/ApplicationPropertiesFiles.java new file mode 100644 index 0000000..912a6e1 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/ApplicationPropertiesFiles.java @@ -0,0 +1,46 @@ +/* + * Copyright © 2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.PropertySources; + + +@Configuration +@PropertySources({ + @PropertySource("file:etc/config/cmso.properties"), + @PropertySource("file:etc/config/optimizer.properties"), + @PropertySource("file:etc/config/ticketmgt.properties"), +}) +public class ApplicationPropertiesFiles +{ +} \ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java new file mode 100644 index 0000000..e002b7d --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/AuthProvider.java @@ -0,0 +1,66 @@ +/* + * Copyright © 2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso; + +import java.util.ArrayList; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.stereotype.Component; + +@Component +public class AuthProvider + implements AuthenticationProvider { + + @Autowired + Environment env; + + @Override + public Authentication authenticate(Authentication authentication) + throws AuthenticationException { + org.springframework.security.web.authentication.www.BasicAuthenticationFilter f = null; + String name = authentication.getName(); + String password = authentication.getCredentials().toString(); + //TODO check credentials until we enable AAF + return new UsernamePasswordAuthenticationToken( + name, password, new ArrayList<>()); + } + + @Override + public boolean supports(Class authentication) { + return authentication.equals( + UsernamePasswordAuthenticationToken.class); + } +} diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java index d1ccb7e..e5aca31 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/CMSEnvironmentPostProcessor.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,8 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; public class CMSEnvironmentPostProcessor implements EnvironmentPostProcessor { - + // TODO tested in ONAP springboot and this is called before all of the properties files have been loaded... + // perhaps there is a post post processor? Until this works. DB password will be in the clear in the proeprties files. @Override public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { String pwd = environment.getProperty("cmso.database.password"); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java new file mode 100644 index 0000000..a4802d2 --- /dev/null +++ b/cmso-service/src/main/java/org/onap/optf/cmso/SecurityConfig.java @@ -0,0 +1,61 @@ +/* + * Copyright © 2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. + * + * 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. + * + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * 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. +*/ +package org.onap.optf.cmso; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan; +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; + +@Configuration +@EnableWebSecurity +@ComponentScan("org.onap.optf") +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private AuthProvider authProvider; + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + + auth.authenticationProvider(authProvider); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http.csrf().disable().authorizeRequests().anyRequest().authenticated().and().httpBasic(); + + } +} \ No newline at end of file diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java index d4ab593..121774b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ApprovalType.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; @@ -50,11 +51,11 @@ public class ApprovalType implements Serializable { private static final long serialVersionUID = 1L; @Id - @GeneratedValue - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; @Column(name = "approval_count") - private int approvalCount; + private Integer approvalCount; @Column(name = "approval_type") private String approvalType; @@ -65,19 +66,19 @@ public class ApprovalType implements Serializable { public ApprovalType() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } - public int getApprovalCount() { + public Integer getApprovalCount() { return this.approvalCount; } - public void setApprovalCount(int approvalCount) { + public void setApprovalCount(Integer approvalCount) { this.approvalCount = approvalCount; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java index ceece9a..7224508 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementChangeWindow.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; @@ -58,8 +59,8 @@ public class ChangeManagementChangeWindow implements Serializable { @JsonIgnore @Id - @GeneratedValue - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; @JsonIgnore @Column(name = "finish_time") @@ -81,15 +82,15 @@ public class ChangeManagementChangeWindow implements Serializable { @JsonIgnore @Column(name = "change_management_groups_id") - private int changeManagementGroupsId; + private Integer changeManagementGroupsId; public ChangeManagementChangeWindow() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } @@ -109,11 +110,11 @@ public class ChangeManagementChangeWindow implements Serializable { public void setStartTime(String startTime) {} - public int getChangeManagementGroupsId() { + public Integer getChangeManagementGroupsId() { return changeManagementGroupsId; } - public void setChangeManagementGroupsId(int changeManagementGroupsId) { + public void setChangeManagementGroupsId(Integer changeManagementGroupsId) { this.changeManagementGroupsId = changeManagementGroupsId; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java index 3b82c62..31c4a2b 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementDetail.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ package org.onap.optf.cmso.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.Transient; @@ -58,8 +59,8 @@ import io.swagger.annotations.ApiModelProperty; public class ChangeManagementDetail { @Id @JsonIgnore - @GeneratedValue - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; @ApiModelProperty(value = "Name of the VNF.") @Column(name = "vnf_name") @@ -167,7 +168,7 @@ public class ChangeManagementDetail { private String msoTime; @JsonIgnore - private int schedules_id; + private Integer schedules_id; public String getVnfName() { return vnfName; @@ -241,11 +242,11 @@ public class ChangeManagementDetail { this.policyId = policyId; } - public int getSchedulesId() { + public Integer getSchedulesId() { return schedules_id; } - public void setSchedulesId(int schedules_id) { + public void setSchedulesId(Integer schedules_id) { this.schedules_id = schedules_id; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java index 0664851..6aeb325 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementGroup.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.NamedQuery; import javax.persistence.Table; @@ -59,8 +60,8 @@ public class ChangeManagementGroup implements Serializable { @JsonIgnore @Id - @GeneratedValue - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; @JsonIgnore @Column(name = "finish_time") @@ -95,19 +96,19 @@ public class ChangeManagementGroup implements Serializable { @JsonIgnore @Column(name = "schedules_id") - private int schedulesId; + private Integer schedulesId; @Column(name = "additional_duration_in_secs") @ApiModelProperty(value = "Time added to the workflow interval to allow for rollback in case of failure.") - private int additionalDurationInSecs; + private Integer additionalDurationInSecs; @ApiModelProperty(value = "The maximum number of workflows that should be started simultaneiously.") @Column(name = "concurrency_limit") - private int concurrencyLimit; + private Integer concurrencyLimit; @ApiModelProperty(value = "Expected duration of a successful workflow execution.") @Column(name = "normal_duration_in_secs") - private int normalDurationInSecs; + private Integer normalDurationInSecs; @ApiModelProperty( value = "The name of the schedule optimization policy used by the change management schedule optimizer.") @@ -121,11 +122,11 @@ public class ChangeManagementGroup implements Serializable { public ChangeManagementGroup() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } @@ -161,35 +162,35 @@ public class ChangeManagementGroup implements Serializable { public void setStartTime(String startTime) {} - public int getSchedulesId() { + public Integer getSchedulesId() { return schedulesId; } - public void setSchedulesId(int schedulesId) { + public void setSchedulesId(Integer schedulesId) { this.schedulesId = schedulesId; } - public int getAdditionalDurationInSecs() { + public Integer getAdditionalDurationInSecs() { return additionalDurationInSecs; } - public void setAdditionalDurationInSecs(int additionalDurationInSecs) { + public void setAdditionalDurationInSecs(Integer additionalDurationInSecs) { this.additionalDurationInSecs = additionalDurationInSecs; } - public int getConcurrencyLimit() { + public Integer getConcurrencyLimit() { return concurrencyLimit; } - public void setConcurrencyLimit(int concurrencyLimit) { + public void setConcurrencyLimit(Integer concurrencyLimit) { this.concurrencyLimit = concurrencyLimit; } - public int getNormalDurationInSecs() { + public Integer getNormalDurationInSecs() { return normalDurationInSecs; } - public void setNormalDurationInSecs(int normalDurationInSecs) { + public void setNormalDurationInSecs(Integer normalDurationInSecs) { this.normalDurationInSecs = normalDurationInSecs; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java index 779e8ca..9690290 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ChangeManagementSchedule.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.NamedQuery; @@ -60,7 +61,7 @@ public class ChangeManagementSchedule implements Serializable { @JsonIgnore @Id - @GeneratedValue + @GeneratedValue(strategy=GenerationType.IDENTITY) private Integer id; @ApiModelProperty(value = "TM Change Id") @@ -108,7 +109,7 @@ public class ChangeManagementSchedule implements Serializable { @Column(name = "change_management_groups_id") @JsonIgnore - private int changeManagementGroupsId; + private Integer changeManagementGroupsId; @JsonIgnore @Column(name = "dispatch_time") @@ -161,11 +162,11 @@ public class ChangeManagementSchedule implements Serializable { public ChangeManagementSchedule() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } @@ -217,11 +218,11 @@ public class ChangeManagementSchedule implements Serializable { this.tmChangeId = tmChangeId; } - public int getChangeManagementGroupsId() { + public Integer getChangeManagementGroupsId() { return changeManagementGroupsId; } - public void setChangeManagementGroupsId(int changeManagementGroupsId) { + public void setChangeManagementGroupsId(Integer changeManagementGroupsId) { this.changeManagementGroupsId = changeManagementGroupsId; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java index f32ff98..fc86964 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/DomainData.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ package org.onap.optf.cmso.model; import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -55,8 +56,8 @@ public class DomainData implements Serializable { @JsonIgnore @Id - @GeneratedValue - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; private String name; @@ -69,11 +70,11 @@ public class DomainData implements Serializable { public DomainData() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java index 3a13563..d6fe4f9 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/Schedule.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.NamedQuery; @@ -63,8 +64,8 @@ public class Schedule implements Serializable { @JsonIgnore @Id - @GeneratedValue - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; @JsonIgnore @Column(name = "create_date_time") @@ -93,7 +94,7 @@ public class Schedule implements Serializable { @JsonIgnore @Column(name = "optimizer_attempts_to_schedule") - private int optimizerAttemptsToSchedule; + private Integer optimizerAttemptsToSchedule; @JsonIgnore @Column(name = "optimizer_return_date_time") @@ -159,11 +160,11 @@ public class Schedule implements Serializable { public Schedule() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } @@ -307,11 +308,11 @@ public class Schedule implements Serializable { return sa; } - public int getOptimizerAttemptsToSchedule() { + public Integer getOptimizerAttemptsToSchedule() { return optimizerAttemptsToSchedule; } - public void setOptimizerAttemptsToSchedule(int optimizerAttemptsToSchedule) { + public void setOptimizerAttemptsToSchedule(Integer optimizerAttemptsToSchedule) { this.optimizerAttemptsToSchedule = optimizerAttemptsToSchedule; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java index adfafd1..dee3c42 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleApproval.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; @@ -59,9 +60,9 @@ public class ScheduleApproval implements Serializable { private static final long serialVersionUID = 1L; @Id - @GeneratedValue + @GeneratedValue(strategy=GenerationType.IDENTITY) @JsonIgnore - private int id; + private Integer id; @JsonIgnore @Column(name = "approval_date_time") @@ -91,11 +92,11 @@ public class ScheduleApproval implements Serializable { public ScheduleApproval() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java index 97a96f0..46cb46e 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/model/ScheduleEvent.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ package org.onap.optf.cmso.model; import java.io.Serializable; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Lob; import javax.persistence.NamedQuery; @@ -54,7 +56,8 @@ public class ScheduleEvent implements Serializable { private static final long serialVersionUID = 1L; @Id - private int id; + @GeneratedValue(strategy=GenerationType.IDENTITY) + private Integer id; private String domain; @@ -79,17 +82,17 @@ public class ScheduleEvent implements Serializable { private String reminderTime; @Column(name = "schedules_id") - private int schedulesId; + private Integer schedulesId; private String status; public ScheduleEvent() {} - public int getId() { + public Integer getId() { return this.id; } - public void setId(int id) { + public void setId(Integer id) { this.id = id; } @@ -109,11 +112,11 @@ public class ScheduleEvent implements Serializable { this.eventText = eventText; } - public int getSchedulesId() { + public Integer getSchedulesId() { return this.schedulesId; } - public void setSchedulesId(int schedulesId) { + public void setSchedulesId(Integer schedulesId) { this.schedulesId = schedulesId; } diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java index 8dbafbc..2e0cfeb 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/BaseSchedulerServiceImpl.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -91,6 +91,7 @@ public class BaseSchedulerServiceImpl { // are 1<=>1 at this // point. s.setScheduleName(scheduleMessage.getScheduleName()); + s.setOptimizerAttemptsToSchedule(0); s.setScheduleInfo(scheduleMessage.getSchedulingInfo().toString()); s.setStatus(CMSStatusEnum.PendingSchedule.toString()); scheduleDAO.save(s); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java index f994dc8..a3a4ae8 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/service/rs/HealthCheckImpl.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -80,8 +80,8 @@ public class HealthCheckImpl implements HealthCheck { if (checkInterfaces) { addToHealthCheckMessage(hc, tmClient.healthCheck()); - addToHealthCheckMessage(hc, sniroClient.healthCheck()); addToHealthCheckMessage(hc, msoStatusClient.healthCheck()); + addToHealthCheckMessage(hc, sniroClient.healthCheck()); } addToHealthCheckMessage(hc, this.healthCheck()); diff --git a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java index 42f282a..8cbe459 100644 --- a/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java +++ b/cmso-service/src/main/java/org/onap/optf/cmso/sostatus/MsoStatusClient.java @@ -1,6 +1,6 @@ /* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. + * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -247,8 +247,8 @@ public class MsoStatusClient { public HealthCheckComponent healthCheck() { Map mdcSave = Mdc.save(); String requestId = "healthCheck"; - String url = env.getProperty("so.url"); - String user = env.getProperty("so.user"); + String url = env.getProperty("so.url", ""); + String user = env.getProperty("so.user", ""); String pass = pm.getProperty("so.pass", ""); if (!url.endsWith("/")) url = url + "/"; diff --git a/cmso-service/src/main/resources/META-INF/spring.factories b/cmso-service/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..5047be8 --- /dev/null +++ b/cmso-service/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.env.EnvironmentPostProcessor=org.onap.optf.cmso.CMSEnvironmentPostProcessor \ No newline at end of file diff --git a/cmso-service/src/main/resources/application.properties b/cmso-service/src/main/resources/application.properties index b6239c9..25c5b10 100644 --- a/cmso-service/src/main/resources/application.properties +++ b/cmso-service/src/main/resources/application.properties @@ -36,7 +36,7 @@ info.build.version=@project.version@ spring.jersey.type=filter spring.mvc.urls=swagger,docs,prometheus -server.contextPath=/cmso +server.servlet.context-path=/cmso #This property is used to set the Tomcat connector attributes.developers can define multiple attributes separated by comma #tomcat.connector.attributes=allowTrace-true @@ -53,3 +53,9 @@ server.port=8080 server.dispatchPort=8089 kubernetes.namespace=org.onap.optf.cmso + + +com.att.eelf.logging.file=logback.xml +com.att.eelf.logging.path= + +logging.config= diff --git a/cmso-service/src/main/resources/swagger-ui/dist/swagger.json b/cmso-service/src/main/resources/swagger-ui/dist/swagger.json index b8f5def..635d6a9 100644 --- a/cmso-service/src/main/resources/swagger-ui/dist/swagger.json +++ b/cmso-service/src/main/resources/swagger-ui/dist/swagger.json @@ -2,7 +2,7 @@ "swagger" : "2.0", "info" : { "version" : "0.1.0-SNAPSHOT", - "title" : "cmso" + "title" : "cmso-service" }, "basePath" : "/cmso", "paths" : { diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/service/H2Test.java b/cmso-service/src/test/java/org/onap/optf/cmso/service/H2Test.java deleted file mode 100644 index 8a586a9..0000000 --- a/cmso-service/src/test/java/org/onap/optf/cmso/service/H2Test.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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. -*/ - -package org.onap.optf.cmso.service; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = {"classpath:testConfig.xml"}) -public class H2Test { - - @Test - public void h2Test() { - - } -} diff --git a/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java b/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java deleted file mode 100644 index b989a73..0000000 --- a/cmso-service/src/test/java/org/onap/optf/cmso/service/rs/CMSOServiceImplTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright © 2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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. - * - * - * Unless otherwise specified, all documentation contained herein is licensed - * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); - * you may not use this documentation except in compliance with the License. - * You may obtain a copy of the License at - * - * https://creativecommons.org/licenses/by/4.0/ - * - * Unless required by applicable law or agreed to in writing, documentation - * 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. -*/ - -package org.onap.optf.cmso.service.rs; - -import static org.junit.Assert.assertEquals; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import javax.ws.rs.core.Response; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.optf.cmso.JpaInit; -import org.onap.optf.cmso.JtestHelper; -import org.onap.optf.cmso.common.CMSRequestError; -import org.onap.optf.cmso.service.rs.models.CMSMessage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; -import org.springframework.test.context.junit4.SpringRunner; -import com.fasterxml.jackson.databind.ObjectMapper; -import scala.collection.mutable.StringBuilder; - -@RunWith(SpringRunner.class) -@DataJpaTest -public class CMSOServiceImplTest { - - @Autowired - CMSOService cMSOServiceImpl; - - @Autowired - private TestEntityManager entityManager; - - @Before - public void setUp() throws Exception { - JpaInit.init(entityManager); - } - - @Test - public void test_createScheduleRequest() { - String[] templates = {"changemanagement/MultipleVnfImmediate.json.template",}; - String[] domains = {"ChangeManagement",}; - String[] userIds = {"jf9860",}; - String[] callbackUrls = {"http://localhost:8089/",}; - String[] callbackDatum = {"sdafafadfdasfdsafdsa",}; - String[] workflows = {"Replace", "Update", "NewOne",}; - Integer[] normalDurationInSeeconds = {10,}; - Integer[] additionalDurationInSeeconds = {10,}; - String[] results = {"500:", // {additionalDurationInSeconds=10, workflow=Replace, - // domain=ChangeManagement, - // callbackData=sdafafadfdasfdsafdsa, testid=79e1, - // callbackUrl=http://localhost:8089/, - // uuid=a36b45b9-dff4-45b4-ac6b-2a4f35e179e1, userId=jf9860, - // normalDurationInSeconds=10} - "500:", // {additionalDurationInSeconds=10, workflow=Update, - // domain=ChangeManagement, - // callbackData=sdafafadfdasfdsafdsa, testid=c525, - // callbackUrl=http://localhost:8089/, - // uuid=26b189f7-b075-4013-b487-d938b895c525, userId=jf9860, - // normalDurationInSeconds=10} - "500:", // {additionalDurationInSeconds=10, workflow=NewOne, - // domain=ChangeManagement, - // callbackData=sdafafadfdasfdsafdsa, testid=8e87, - // callbackUrl=http://localhost:8089/, - // uuid=4f59b14a-8040-4257-8981-defcb8f38e87, userId=jf9860, - // normalDurationInSeconds=10} - }; - - int i = 0; - for (String template : templates) { - for (String domain : domains) { - for (String userId : userIds) { - for (String callbackUrl : callbackUrls) { - for (String callbackData : callbackDatum) { - for (String workflow : workflows) { - for (Integer normalDuration : normalDurationInSeeconds) { - for (Integer additionalDuration : additionalDurationInSeeconds) { - Map values = new HashMap(); - String scheduleId = UUID.randomUUID().toString(); - values.put("uuid", scheduleId); - values.put("testid", scheduleId.substring(scheduleId.length() - 4)); - values.put("domain", domain); - values.put("userId", userId); - values.put("callbackUrl", callbackUrl); - values.put("callbackData", callbackData); - values.put("workflow", workflow); - values.put("normalDurationInSeconds", normalDuration.toString()); - values.put("additionalDurationInSeconds", additionalDuration.toString()); - String json = JtestHelper.template(template, values); - ObjectMapper om = new ObjectMapper(); - CMSMessage scheduleMessage; - try { - scheduleMessage = om.readValue(json, CMSMessage.class); - MockHttpServletRequest mrequest = new MockHttpServletRequest(); - mrequest.url.append(scheduleId); - - Response response = cMSOServiceImpl.createScheduleRequest("v2", scheduleId, - scheduleMessage, mrequest.request); - - Object result = response.getEntity(); - StringBuilder sb = new StringBuilder(); - sb.append(response.getStatus()).append(":"); - if (result instanceof CMSRequestError) { - String r = result.toString().replaceAll(" : Reason :.*$", ""); - sb.append(r.replaceAll(scheduleId, "")); - } - // Generate results[] entry - System.out.println("\"" + sb.toString() + "\", //" + values.toString()); - - // Debug an assertion - System.out.println(results[i] + ":" + sb.toString()); - assertEquals(results[i].equals(sb.toString()), true); - i++; - - } catch (Exception e) { - e.printStackTrace(); - } - - } - } - } - - } - } - } - } - } - } -} -- cgit 1.2.3-korg