diff options
5 files changed, 79 insertions, 32 deletions
diff --git a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java index b4dcd346a..d9b0f092e 100644 --- a/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java +++ b/epsdk-app-onap/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java @@ -37,6 +37,8 @@ */ package org.onap.portalapp.conf; +import static org.apache.commons.lang3.StringUtils.isNotEmpty; + import java.util.ArrayList; import java.util.List; import javax.sql.DataSource; @@ -50,6 +52,7 @@ import org.onap.portalsdk.core.objectcache.AbstractCacheManager; import org.onap.portalsdk.core.service.DataAccessService; import org.onap.portalsdk.core.util.CacheManager; import org.onap.portalsdk.core.util.SystemProperties; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -164,8 +167,15 @@ public class ExternalAppConfig extends AppConfig implements Configurable { } @Bean - public LoginStrategy loginStrategy() { - return new LoginStrategyImpl(); + public LoginStrategy loginStrategy(@Value("${login.strategy.classname:}") String classname) throws ReflectiveOperationException { + return isNotEmpty(classname) ? + newLoginStrategyInstance(classname) : new LoginStrategyImpl(); + } + + private LoginStrategy newLoginStrategyInstance(String loginStrategyClassname) throws ReflectiveOperationException { + return (LoginStrategy) Class.forName(loginStrategyClassname) + .getConstructor() + .newInstance(); } @Bean diff --git a/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java b/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java index 1bdf46325..f06526860 100644 --- a/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java +++ b/epsdk-app-onap/src/test/java/org/onap/portalapp/conf/ExternalAppConfigTest.java @@ -37,18 +37,23 @@ */ package org.onap.portalapp.conf; +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + import java.util.List; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.junit.Assert; import org.junit.Test; +import org.onap.portalapp.login.LoginStrategyImpl; import org.onap.portalapp.scheduler.RegistryAdapter; import org.onap.portalsdk.core.auth.LoginStrategy; +import org.onap.portalsdk.core.onboarding.exception.PortalAPIException; import org.onap.portalsdk.core.service.DataAccessService; -import org.springframework.jdbc.datasource.init.DataSourceInitializer; -import org.springframework.jdbc.datasource.init.DatabasePopulator; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ViewResolver; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; public class ExternalAppConfigTest { @@ -112,12 +117,39 @@ public class ExternalAppConfigTest { } @Test - public void testLoginStrategy() throws Exception { - ExternalAppConfig testSubject; - LoginStrategy result; + public void loginStrategy_givenEmptyString_yieldDefault() throws Exception { + assertThat(new ExternalAppConfig().loginStrategy(""), + is(instanceOf(LoginStrategyImpl.class))); + } - // default test - testSubject = createTestSubject(); - result = testSubject.loginStrategy(); + @Test + public void loginStrategy_givenNullString_yieldDefault() throws Exception { + assertThat(new ExternalAppConfig().loginStrategy(null), + is(instanceOf(LoginStrategyImpl.class))); + } + + public static class DummyLoginStrategy extends LoginStrategy { + @Override + public ModelAndView doLogin(HttpServletRequest request, HttpServletResponse response) { + return null; + } + + @Override + public String getUserId(HttpServletRequest request) { + return null; + } + } + + @Test + public void loginStrategy_givenClassname_yieldClassInstance() throws Exception { + assertThat( + new ExternalAppConfig().loginStrategy("org.onap.portalapp.conf.ExternalAppConfigTest$DummyLoginStrategy"), + is(instanceOf(DummyLoginStrategy.class))); + } + + @Test(expected = ClassNotFoundException.class) + public void loginStrategy_givenMissingClassname_throwsException() throws Exception { + new ExternalAppConfig().loginStrategy("no.real.classname"); + Assert.fail("should throw"); } -}
\ No newline at end of file +} diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js index a7f7e9128..b6725b124 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.controller.js @@ -30,7 +30,7 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal $scope.vfModuleName = vfModule.name; $scope.volumeGroups = vfModule.volumeGroups; $scope.lcpAndTenant = null; - $scope.regionSelection = {lcpRegion: null, legacyRegion: null, tenant: null}; + $scope.regionSelection = {optionId: null, legacyRegion: null, tenant: null}; $scope.lcpRegionList = null; $scope.isHomingData = false; $scope.megaRegion = ['AAIAIC25']; @@ -60,12 +60,12 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal .then(function (res) { if (res && res.data) { $scope.regionSelection = { - lcpRegion: (res.data[COMPONENT.CLOUD_REGION_ID]) ? res.data[COMPONENT.CLOUD_REGION_ID] : null, + optionId: (res.data[COMPONENT.CLOUD_REGION_ID]) ? res.data[COMPONENT.CLOUD_REGION_ID] : null, legacyRegion: null, tenant: (res.data[COMPONENT.TENANT_ID]) ? res.data[COMPONENT.TENANT_ID] : null }; - $scope.isHomingData = $scope.regionSelection.lcpRegion !== null && res.data.tenant !== null; - $scope.isHomingData = $scope.isHomingData && (($scope.megaRegion).indexOf($scope.regionSelection.lcpRegion) === -1); + $scope.isHomingData = $scope.regionSelection.optionId !== null && res.data.tenant !== null; + $scope.isHomingData = $scope.isHomingData && !$scope.selectedLcpRegionIsMegaRegion(); } if (!$scope.isHomingData) { @@ -75,11 +75,11 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal .catch(function (error) { getLcpCloudRegionTenantList(); }); - }; + } function getLcpRegionId() { if(_.isEmpty($scope.regionSelection.legacyRegion)) { - return $scope.regionSelection.lcpRegion + return DataService.getCloudOwnerAndLcpCloudRegionFromOptionId($scope.regionSelection.optionId).cloudRegionId; } return $scope.regionSelection.legacyRegion; } @@ -144,6 +144,12 @@ var vfModuleActionModalController = function(COMPONENT, FIELD, $scope, $uibModal return AaiService.removeVendorFromCloudOwner(cloudOwner) }; + $scope.selectedLcpRegionIsMegaRegion = function() { + let cloudRegionId = + DataService.getCloudOwnerAndLcpCloudRegionFromOptionId($scope.regionSelection.optionId).cloudRegionId; + return ($scope.megaRegion).indexOf(cloudRegionId) > -1 + }; + $scope.cancel = function() { $uibModalInstance.dismiss('cancel'); }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html index 3fbe07e83..944352403 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/vf-module-homing-data-action/vf-module-homing-data-action.html @@ -55,7 +55,7 @@ <div class="lcp-region field"> <label>LCP Region</label> <select name="lcp-region" required class="form-item wide" - data-tests-id="lcpRegion" data-ng-model="regionSelection.lcpRegion" + data-tests-id="lcpRegion" data-ng-model="regionSelection.optionId" data-ng-change="regionSelection.tenant = null; regionSelection.legacyRegion = null;"> <option class="lcp-region-placeholder" value="" selected>Select LCP Region</option> <option ng-repeat="option in lcpRegionList" value="{{option.cloudRegionOptionId}}" @@ -69,7 +69,7 @@ </select> </div> - <div class="legacy-region field" data-ng-if="(megaRegion).indexOf(regionSelection.lcpRegion) > -1"> + <div class="legacy-region field" data-ng-if="selectedLcpRegionIsMegaRegion()"> <label>Legacy Region</label> <input type="text" data-tests-id="lcpRegionText" required data-ng-model="regionSelection.legacyRegion" placeholder="Enter legacy region"> @@ -81,7 +81,7 @@ data-tests-id="tenant" data-ng-model="regionSelection.tenant"> <option class="tenant-placeholder" value="" selected>Select Tenant Name</option> <option ng-repeat="option in lcpAndTenant" class="tenantOption" value="{{option.tenantId}}" - data-ng-if="option.isPermitted && option.cloudRegionOptionId === regionSelection.lcpRegion">{{option.tenantName}} + data-ng-if="option.isPermitted && option.cloudRegionOptionId === regionSelection.optionId">{{option.tenantName}} </option> </select> </div> diff --git a/vid-webpack-master/cypress/integration/iFrames/softDeleteAndResume.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/softDeleteAndResume.e2e.ts index 02bc2728d..b83268ece 100644 --- a/vid-webpack-master/cypress/integration/iFrames/softDeleteAndResume.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/softDeleteAndResume.e2e.ts @@ -1,6 +1,5 @@ ///<reference path="../../../node_modules/cypress/types/index.d.ts"/> import {JsonBuilder} from '../../support/jsonBuilders/jsonBuilder'; -import {PnfModel} from '../../support/jsonBuilders/models/pnf.model'; import {ServiceModel} from '../../support/jsonBuilders/models/service.model'; import {AaiServiceInstancesModel} from '../../support/jsonBuilders/models/serviceInstances.model'; import {AAISubDetailsModel} from '../../support/jsonBuilders/models/aaiSubDetails.model'; @@ -76,7 +75,7 @@ describe('Soft delete tests', function () { it(`Resume button display in orch status - pendingactivation, assigned - feature FLAG_VF_MODULE_RESUME_STATUS_CREATE - is OFF`, function () { - cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/flags.json').then((res) => { + cy.readFile('/cypress/support/jsonBuilders/mocks/jsons/flags.json').then(() => { cy.server() .route({ method: 'GET', @@ -121,17 +120,17 @@ describe('Soft delete tests', function () { cy.visit('/serviceModels.htm#/instantiate?subscriberId=e433710f-9217-458d-a79d-1c7aff376d89&subscriberName=SILVIA%20ROBBINS&serviceType=TYLER%20SILVIA&serviceInstanceId=3f93c7cb-2fd0-4557-9514-e189b7b04f9d&aaiModelVersionId=6e59c5de-f052-46fa-aa7e-2fca9d674c44&isPermitted=true'); cy.wait('@service-complexService'); checkSoftDeleteAndDeletePopup('gg', 'vfModuleTreeNode-assigned', false, true); - cy.selectDropdownOptionByText('lcpRegion', 'AAIAIC25'); + cy.selectDropdownOptionByText('lcpRegion', 'AAIAIC25 (AIC)'); cy.getElementByDataTestsId('confirmResumeDeleteButton').should('have.attr', 'disabled'); cy.typeToInput("lcpRegionText", "just another region"); cy.getElementByDataTestsId('confirmResumeDeleteButton').should('have.attr', 'disabled'); cy.selectDropdownOptionByText('tenant', 'USP-SIP-IC-24335-T-01'); cy.getElementByDataTestsId('confirmResumeDeleteButton').should('not.have.attr', 'disabled'); - cy.selectDropdownOptionByText('lcpRegion', 'hvf6'); + cy.selectDropdownOptionByText('lcpRegion', 'hvf6 (AIC)'); cy.getElementByDataTestsId('confirmResumeDeleteButton').should('have.attr', 'disabled'); cy.selectDropdownOptionByText('tenant', 'AIN Web Tool-15-D-testalexandria'); cy.getElementByDataTestsId('confirmResumeDeleteButton').should('not.have.attr', 'disabled'); - cy.getElementByDataTestsId('cancel').click({force: true}) + cy.getElementByDataTestsId('cancel').click({force: true}); cy.getElementByDataTestsId('confirmResumeDeleteButton').should('not.be.visible'); }); @@ -190,10 +189,10 @@ describe('Soft delete tests', function () { }); function checkLegacyRegion() { - checkIsLegacyRegionTextIsDisplay('AAIAIC25', true); - checkIsLegacyRegionTextIsDisplay('olson3', false); - checkIsLegacyRegionTextIsDisplay('olson5a', false); - checkIsLegacyRegionTextIsDisplay('hvf6', false); + checkIsLegacyRegionTextIsDisplay('AAIAIC25 (AIC)', true); + checkIsLegacyRegionTextIsDisplay('olson3 (AIC)', false); + checkIsLegacyRegionTextIsDisplay('olson5a (AIC)', false); + checkIsLegacyRegionTextIsDisplay('hvf6 (AIC)', false); } function checkIsLegacyRegionTextIsDisplay(lcpRegionName: string, isVisible: boolean) { |