Add negative integration test cases for helm package onboarding 82/118682/5
authorRemigiusz Janeczek <remigiusz.janeczek@nokia.com>
Tue, 2 Mar 2021 09:28:28 +0000 (10:28 +0100)
committerChristophe Closset <christophe.closset@intl.att.com>
Wed, 3 Mar 2021 08:25:30 +0000 (08:25 +0000)
Issue-ID: SDC-3185
Signed-off-by: Remigiusz Janeczek <remigiusz.janeczek@nokia.com>
Change-Id: I76d372b9556c31af77e8f770b996398aec0145df

integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/data/providers/OnboardingDataProviders.java
integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/sanity/Onboard.java
integration-tests/src/test/java/org/onap/sdc/backend/ci/tests/utils/general/OnboardingUtils.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/dataProvider/OnbordingDataProviders.java
integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/OnboardingFlowsUi.java
integration-tests/src/test/resources/Files/CNFs/invalid/helm-package-invalid-missing-flag-isbase.zip [new file with mode: 0644]
integration-tests/src/test/resources/ci/testSuites/frontend/onapUiSanity.xml

index a743521..88b1a66 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2019 Nordix Foundation
+ *  Copyright (C) 2021 Nokia. 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.
@@ -76,6 +77,13 @@ public final class OnboardingDataProviders {
         return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF));
     }
 
