Fix for Penetration test _ Session and cookie management
[vid.git] / vid-automation / src / main / java / vid / automation / test / test / ALaCarteflowTest.java
1 package vid.automation.test.test;
2
3 import static org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset.DEFAULT_CLOUD_OWNER;
4 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.MDT_1;
5 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC;
6 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC;
7 import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.SOME_LEGACY_REGION;
8 import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;
9
10 import com.google.common.collect.ImmutableList;
11 import com.google.common.collect.ImmutableMap;
12 import java.util.List;
13 import java.util.stream.Collectors;
14 import org.junit.Assert;
15 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
16 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
17 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
18 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
19 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleOldViewEdit;
20 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteOldViewEdit;
21 import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVolumeGroupOldViewEdit;
22 import org.openqa.selenium.WebElement;
23 import org.testng.annotations.BeforeClass;
24 import org.testng.annotations.DataProvider;
25 import org.testng.annotations.Test;
26 import vid.automation.test.Constants;
27 import vid.automation.test.infra.Get;
28 import vid.automation.test.model.ServiceModel;
29 import vid.automation.test.model.User;
30 import vid.automation.test.sections.SideMenu;
31 import vid.automation.test.sections.VidBasePage;
32 import vid.automation.test.sections.ViewEditPage;
33 import vid.automation.test.services.ServicesService;
34 import vid.automation.test.services.SimulatorApi;
35
36
37 public class ALaCarteflowTest extends CreateInstanceDialogBaseTest {
38     static final String SUBSCRIBER = "Emanuel";
39     static final String SERVICE_NAME = "ggghhh";
40     static final String SERVICE_ID = "537d3eb0-b7ab-4fe8-a438-6166ab6af49b";
41     static final String VNF_ID = "0eb38f69-d96b-4d5e-b8c9-3736c292f0f7";
42     static final String DEFAULT_TEST_API_VALUE = "GR_API";
43     public static final String SERVICE_INSTANCE_ID = "SERVICE_INSTANCE_ID";
44     public static final String A_LACARTE_FLOW_GET_ORCHESTRATION = "aLacarteFlow/get_orchestration_request_status.json";
45     public static final String ORCHESTRATION_REQUEST_ID = "orchestrationRequestId";
46     public static final String STATUS_MESSAGE = "status_message";
47     public static final String REQUEST_TYPE = "REQUEST-TYPE";
48     public static final String CREATE = "Create";
49     public static final String AAIAIC_25 = "AAIAIC25";
50     public static final String AIC = "AIC";
51     public static final String TENANT = "092eb9e8e4b7412e8787dd091bc58e86";
52     public static final String FALSE = "false";
53     public static final String NODE_INSTANCE = "VSP1710PID298109_vWINIFRED 0";
54     public static final String MODEL = "959a7ba0-89ee-4984-9af6-65d5bdda4b0e";
55     private static final String CREATE_VNF_REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873dfbd";
56
57
58     @BeforeClass
59     protected void registerToSimulator() {
60         SimulatorApi.clearAll();
61         SimulatorApi.registerExpectation(APPEND,
62                 "ecompportal_getSessionSlotCheckInterval.json",
63                 "search_for_service_instance/aai_get_services.json"
64                 , "create_configuration/aai_get_tenants.json"
65                 , "sanity/get_aai_sub_details.json"
66                 , "aLacarteFlow/get_aai_search_named_query.json"
67                 , "aLacarteFlow/get_sdc_catalog_services_ggghhh.json"
68         );
69         SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND);
70     }
71
72
73     @Test(dataProvider = "msoTestApiOptions")
74     public void testAddVfModule(String msoTestApiOption, String msoTestApiValue) {
75         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
76             final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bddd";
77             final String MODEL_UUID = "d205e01d-e5da-4e68-8c52-f95cb0607959";
78
79             String vfModuleName = viewEditPage.generateInstanceName(Constants.ViewEdit.VF_MODULE_INSTANCE_NAME_PREFIX);
80
81             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
82                     PRESET_MDT1_TO_ATT_NC,
83                     new PresetMSOCreateVfModuleOldViewEdit(
84                             REQUEST_ID,
85                             BaseMSOPreset.DEFAULT_INSTANCE_ID,
86                             SERVICE_ID,
87                             VNF_ID,
88                             vfModuleName,
89                             msoTestApiValue,
90                             DEFAULT_CLOUD_OWNER)),
91                     SimulatorApi.RegistrationStrategy.APPEND);
92
93
94             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
95                     ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT,
96                             REQUEST_TYPE, CREATE), APPEND);
97             GeneralUIUtils.ultimateWait();
98             goToInstance();
99             ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
100             addVFModule("Vsp1710pid298109Vwinifred..mmsc_mod1_ltm..module-8", vfModuleName, AAIAIC_25, AIC,
101                     TENANT, FALSE, MDT_1, getCurrentUser().tenants, serviceInstance);
102
103         });
104     }
105
106     @Test
107     public void testTenant() throws Exception {
108         ViewEditPage viewEditPage = new ViewEditPage();
109         User user = usersService.getUser("Emanuel_with_tenant");
110         relogin(user.credentials);
111         goToInstance();
112         viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
113         viewEditPage.setInstanceName("New and fun instance");
114         viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
115         viewEditPage.selectLcpRegion("hvf6", AIC);
116         List<WebElement> tenantOptions = Get.byClass(Constants.ViewEdit.TENANT_OPTION_CLASS);
117         List<WebElement> enabledTenantOption = tenantOptions.stream().filter(webElement -> webElement.isEnabled()).collect(Collectors.toList());
118         Assert.assertTrue(enabledTenantOption.size() == 1);
119         Assert.assertTrue(enabledTenantOption.get(0).getText().equals("test-hvf6-09"));
120     }
121
122     @Test(dataProvider = "msoTestApiOptions")
123     public void testAddVnf(String msoTestApiOption, String msoTestApiValue) {
124         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
125             final String MODEL_UUID = MODEL;
126             String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
127             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
128                     PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
129                     new PresetMSOCreateVnfALaCarteOldViewEdit(
130                             CREATE_VNF_REQUEST_ID,
131                             SERVICE_ID,
132                             instanceName,
133                             true,
134                             msoTestApiValue)),
135                     SimulatorApi.RegistrationStrategy.APPEND);
136             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
137                     ImmutableMap.of(ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd", STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT,
138                             REQUEST_TYPE, CREATE), APPEND);
139             GeneralUIUtils.ultimateWait();
140             goToInstance();
141             ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
142             addVNF(NODE_INSTANCE, AAIAIC_25, AIC, TENANT,
143                     FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, "ONAP", serviceInstance, instanceName);
144         });
145     }
146
147     @Test(dataProvider = "msoTestApiOptions")
148     public void requiredLineOfBussiness_confirmVnfWithNoLob(String msoTestApiOption, String msoTestApiValue) throws Exception {
149         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
150             goToInstance();
151             String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
152             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
153                     PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
154                     new PresetMSOCreateVnfALaCarteOldViewEdit(
155                             CREATE_VNF_REQUEST_ID,
156                             SERVICE_ID,
157                             instanceName,
158                             false,
159                             msoTestApiValue)),
160                     SimulatorApi.RegistrationStrategy.APPEND);
161             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of(
162                     ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd",
163                     STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT,
164                     REQUEST_TYPE, CREATE
165             ), APPEND);
166             openAndFillVnfPopup(NODE_INSTANCE, AAIAIC_25, AIC, TENANT,
167                     FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, null, null, instanceName);
168             assertConfirmShowMissingDataErrorOnCurrentPopup(Constants.ViewEdit.LINE_OF_BUSINESS_TEXT);
169         });
170     }
171
172     @Test
173     public void emptyLobAfterReopenCreateVnfDialog() throws Exception {
174         final String lobToSelect = "ONAP";
175         goToInstance();
176         ViewEditPage viewEditPage = new ViewEditPage();
177         viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
178         GeneralUIUtils.ultimateWait();
179         viewEditPage.selectLineOfBusiness(lobToSelect);
180         viewEditPage.clickCancelButtonByTestID();
181         viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
182         GeneralUIUtils.ultimateWait();
183         viewEditPage.selectLineOfBusiness(lobToSelect);
184         viewEditPage.clickCancelButtonByTestID();
185     }
186
187     @Test(dataProvider = "msoTestApiOptions")
188     public void testAddVolumeGroup(String msoTestApiOption, String msoTestApiValue) throws Exception {
189         withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
190             final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bdaa";
191             final String MODEL_UUID = "13f022c4-651e-4326-b8e1-61e9a8c7a7ad";
192             String vgName = viewEditPage.generateInstanceName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX);
193             SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
194                     PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
195                     new PresetMSOCreateVolumeGroupOldViewEdit(
196                             REQUEST_ID,
197                             BaseMSOPreset.DEFAULT_INSTANCE_ID,
198                             SERVICE_ID,
199                             VNF_ID,
200                             vgName,
201                             msoTestApiValue)),
202                     SimulatorApi.RegistrationStrategy.APPEND);
203             SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
204                     ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VOLUME_GROUP_CREATED_SUCCESSFULLY_TEXT,
205                             REQUEST_TYPE, CREATE), SimulatorApi.RegistrationStrategy.APPEND);
206             GeneralUIUtils.ultimateWait();
207             goToInstance();
208             ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
209             addVolumeGroup("Vsp1710pid298109Vwinifred..mmsc_mod6_eca_oam..module-3", vgName, AAIAIC_25, AIC, TENANT,
210                     FALSE, SOME_LEGACY_REGION, getCurrentUser().tenants, serviceInstance);
211         });
212     }
213
214     private User getCurrentUser() {
215         return usersService.getUser(Constants.Users.EMANUEL_vWINIFRED);
216     }
217
218     private void goToInstance() {
219         SideMenu.navigateToSearchExistingPage();
220         goToExistingInstanceBySubscriber(SUBSCRIBER, SERVICE_NAME, SERVICE_ID);
221
222     }
223
224     @Override
225     protected UserCredentials getUserCredentials() {
226         User user = getCurrentUser();
227         return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_vWINIFRED, "", "");
228     }
229
230     @DataProvider
231     public static Object[][] msoTestApiOptions() {
232         return new Object[][]{
233                 {"GR_API (new)", DEFAULT_TEST_API_VALUE}
234                 , {"VNF_API (old)", "VNF_API"}
235         };
236     }
237
238     private void withMsoTestApiConfiguration(String msoTestApiOption, String msoTestApiValue, Runnable test) {
239         if (msoTestApiValue.equals(DEFAULT_TEST_API_VALUE)) {
240             test.run();
241         } else {
242             try {
243                 selectMsoTestApiOption(msoTestApiOption);
244                 test.run();
245             } finally {
246                 // back to default
247                 selectMsoTestApiOption("GR_API (new)");
248             }
249         }
250     }
251
252
253 }