--- /dev/null
+Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
+
+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.
\ No newline at end of file
+++ /dev/null
-/*
- * ============LICENSE_START==========================================
- * ===================================================================
- * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
- * ===================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- *
- *
- */
-
-For the file /epsdk-app-onap/src/main/webapp/app/fusion/external/ebz/angular_js/angular-sanitize.js,
-to the extent that it contains code originating from Erik Arvidsson, that code is used under the Apache-2.0 license,
-as permitted by http://erik.eae.net/simplehtmlparser/simplehtmlparser.js.
\ No newline at end of file
--- /dev/null
+package org.onap.vid.properties
+
+import org.apache.commons.io.filefilter.WildcardFileFilter
+import org.springframework.web.context.request.RequestContextHolder.getRequestAttributes
+import org.springframework.web.context.request.ServletRequestAttributes
+import org.togglz.core.Feature
+import org.togglz.core.manager.FeatureManager
+import org.togglz.core.manager.FeatureManagerBuilder
+import org.togglz.core.repository.file.FileBasedStateRepository
+import java.io.File
+import java.io.FilenameFilter
+import javax.servlet.ServletContext
+import javax.servlet.http.HttpServletRequest
+
+
+private const val SLOW_RELOAD = 60_000
+private const val COOKIE_NAME = "features.set"
+
+class FeatureSetsManager(
+ private val defaultManager: FeatureManager,
+ private val nameProvider: AlternativeFeatureSetNameProvider,
+ private val servletContext: ServletContext
+) : FeatureManager by defaultManager {
+
+ override fun isActive(feature: Feature?): Boolean {
+ return resolvedFeatureManager().isActive(feature)
+ }
+
+ private fun resolvedFeatureManager(): FeatureManager {
+ return when (val alternativeFeatureSetName = nameProvider.alternativeFeatureSetName) {
+ null -> defaultManager
+ else -> allFeatureManagers.getValue(alternativeFeatureSetName)
+ }
+ }
+
+ internal val allFeatureManagers: Map<String, FeatureManager> by lazy {
+ allFeatureSetFiles().associateBy(
+ { it.name },
+ { newFeatureManager(it) }
+ ).withDefault { allFeaturesOff }
+ }
+
+ private val allFeaturesOff =
+ FeatureManagerBuilder().featureEnum(Features::class.java).build()
+
+ private fun newFeatureManager(file: File): FeatureManager {
+ return FeatureManagerBuilder()
+ .featureEnum(Features::class.java)
+ .stateRepository(FileBasedStateRepository(file, SLOW_RELOAD))
+ .build()
+ }
+
+ private fun allFeatureSetFiles(): Array<File> {
+ val dir = File(servletContext.getRealPath("/WEB-INF/conf/"))
+ val fileFilter: FilenameFilter = WildcardFileFilter("*.features.properties")
+
+ return dir.listFiles(fileFilter) ?: emptyArray()
+ }
+}
+
+interface AlternativeFeatureSetNameProvider {
+ val alternativeFeatureSetName: String?
+}
+
+class AlternativeFeatureSetNameFromCookie: AlternativeFeatureSetNameProvider {
+ override val alternativeFeatureSetName: String?
+ get() = valueFromCookie(currentHttpRequest())
+
+ internal fun valueFromCookie(httpServletRequest: HttpServletRequest?): String? {
+ return httpServletRequest
+ ?.cookies
+ ?.firstOrNull { it.name == COOKIE_NAME }
+ ?.value
+ }
+
+ internal fun currentHttpRequest(): HttpServletRequest? {
+ return when (val requestAttributes = getRequestAttributes()) {
+ is ServletRequestAttributes -> requestAttributes.request
+ else -> null
+ }
+ }
+}
FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND,
FLAG_2004_INSTANTIATION_STATUS_FILTER,
FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE,
- FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER,
FLAG_2004_INSTANTIATION_TEMPLATES_POPUP,
FLAG_2002_UNLIMITED_MAX,
+
;
package org.onap.vid.properties;
+import java.io.File;
+import javax.servlet.ServletContext;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.togglz.core.repository.file.FileBasedStateRepository;
import org.togglz.spring.listener.TogglzApplicationContextBinderApplicationListener;
-import javax.servlet.ServletContext;
-import java.io.File;
-
@Configuration
public class FeaturesTogglingConfiguration {
@Bean
filename = StringUtils.trimToNull(filename);
- return new FeatureManagerBuilder()
+ return new FeatureSetsManager(
+ new FeatureManagerBuilder()
.featureEnum(Features.class)
.stateRepository(new FileBasedStateRepository(
- new File(filename.startsWith("/")? filename : servletContext.getRealPath("/WEB-INF/conf/" + filename))
+ new File(filename.startsWith("/") ? filename : servletContext.getRealPath("/WEB-INF/conf/" + filename))
))
- .build();
+ .build(), new AlternativeFeatureSetNameFromCookie(), servletContext
+ );
}
}
if (!$scope.shouldShowOldPopup()) {
+ let modelNameVersionId = request.modelNameVersionId ?
+ request.modelNameVersionId :
+ (DataService.getModelInfo(COMPONENT.SERVICE) ? DataService.getModelInfo(COMPONENT.SERVICE).modelNameVersionId : "");
if(DataService.getIsInstantiationTemplateExists()){
- $scope.url = COMPONENT.INSTANTIATION_TEMPLATES_IFRAME_URL + request.modelNameVersionId;
+ $scope.url = COMPONENT.INSTANTIATION_TEMPLATES_IFRAME_URL + modelNameVersionId;
window.addEventListener("message", receiveMessage, false);
}else {
- $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + request.modelNameVersionId + "&isCreate=true&r=" + Math.random();
+ $scope.url = COMPONENT.SERVICE_POPUP_IFRAME_URL + modelNameVersionId + "&isCreate=true&r=" + Math.random();
window.addEventListener("message", receiveMessage, false);
}
}
--- /dev/null
+package org.onap.vid.properties
+
+import org.hamcrest.CoreMatchers.*
+import org.hamcrest.MatcherAssert.assertThat
+import org.mockito.ArgumentMatchers.anyString
+import org.mockito.InjectMocks
+import org.mockito.Mock
+import org.mockito.Mockito.*
+import org.onap.vid.testUtils.TestUtils
+import org.springframework.web.context.request.RequestContextHolder
+import org.testng.annotations.BeforeMethod
+import org.testng.annotations.Test
+import org.togglz.core.manager.FeatureManager
+import javax.servlet.ServletContext
+import javax.servlet.http.Cookie
+import javax.servlet.http.HttpServletRequest
+import org.hamcrest.CoreMatchers.`is` as _is
+import org.mockito.Mockito.`when` as _when
+
+class FeatureSetsManagerTest {
+ @Mock
+ lateinit var defaultFeatureManager: FeatureManager
+ @Mock
+ lateinit var servletContext: ServletContext
+ @Mock
+ lateinit var alternativeFeatureSetNameProvider: AlternativeFeatureSetNameProvider
+ @InjectMocks
+ lateinit var featureSetsManager: FeatureSetsManager
+
+ private val alternativeFeatureSetNameFromCookie = AlternativeFeatureSetNameFromCookie()
+
+ @BeforeMethod
+ fun setUp() {
+ TestUtils.initMockitoMocks(this)
+ }
+
+ @Test
+ fun `isActive - without alternative features set name - delegates to default and no file loaded`() {
+ _when(defaultFeatureManager.isActive(Features.FLAG_1810_AAI_LOCAL_CACHE)).thenReturn(true)
+ _when(alternativeFeatureSetNameProvider.alternativeFeatureSetName).thenReturn(null)
+
+ assertThat(featureSetsManager.isActive(Features.FLAG_1810_AAI_LOCAL_CACHE), _is(true))
+
+ verifyZeroInteractions(servletContext) // implies no other file loaded
+ verify(defaultFeatureManager, times(1)).isActive(Features.FLAG_1810_AAI_LOCAL_CACHE)
+ }
+
+ @Test
+ fun `isActive - with alternative features set - brings flags from alternative`() {
+ _when(servletContext.getRealPath(anyString())).thenReturn(this.javaClass.getResource("/").path)
+ _when(alternativeFeatureSetNameProvider.alternativeFeatureSetName).thenReturn("example.features.properties")
+
+ assertThat(featureSetsManager.isActive(Features.FLAG_1810_AAI_LOCAL_CACHE), _is(true))
+ assertThat(featureSetsManager.isActive(Features.FLAG_1902_NEW_VIEW_EDIT), _is(false))
+ verifyZeroInteractions(defaultFeatureManager)
+ }
+
+ @Test
+ fun `isActive - with non-existing alternative features set - fallback is to all flags off`() {
+ _when(servletContext.getRealPath(anyString())).thenReturn(this.javaClass.getResource("/").path)
+ _when(alternativeFeatureSetNameProvider.alternativeFeatureSetName).thenReturn("non-existing")
+
+ assertThat(featureSetsManager, not(nullValue()))
+ assertThat(
+ featureSetsManager.features.map { featureSetsManager.isActive(it) },
+ not(hasItem(true))
+ )
+ }
+
+ @Test
+ fun `valueFromCookie - given no request - return null`() {
+ assertThat(alternativeFeatureSetNameFromCookie.valueFromCookie(null), _is(nullValue()))
+ }
+
+ @Test
+ fun `valueFromCookie - given request - return the correct cookie value`() {
+ val servletRequestMock = mock(HttpServletRequest::class.java)
+ _when(servletRequestMock.cookies).thenReturn(arrayOf(Cookie("features.set", "value")))
+
+ assertThat(alternativeFeatureSetNameFromCookie.valueFromCookie(servletRequestMock), _is("value"))
+ }
+
+ @Test
+ fun `valueFromCookie - given request without cookies - return null`() {
+ val servletRequestMock = mock(HttpServletRequest::class.java)
+ _when(servletRequestMock.cookies).thenReturn(emptyArray())
+
+ assertThat(alternativeFeatureSetNameFromCookie.valueFromCookie(servletRequestMock), _is(nullValue()))
+ }
+
+ @Test
+ fun `currentHttpRequest - when no current request - return null`() {
+ assertPrecondition()
+ assertThat(alternativeFeatureSetNameFromCookie.currentHttpRequest(), _is(nullValue()))
+ }
+
+ private fun assertPrecondition() {
+ assertThat("precondition for test not met: static RequestContextHolder.getRequestAttributes should be null",
+ RequestContextHolder.getRequestAttributes(), _is(nullValue()))
+ }
+}
--- /dev/null
+FLAG_1810_AAI_LOCAL_CACHE=true
\ No newline at end of file
FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS,
FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND,
FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE,
- FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER,
FLAG_2002_UNLIMITED_MAX,
;
GeneralUIUtils.clickOnElementByTestId(Constants.OwningEntity.PROJECT_SELECT_TEST_ID);
}
- public void clickPreviousInstantiationButton() {
- GeneralUIUtils.clickOnElementByTestIdWithoutWait("ShowPreviousInstancesButton");
- }
-
}
import static vid.automation.test.infra.Features.FLAG_1908_COLLECTION_RESOURCE_NEW_INSTANTIATION_UI;
import static vid.automation.test.infra.Features.FLAG_2002_ANY_ALACARTE_BESIDES_EXCLUDED_NEW_INSTANTIATION_UI;
import static vid.automation.test.infra.Features.FLAG_2002_IDENTIFY_INVARIANT_MACRO_UUID_BY_BACKEND;
-import static vid.automation.test.infra.Features.FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER;
import static vid.automation.test.infra.Features.FLAG_5G_IN_NEW_INSTANTIATION_UI;
import static vid.automation.test.infra.Features.FLAG_NETWORK_TO_ASYNC_INSTANTIATION;
import static vid.automation.test.infra.Features.FLAG_SHOW_ORCHESTRATION_TYPE;
return deployMacroDialog;
}
- @Test
- @FeatureTogglingTest(FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER)
- public void testClickPreviousInstantiationsInCreationDialog() {
- try {
- String serviceId = "2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd";
- DeployModernUIMacroDialog deployMacroDialog = getDeployModernUIMacroDialog(serviceId);
- deployMacroDialog.clickPreviousInstantiationButton();
-
- //exit form deploy dialog
- goOutFromIframe();
- //go into Instantiation Status page
- goToIframe();
-
- InstantiationStatusPage.verifyInstantiationStatusFilterValue(serviceId);
- }
- finally {
- goOutFromIframe();
- }
- }
-
private BrowseASDCPage registerSimulatorAndGoToBrowseSDC() {
SimulatorApi.registerExpectation(SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET,
"ecompportal_getSessionSlotCheckInterval.json",
});
});
+ it(`browse sdc open create new service instance flow`, function () {
+ const MACRO_FOR_NEW_FLOW_ID: string = '745d1bf1-9ed1-413f-8111-f1e984ad63fb';
+
+ cy.initGetAAISubDetails();
+
+ cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiGetModelsByServiceType.json').then((res) => {
+ jsonBuilderAndMock.basicJson(res,
+ Cypress.config('baseUrl') + '/aai_get_models_by_service_type/**',
+ 200,
+ 0,
+ 'aaiGetModelByServiceType');
+ });
+
+ cy.readFile('cypress/support/jsonBuilders/mocks/jsons/bug616888/Dror_service1806_Macro1.json').then((res) => {
+ jsonBuilderAndMock.basicJson(res,
+ Cypress.config('baseUrl') + '/rest/models/services/' + MACRO_FOR_NEW_FLOW_ID,
+ 200,
+ 0,
+ 'MACRO_FOR_NEW_FLOW');
+ });
+
+ cy.get('span').contains('Create New Service Instance').click({force: true})
+ .selectDropdownOptionByText('subscriberName', 'SILVIA ROBBINS');
+ cy.get('button').contains('Submit').click({force: true});
+ cy.selectDropdownOptionByText('serviceType', 'TYLER SILVIA');
+ cy.get('button').contains('Submit').click({force: true});
+ cy.wait("@aaiGetModelByServiceType").then(() => {
+ cy.getElementByDataTestsId('deploy-' + MACRO_FOR_NEW_FLOW_ID).click({force: true});
+ cy.get('button').contains('Deploy').eq(0).click({force: true});
+ cy.get('iframe').then(function ($iframe) {
+ expect($iframe.attr('src')).to.contain(`app/ui/#/servicePopup?serviceModelId=74fa72dd-012b-49c3-800d-06b12bcaf1a0`);
+ });
+ });
+
+ cy.visit("welcome.htm"); //relaod page to not break the following tests
+
+ });
+
+
it(`browse sdc of service without instantiationType open aLaCarte popup`, function () {
const VERY_OLD_SERVICE_UUID: string = "09c476c7-91ae-44b8-a731-04d8d8fa3695";
const TEST_MOCKS_PATH = "cypress/support/jsonBuilders/mocks/jsons/bug_aLaCarteServiceWrongPopup/";
});
});
- it('when open service popup should show showPrevious button', () => {
- cy.openPopupIframe('/app/ui/#/servicePopup?serviceModelId=2f80c596-27e5-4ca9-b5bb-e03a7fd4c0fd&isCreate=true');
- cy.getElementByDataTestsId('ShowPreviousInstancesButton').contains('Previous Instantiation').click();
-
- })
-
-
});
});
initActiveVPNs : typeof initActiveVPNs;
initGetAAISubDetails : typeof initGetAAISubDetails;
initAAIServices: typeof initAAIServices;
+ initGetModelByServiceType: typeof initGetModelByServiceType;
}
}
});
}
+function initGetModelByServiceType(response? : JSON) : void {
+ cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubDetails.json').then((res) => {
+ cy.server()
+ .route({
+ method: 'GET',
+ status: 200,
+ url: Cypress.config('baseUrl') + "/aai_get_models_by_service_type/**",
+ response: response ? response : res
+ }).as('aai-sub-details')
+ });
+}
+
+
function initAlaCarteService(response? : JSON) : void {
cy.readFile('cypress/support/jsonBuilders/mocks/jsons/a-la-carteService.json').then((res) => {
cy.server()
Cypress.Commands.add('initActiveNetworks', initActiveNetworks);
Cypress.Commands.add('initActiveVPNs', initActiveVPNs);
Cypress.Commands.add('initAAIServices', initAAIServices);
+Cypress.Commands.add('initGetModelByServiceType', initGetModelByServiceType);
--- /dev/null
+{
+ "inventory-response-item": [
+ {
+ "service-subscription": {
+ "service-type": "TYLER SILVIA",
+ "resource-version": "1494001841964"
+ },
+ "extra-properties": {},
+ "inventory-response-items": {
+ "inventory-response-item":[
+ {
+ "model-name": "RG_11-18_vccf_srvc",
+ "service-instance": {
+ "service-instance-id": "b9769e8f-70aa-4b05-8988-64044aa63498",
+ "service-instance-name": "TestCharlie",
+ "model-invariant-id": "4af418a9-c2f5-4fae-a577-b69d6341eee8",
+ "model-version-id": "745d1bf1-9ed1-413f-8111-f1e984ad63fb",
+ "resource-version": "1494002070115"
+ },
+ "extra-properties": {
+ "extra-property": [
+ {
+ "property-name": "model-ver.model-description",
+ "property-value": "Service for vccf"
+ },
+ {
+ "property-name": "model-ver.model-version-id",
+ "property-value": "745d1bf1-9ed1-413f-8111-f1e984ad63fb"
+ },
+ {
+ "property-name": "model-ver.model-name",
+ "property-value": "RG_11-18_vccf_srvc"
+ },
+ {
+ "property-name": "model.model-type",
+ "property-value": "service"
+ },
+ {
+ "property-name": "model.model-invariant-id",
+ "property-value": "4af418a9-c2f5-4fae-a577-b69d6341eee8"
+ },
+ {
+ "property-name": "model.model-description"
+ },
+ {
+ "property-name": "model-ver.model-version",
+ "property-value": "1.0"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
+
+
"FLAG_1911_INSTANTIATION_ORDER_BUTTON_IN_ASYNC_ALACARTE": false,
"FLAG_2002_VNF_PLATFORM_MULTI_SELECT" : true,
"FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS": true,
- "FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER": true,
"FLAG_2004_INSTANTIATION_STATUS_FILTER": true,
"FLAG_2004_INSTANTIATION_TEMPLATES_POPUP" : false,
"FLAG_2002_UNLIMITED_MAX" : true,
type="button" class="btn btn-success submit"
(click)="openTemplateModal()"
><span>Template</span></button>
- <button
- *ngIf="isShowPreviousInstantiationBtn"
- [attr.data-tests-id]="'ShowPreviousInstancesButton'"
- type="button" class="btn btn-success submit"
- (click)="formPopupDetails.onOtherAction(formPopupDetails.that, dynamicForm)"
- ><span>Previous Instantiation</span></button>
<button
[attr.data-tests-id]="'cancelButton'"
type="button" class="btn btn-default cancel"
type: PopupType;
uuidData: UUIDData;
showTemplateBtn: boolean = false;
- isShowPreviousInstantiationBtn: boolean = false;
isUpdateMode: boolean;
node: ITreeNode = null;
hasGeneralApiError: boolean = false;
};
this.showTemplateBtn = this._genericFormPopupService.shouldShowTemplateBtn(isInstantiationTemplateExists);
- this.isShowPreviousInstantiationBtn = !!this._store.getState().global.flags["FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER"];
this.uuidData.popupService.closeDialogEvent.subscribe((that) => {
this.closeDialog(that);
FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS ='FLAG_2002_VFM_UPGRADE_ADDITIONAL_OPTIONS',
FLAG_2004_INSTANTIATION_STATUS_FILTER ='FLAG_2004_INSTANTIATION_STATUS_FILTER',
FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE = 'FLAG_2004_CREATE_ANOTHER_INSTANCE_FROM_TEMPLATE',
- FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER ='FLAG_2004_TEMP_BUTTON_TO_INSTANTIATION_STATUS_FILTER',
FLAG_2004_INSTANTIATION_TEMPLATES_POPUP = 'FLAG_2004_INSTANTIATION_TEMPLATES_POPUP'
}