diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-common')
11 files changed, 462 insertions, 125 deletions
diff --git a/ecomp-sdk/epsdk-app-common/README.md b/ecomp-sdk/epsdk-app-common/README.md index 1823262f..fa3e7bc4 100644 --- a/ecomp-sdk/epsdk-app-common/README.md +++ b/ecomp-sdk/epsdk-app-common/README.md @@ -30,6 +30,7 @@ Version 1.4.0 - PORTAL-72 Address Sonar Scan code issues - PORTAL-90 Use approved ONAP license text - Portal-86 Remove application specific usages from tests and other files +- PORTAL-78 Fix SingleSignon by force session creation prior to redirection to portal Version 1.3.0, 28 August 2017 diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java index 17630643..fb2e3b80 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/SingleSignOnController.java @@ -202,6 +202,11 @@ public class SingleSignOnController extends UnRestrictedBaseController { final String redirectUrl = portalUrl + "?uebAppKey=" + uebAppKey + "&redirectUrl=" + encodedReturnToAppUrl; logger.debug(EELFLoggerDelegate.debugLogger, "singleSignOnLogin: portal-bound redirect URL is {}", redirectUrl); + + // this line may not be necessary but jsessionid coockie is not getting created in all cases; + // so force the cookie creation + request.getSession(true); + return new ModelAndView("redirect:" + redirectUrl); } } diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/package-info.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/package-info.java index 3cbcb3ba..a9db4ea1 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/package-info.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/core/package-info.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.controller.core; /** diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/package-info.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/package-info.java index 57b7d4a4..6b6effca 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/package-info.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/controller/sample/package-info.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.controller.sample; /** diff --git a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java index 9c77441d..3efe46fd 100644 --- a/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java +++ b/ecomp-sdk/epsdk-app-common/src/main/java/org/onap/portalapp/service/OnBoardingApiServiceImpl.java @@ -55,10 +55,14 @@ import org.onap.portalsdk.core.onboarding.client.AppContextManager; import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestAPIService; import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.onboarding.listener.PortalTimeoutHandler; +import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; +import org.onap.portalsdk.core.onboarding.util.PortalApiProperties; import org.onap.portalsdk.core.restful.domain.EcompRole; import org.onap.portalsdk.core.restful.domain.EcompUser; +import org.onap.portalsdk.core.service.RestApiRequestBuilder; import org.onap.portalsdk.core.service.RoleService; import org.onap.portalsdk.core.service.UserProfileService; +import org.onap.portalsdk.core.service.UserService; import org.onap.portalsdk.core.service.WebServiceCallService; import org.onap.portalsdk.core.util.JSONUtil; import org.onap.portalsdk.core.util.SystemProperties; @@ -66,6 +70,9 @@ import org.onap.portalsdk.core.web.support.UserUtils; import org.slf4j.MDC; import org.springframework.context.ApplicationContext; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.TypeFactory; + /** * Implements the REST API interface to answer requests made by Portal app about * users and active sessions. @@ -84,7 +91,14 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService { private IAdminAuthExtension adminAuthExtensionServiceImpl; private LoginStrategy loginStrategy; - + private UserService userService; + private RestApiRequestBuilder restApiRequestBuilder; + + private static final String isAccessCentralized = PortalApiProperties + .getProperty(PortalApiConstants.ROLE_ACCESS_CENTRALIZED); + + private static final String isCentralized = "remote"; + public OnBoardingApiServiceImpl() { // Defend against null-pointer exception during server startup // that was caused by a spurious Spring annotation on this class. @@ -96,6 +110,10 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService { loginStrategy = appContext.getBean(LoginStrategy.class); // initialize the base class definition for Admin Auth Extension adminAuthExtensionServiceImpl = appContext.getBean(IAdminAuthExtension.class); + userService = appContext.getBean(UserService.class); + if(isCentralized.equals(isAccessCentralized)){ + restApiRequestBuilder = appContext.getBean(RestApiRequestBuilder.class); + } } private void setCurrentAttributes(User user, EcompUser userJson) { @@ -200,7 +218,15 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService { try { if (logger.isDebugEnabled()) logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId); - User user = userProfileService.getUserByLoginId(loginId); + + User user = null; + if(isCentralized.equals(isAccessCentralized)){ + String responseString = restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId); + user = userService.userMapper(responseString); + } + else{ + user = userProfileService.getUserByLoginId(loginId); + } if (user == null) { logger.info(EELFLoggerDelegate.debugLogger, "User + " + loginId + " doesn't exist"); return null; @@ -224,16 +250,36 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService { @Override public List<EcompUser> getUsers() throws PortalAPIException { + String users_List = ""; try { - List<User> users = userProfileService.findAllActive(); - List<EcompUser> ecompUsers = new ArrayList<EcompUser>(); - for (User user : users) - ecompUsers.add(UserUtils.convertToEcompUser(user)); - return ecompUsers; + if (isCentralized.equals(isAccessCentralized)) { + List<EcompUser> UsersList = new ArrayList<>(); + List<EcompUser> finalUsersList = new ArrayList<>(); + users_List = restApiRequestBuilder.getViaREST("/users", true, null); + ObjectMapper mapper = new ObjectMapper(); + UsersList = mapper.readValue(users_List, + TypeFactory.defaultInstance().constructCollectionType(List.class, EcompUser.class)); + for (EcompUser userString : UsersList) { + EcompUser ecompUser = mapper.convertValue(userString, EcompUser.class); + finalUsersList.add(ecompUser); + } + return UsersList; + } + else { + List<User> users = userProfileService.findAllActive(); + List<EcompUser> ecompUsers = new ArrayList<EcompUser>(); + for (User user : users) + ecompUsers.add(UserUtils.convertToEcompUser(user)); + return ecompUsers; + } } catch (Exception e) { String response = "OnboardingApiService.getUsers failed"; logger.error(EELFLoggerDelegate.errorLogger, response, e); - throw new PortalAPIException(response, e); + if (users_List.equals("")) { + throw new PortalAPIException("Application is Inactive"); + } else { + throw new PortalAPIException(response, e); + } } } @@ -301,6 +347,20 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService { logger.debug(EELFLoggerDelegate.debugLogger, "## REST API ## loginId: {}", loginId); List<EcompRole> ecompRoles = new ArrayList<EcompRole>(); try { + + if(isCentralized.equals(isAccessCentralized)){ + User user = null; + String responseString = restApiRequestBuilder.getViaREST("/user/" + loginId, true, loginId); + user = userService.userMapper(responseString); + SortedSet<Role> currentRoles = null; + if (user != null) { + currentRoles = user.getRoles(); + if (currentRoles != null) + for (Role role : currentRoles) + ecompRoles.add(UserUtils.convertToEcompRole(role)); + } + } + else{ User user = userProfileService.getUserByLoginId(loginId); SortedSet<Role> currentRoles = null; if (user != null) { @@ -309,6 +369,7 @@ public class OnBoardingApiServiceImpl implements IPortalRestAPIService { for (Role role : currentRoles) ecompRoles.add(UserUtils.convertToEcompRole(role)); } + } return ecompRoles; } catch (Exception e) { String response = "OnboardingApiService.getUserRoles failed"; diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/SanityTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/SanityTest.java index 259aecd4..479f83e0 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/SanityTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/SanityTest.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp; import org.junit.Assert; diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/CollaborationControllerTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/CollaborationControllerTest.java index 97786046..e6e604cb 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/CollaborationControllerTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/CollaborationControllerTest.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.controller; import org.junit.Assert; @@ -9,21 +46,18 @@ import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +public class CollaborationControllerTest extends MockApplicationContextTestSuite { - -public class CollaborationControllerTest extends MockApplicationContextTestSuite{ - @Test public void testGetAvailableRoles() throws Exception { MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get("/collaborate_list"); User user = new User(); user.setId(1l); - //user.setOrgUserId("abc"); + // user.setOrgUserId("abc"); requestBuilder.sessionAttr(SystemProperties.getProperty(SystemProperties.USER_ATTRIBUTE_NAME), user); - - ResultActions ra =getMockMvc().perform(requestBuilder); - Assert.assertEquals(2,ra.andReturn().getModelAndView().getModelMap().size()); - } + ResultActions ra = getMockMvc().perform(requestBuilder); + Assert.assertEquals(2, ra.andReturn().getModelAndView().getModelMap().size()); + } } diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/NetMapTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/NetMapTest.java index 0ab09291..61973f64 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/NetMapTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/controller/NetMapTest.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.controller; import org.junit.Assert; diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/core/MockApplicationContextTestSuite.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/core/MockApplicationContextTestSuite.java index cede7e0c..ee9db320 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/core/MockApplicationContextTestSuite.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/core/MockApplicationContextTestSuite.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.core; import java.io.IOException; @@ -23,105 +60,91 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; - - /** - * - * - * - * In order to write a unit test, - * 1. inherit this class - See SanityTest.java - * 2. place the "war" folder on your test class's classpath - * 3. run the test with the following VM argument; This is important because when starting the application from Container, the System Properties file (SystemProperties.java) can have the direct path - * but, when running from the Mock Junit container, the path should be prefixed with "classpath" to enable the mock container to search for the file in the classpath - * -Dcontainer.classpath="classpath:" + * In order to write a unit test, 1. inherit this class - See SanityTest.java 2. + * place the "war" folder on your test class's classpath 3. run the test with + * the following VM argument; This is important because when starting the + * application from Container, the System Properties file + * (SystemProperties.java) can have the direct path but, when running from the + * Mock Junit container, the path should be prefixed with "classpath" to enable + * the mock container to search for the file in the classpath + * -Dcontainer.classpath="classpath:" * */ - @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = {MockAppConfig.class}) -@ActiveProfiles(value="test") +@ContextConfiguration(loader = AnnotationConfigWebContextLoader.class, classes = { MockAppConfig.class }) +@ActiveProfiles(value = "test") public class MockApplicationContextTestSuite { - - @Autowired - public WebApplicationContext wac; - - private MockMvc mockMvc; - - @Before - public void setup() { - if(mockMvc == null) { - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); - - } - } - - public Object getBean(String name) { - return this.wac.getBean(name); - } + @Autowired + public WebApplicationContext wac; - public MockMvc getMockMvc() { - return mockMvc; - } + private MockMvc mockMvc; + + @Before + public void setup() { + if (mockMvc == null) { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); - public void setMockMvc(MockMvc mockMvc) { - this.mockMvc = mockMvc; - } - - public WebApplicationContext getWebApplicationContext() { - return wac; } - - - - + } + + public Object getBean(String name) { + return this.wac.getBean(name); + } + + public MockMvc getMockMvc() { + return mockMvc; + } + + public void setMockMvc(MockMvc mockMvc) { + this.mockMvc = mockMvc; + } + + public WebApplicationContext getWebApplicationContext() { + return wac; + } + } - - - @Configuration - @ComponentScan(basePackages = "org.onap", - excludeFilters = { - } - ) - @Profile("test") - class MockAppConfig extends AppConfig { - - @Bean - public SystemProperties systemProperties(){ - return new MockSystemProperties(); - } - - @Bean - public AbstractCacheManager cacheManager() { - return new CacheManager() { - - public void configure() throws IOException { - - } - }; - } - - protected String[] tileDefinitions() { - return new String[] {"classpath:/WEB-INF/fusion/defs/definitions.xml", "classpath:/WEB-INF/defs/definitions.xml"}; - } - - @Override - public void addInterceptors(InterceptorRegistry registry) { - //registry.addInterceptor(new SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout()); - //registry.addInterceptor(resourceInterceptor()); + +@Configuration +@ComponentScan(basePackages = "org.onap", excludeFilters = {}) +@Profile("test") +class MockAppConfig extends AppConfig { + + @Bean + public SystemProperties systemProperties() { + return new MockSystemProperties(); + } + + @Bean + public AbstractCacheManager cacheManager() { + return new CacheManager() { + + public void configure() throws IOException { + } - - public static class MockSystemProperties extends SystemProperties { - - public MockSystemProperties() { - } - - } - + }; + } + + protected String[] tileDefinitions() { + return new String[] { "classpath:/WEB-INF/fusion/defs/definitions.xml", + "classpath:/WEB-INF/defs/definitions.xml" }; + } + + @Override + public void addInterceptors(InterceptorRegistry registry) { + // registry.addInterceptor(new + // SessionTimeoutInterceptor()).excludePathPatterns(getExcludeUrlPathsForSessionTimeout()); + // registry.addInterceptor(resourceInterceptor()); + } + + public static class MockSystemProperties extends SystemProperties { + + public MockSystemProperties() { } - - + } +} diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/ProfileServiceTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/ProfileServiceTest.java index 0e90c501..36d54ba6 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/ProfileServiceTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/service/ProfileServiceTest.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.service; import java.util.List; @@ -11,27 +48,24 @@ import org.onap.portalsdk.core.service.ProfileService; import org.onap.portalsdk.core.service.UserProfileService; import org.springframework.beans.factory.annotation.Autowired; - - - public class ProfileServiceTest extends MockApplicationContextTestSuite { - + @Autowired ProfileService service; - + @Autowired UserProfileService userProfileService; - + @Test - public void testFindAll() throws Exception{ - + public void testFindAll() throws Exception { + List<Profile> profiles = service.findAll(); Assert.assertTrue(profiles.size() > 0); } @Test public void testFindAllActive() { - + List<User> users = userProfileService.findAllActive(); List<User> activeUsers = userProfileService.findAllActive(); Assert.assertTrue(users.size() - activeUsers.size() >= 0); diff --git a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/workflow/services/WorkflowScheduleServiceTest.java b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/workflow/services/WorkflowScheduleServiceTest.java index c59619d2..e26c35ab 100644 --- a/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/workflow/services/WorkflowScheduleServiceTest.java +++ b/ecomp-sdk/epsdk-app-common/src/test/java/org/onap/portalapp/workflow/services/WorkflowScheduleServiceTest.java @@ -1,3 +1,40 @@ +/* + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software 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. + * + * ============LICENSE_END============================================ + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ package org.onap.portalapp.workflow.services; import java.util.Calendar; @@ -9,20 +46,14 @@ import org.onap.portalsdk.workflow.domain.WorkflowSchedule; import org.onap.portalsdk.workflow.services.WorkflowScheduleService; import org.springframework.beans.factory.annotation.Autowired; - - public class WorkflowScheduleServiceTest extends MockApplicationContextTestSuite { - + @Autowired WorkflowScheduleService service; -// @Autowired -// SchedulerFactoryBean schedulerBean; - + @Test public void testFire() { - - // List<WorkflowSchedule> wfs = service.findAll(); - + final WorkflowSchedule ws = new WorkflowSchedule(); ws.setId(999L); ws.setWorkflowKey("test"); @@ -30,15 +61,15 @@ public class WorkflowScheduleServiceTest extends MockApplicationContextTestSuite final Calendar instance = Calendar.getInstance(); instance.add(Calendar.YEAR, 3); ws.setEndDateTime(instance.getTime()); - + ws.setStartDateTime(Calendar.getInstance().getTime()); - try{ + try { service.saveWorkflowSchedule(ws); Assert.assertTrue(true); - } catch(Exception e) { + } catch (Exception e) { Assert.fail(e.getMessage()); } - + } } |