+    @DataProvider(name = "Invalid_CNF_List", parallel = true)
+    private static Object[][] invalidCnfList() {
+        final List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(XnfTypeEnum.CNF);
+        LOGGER.debug(String.format("There are %s package file(s) to test", fileNamesFromFolder.size()));
+        return provideData(fileNamesFromFolder, FileHandling.getXnfRepositoryPath(XnfTypeEnum.CNF));
+    }
+
     @DataProvider(name = "Single_VNF", parallel = true)
     private static Object[][] singleVNF() {
         final List<String> fileNamesFromFolder = OnboardingUtils.getXnfNamesFileList(XnfTypeEnum.VNF);
index a16fa3e..d67390e 100644 (file)
@@ -3,6 +3,7 @@
  * SDC
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 Nokia. 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.
@@ -21,6 +22,8 @@
 package org.onap.sdc.backend.ci.tests.sanity;
 
 
+import static org.testng.Assert.assertThrows;
+
 import com.aventstack.extentreports.Status;
 import fj.data.Either;
 import org.junit.Rule;
@@ -84,6 +87,12 @@ public class Onboard extends ComponentBaseTest {
                runOnboardToDistributionFlow(filePath, cnfFile, ResourceTypeEnum.VF);
        }
 
+       @Test(dataProviderClass = OnboardingDataProviders.class, dataProvider = "Invalid_CNF_List")
+       public void onboardCNFFlowShouldFailForInvalidHelmPackage(String filePath, String cnfFile) {
+               setLog(cnfFile);
+               assertThrows(() -> runOnboardToDistributionFlow(filePath, cnfFile, ResourceTypeEnum.VF));
+       }
+
        private void runOnboardToDistributionFlow(String packageFilePath, String packageFileName, ResourceTypeEnum resourceTypeEnum) throws Exception {
                ExtentTestActions.log(Status.INFO, String.format("Going to onboard the %s %s", resourceTypeEnum.getValue(), packageFileName));
                User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
index 1357dc4..ad620ef 100644 (file)
@@ -3,6 +3,7 @@
  * SDC
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 Nokia. 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.
@@ -20,6 +21,7 @@
 
 package org.onap.sdc.backend.ci.tests.utils.general;
 
+import java.io.File;
 import org.onap.sdc.backend.ci.tests.datatypes.enums.XnfTypeEnum;
 import org.onap.sdc.backend.ci.tests.datatypes.http.HttpHeaderEnum;
 import org.onap.sdc.backend.ci.tests.datatypes.http.HttpRequest;
@@ -104,7 +106,9 @@ public class OnboardingUtils {
                "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip",
                "1-2017389vtsbc4vf-(VOIP)_v11.0.zip"
        );
-       
+
+       private static final String INVALID_XNFS_SUBPATH = "invalid";
+
        public static String handleFilename(String heatFileName) {
                final String namePrefix = String.format("%sVF%s", ElementFactory.getResourcePrefix(), "Onboarded-");
                final String nameSuffix = "-" + getShortUUID();
@@ -123,7 +127,7 @@ public class OnboardingUtils {
                String vnfName = namePrefix + subHeatFileName + nameSuffix;
                return vnfName;
        }
-       
+
 
        public static String getShortUUID() {
                return UUID.randomUUID().toString().split("-")[0];
@@ -189,6 +193,15 @@ public class OnboardingUtils {
                return fileNamesFromFolder;
        }
 
+       /**
+        * @return
+        * The method returns names list of invalid XNF packages from Files directory under sdc repository
+        */
+       public static List<String> getInvalidXnfNamesFileList(XnfTypeEnum xnfTypeEnum) {
+               String filepath = FileHandling.getXnfRepositoryPath(xnfTypeEnum) + File.separator + INVALID_XNFS_SUBPATH;
+               return FileHandling.getZipFileNamesFromFolder(filepath);
+       }
+
        /**
         * @param vnfNamesFileList
         * @return divide List according to day of month, if day of month is even as get first half part of the List, else - second
@@ -238,4 +251,3 @@ public class OnboardingUtils {
        }
 }
 
-       
\ No newline at end of file
index d8dc5f9..3a9fd4d 100644 (file)
@@ -3,6 +3,7 @@
  * SDC
  * ================================================================================
  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 Nokia. 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.
@@ -65,6 +66,15 @@ public class OnbordingDataProviders {
         return provideData(fileNamesFromFolder, FileHandling.getCnfRepositoryPath());
     }
 
+    @DataProvider(name = "Invalid_CNF_List", parallel = true)
+    private static Object[][] invalidCnfList() {
+
+        List<String> fileNamesFromFolder = OnboardingUtils.getInvalidXnfNamesFileList(XnfTypeEnum.CNF);
+
+        System.out.println(String.format("There are %s zip file(s) to test", fileNamesFromFolder.size()));
+        return provideData(fileNamesFromFolder, FileHandling.getCnfRepositoryPath());
+    }
+
     @DataProvider(name = "updateList")
     private static Object[][] updateList() throws Exception {
 
index 9327d6c..73c6d7c 100644 (file)
@@ -3,6 +3,7 @@
  * SDC
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 Nokia. 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.
@@ -72,6 +73,7 @@ import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.WebElement;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.testng.Assert;
 import org.testng.AssertJUnit;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Optional;
@@ -473,6 +475,14 @@ public class OnboardingFlowsUi extends SetupCDTest {
         runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, cnfFile);
     }
 
+    @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "Invalid_CNF_List")
+    public void onboardCNFTestShouldFailForInvalidHelmPackage(String filePath, String cnfFile) {
+        setLog(cnfFile);
+        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
+        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
+        Assert.assertThrows(() -> runOnboardToDistributionFlow(resourceReqDetails, serviceReqDetails, filePath, cnfFile));
+    }
+
     @Test(dataProviderClass = OnbordingDataProviders.class, dataProvider = "VNF_List")
     public void onboardVNFShotFlow(String filePath, String vnfFile) throws Exception {
         setLog(vnfFile);
diff --git a/integration-tests/src/test/resources/Files/CNFs/invalid/helm-package-invalid-missing-flag-isbase.zip b/integration-tests/src/test/resources/Files/CNFs/invalid/helm-package-invalid-missing-flag-isbase.zip
new file mode 100644 (file)
index 0000000..45a69e8
Binary files /dev/null and b/integration-tests/src/test/resources/Files/CNFs/invalid/helm-package-invalid-missing-flag-isbase.zip differ
index c53dd4a..db352d3 100644 (file)
@@ -20,6 +20,7 @@
         <methods>
           <include name="onapOnboardVNFflow"/>
           <include name="onboardCNFTest"/>
+          <include name="onboardCNFTestShouldFailForInvalidHelmPackage"/>
           <include name="onapOnboardVSPValidationsSanityFlow"/>
           <include name="onboardPNFSoftwareInformationFlow"/>
         </methods>