aboutsummaryrefslogtreecommitdiffstats
path: root/test-apis-ci
diff options
context:
space:
mode:
authorYuli Shlosberg <ys9693@att.com>2018-04-08 14:03:29 +0300
committerMichael Lando <ml636r@att.com>2018-04-09 18:03:21 +0000
commit1788983cf083303c51d538608c92abbebef10307 (patch)
treea70997752b5448dc45739309c53df2ef49f5f59f /test-apis-ci
parent0ebace5621e54b8102b0371f0500340adedf7f75 (diff)
fix use of user credentials logic
Change-Id: If518234e78983fe35ceb4b971d5093052ee824bb Issue-ID: SDC-384 Signed-off-by: Yuli Shlosberg <ys9693@att.com>
Diffstat (limited to 'test-apis-ci')
-rw-r--r--test-apis-ci/sdc-api-tests/Dockerfile2
-rw-r--r--test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/files/default/conf/credentials.yaml42
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java67
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java56
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java69
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java2
-rw-r--r--test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java12
-rw-r--r--test-apis-ci/src/main/resources/ci/conf/credentials.yaml48
9 files changed, 204 insertions, 96 deletions
diff --git a/test-apis-ci/sdc-api-tests/Dockerfile b/test-apis-ci/sdc-api-tests/Dockerfile
index 2be415080e..d419224251 100644
--- a/test-apis-ci/sdc-api-tests/Dockerfile
+++ b/test-apis-ci/sdc-api-tests/Dockerfile
@@ -1,4 +1,4 @@
-FROM onap/base_sdc-sanity:1.2.0-SNAPSHOT-latest
+FROM onap/base_sdc-sanity:1.3.0-SNAPSHOT-latest
COPY chef-solo /root/chef-solo/
diff --git a/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/files/default/conf/credentials.yaml b/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/files/default/conf/credentials.yaml
index ab37f7bee8..05f9a71c5c 100644
--- a/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/files/default/conf/credentials.yaml
+++ b/test-apis-ci/sdc-api-tests/chef-repo/cookbooks/sdc-api-tests/files/default/conf/credentials.yaml
@@ -1,48 +1,48 @@
designer: {
username: cs0008,
password: 123123a,
- firstname: ASDC,
- lastname: KASPIN
+ firstname: SDC,
+ lastname: SDC2
}
admin: {
username: jh0003,
password: 123123a,
- firstname: ASDC,
- lastname: KASPIN
+ firstname: SDC,
+ lastname: SDC2
}
ops: {
- username: af0006,
+ username: op0001,
password: 123123a,
- firstname: ASDC,
- lastname: KASPIN
+ firstname: SDC,
+ lastname: SDC2
}
tester: {
- username: kb0004,
+ username: jm0007,
password: 123123a,
- firstname: ASDC,
- lastname: KASPIN
+ firstname: SDC,
+ lastname: SDC2
}
governor: {
- username: ah0002,
+ username: gv0001,
password: 123123a,
- firstname: ASDC,
- lastname: KASPIN
+ firstname: SDC,
+ lastname: SDC2
}
product_strategist: {
username: m99126,
- password: 1910-FruitGum,
- firstname: ASDC,
- lastname: KASPIN
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
}
product_manager: {
username: m99127,
- password: 747-Airplane,
- firstname: ASDC,
- lastname: KASPIN
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
}
product_local: {
username: pm0001,
password: 123123a,
- firstname: ASDC,
- lastname: KASPIN
+ firstname: SDC,
+ lastname: SDC2
} \ No newline at end of file
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java
new file mode 100644
index 0000000000..64f1a72034
--- /dev/null
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/MainToTest.java
@@ -0,0 +1,67 @@
+package org.openecomp.sdc.ci.tests.config;
+
+
+import fj.data.Either;
+import org.apache.commons.io.IOUtils;
+import org.json.JSONObject;
+import org.openecomp.sdc.be.model.Service;
+import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
+import org.openecomp.sdc.ci.tests.datatypes.http.RestResponse;
+import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
+import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.*;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+public class MainToTest {
+
+ private static final String CREDENTIALS_FILE = "credentials.yaml";
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("Hello World!"); // Display the string.
+ System.out.println("user.dir: " + System.getProperty("user.dir"));
+ System.out.println(UserRoleEnum.DESIGNER.getFirstName());
+ String file = readFile();
+ convertToJson(file);
+ Either<Service, RestResponse> createDefaultService1e = AtomicOperationUtils.createDefaultService(UserRoleEnum.DESIGNER, true);
+
+
+
+ }
+
+ private static String convertToJson(String yamlString) {
+ Yaml yaml = new Yaml();
+ Map<String, Object> map = (Map<String, Object>) yaml.load(yamlString);
+
+ JSONObject jsonObject = new JSONObject(map);
+ return jsonObject.toString();
+ }
+
+ private static String readFile() {
+
+ File credentialsFileLocal = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf"
+ + File.separator + CREDENTIALS_FILE);
+
+ InputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(credentialsFileLocal);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ String mystr = IOUtils.toString(inputStream, Charset.forName("UTF-8"));
+ inputStream.close();
+ return mystr;
+ } catch(IOException e) {
+ }
+ }
+
+ return null;
+ }
+
+
+}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java
index 42f06f2bd3..c6e684c020 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/config/UserCredentialsFromFile.java
@@ -5,55 +5,34 @@ import org.openecomp.sdc.ci.tests.utils.general.FileHandling;
import org.yaml.snakeyaml.Yaml;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Paths;
+import java.util.HashMap;
import java.util.Map;
public class UserCredentialsFromFile {
private static final String CREDENTIALS_FILE = "credentials.yaml";
- private static Map<?, ?> credentials;
+ private static Map<String, UserCredentials> credentials;
private static Yaml yaml = new Yaml();
- private static UserCredentialsFromFile credentialsFromFile;
-// private UserCredentialsFromFile() {
-//
-// }
+ private static final UserCredentialsFromFile instance = new UserCredentialsFromFile();
- public synchronized static UserCredentialsFromFile getInstance() {
- if (credentialsFromFile == null) {
- try {
- credentialsFromFile = new UserCredentialsFromFile();
- } catch (Exception e) {
- e.printStackTrace();
- return null;
- }
- }
- return credentialsFromFile;
+ public static UserCredentialsFromFile getInstance(){
+ return instance;
}
- private void UserCredentialsFromFile() throws IOException {
+ private UserCredentialsFromFile() {
credentials = null;
File credentialsFileRemote = new File(FileHandling.getBasePath() + File.separator + "conf" + File.separator + CREDENTIALS_FILE);
// File credentialsFileLocal = new File(FileHandling.getConfFilesPath() + CREDENTIALS_FILE);
- File credentialFile = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf"
+ File credentialsFileLocal = new File(FileHandling.getSdcVnfsPath() + File.separator + "conf"
+ File.separator + CREDENTIALS_FILE);
-
- if (false == credentialFile.exists()) {
- throw new RuntimeException("The config file " + credentialFile + " cannot be found.");
- }
-
-
- File[] credentialFiles = {credentialsFileRemote, credentialFile};
-
+ File[] credentialFiles = {credentialsFileRemote, credentialsFileLocal};
for (File credentialsFile : credentialFiles){
if (credentialsFile.exists()){
try {
- credentials = FileHandling.parseYamlFile(credentialsFile.getAbsolutePath());
+ credentials = (Map<String, UserCredentials>) FileHandling.parseYamlFile(credentialsFile.getAbsolutePath());
} catch (Exception e) {
e.printStackTrace();
}
@@ -62,19 +41,16 @@ public class UserCredentialsFromFile {
}
-
}
-
- public static UserCredentials getUserCredentialsByRole(String userRole) throws Exception {
- @SuppressWarnings("unchecked")
+ public UserCredentials getUserCredentialsByRole(String userRole) {
Map<String, String> credentialsMap = (Map<String, String>) credentials.get(userRole);
- String user = (String) credentialsMap.get("username");
- String password = (String) credentialsMap.get("password");
- String firstname = (String) credentialsMap.get("firstname");
- String lastname = (String) credentialsMap.get("lastname");
-
- return new UserCredentials(user, password, firstname, lastname, userRole);
+ UserCredentials userCredentials = new UserCredentials();
+ userCredentials.setUserId(credentialsMap.get("username"));
+ userCredentials.setFirstName(credentialsMap.get("firstname"));
+ userCredentials.setLastName(credentialsMap.get("lastname"));
+ userCredentials.setPassword(credentialsMap.get("password"));
+ return userCredentials;
}
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java
index aa70c376bb..7f19d45dfb 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/datatypes/enums/UserRoleEnum.java
@@ -20,30 +20,44 @@
package org.openecomp.sdc.ci.tests.datatypes.enums;
+import org.openecomp.sdc.ci.tests.config.UserCredentialsFromFile;
+import org.openecomp.sdc.ci.tests.datatypes.UserCredentials;
+
public enum UserRoleEnum {
-// ADMIN("jh0003", "Jimmy", "Hendrix"), DESIGNER("cs0008", "Carlos", "Santana"), DESIGNER2("me0009", "Melissa","Etheridge"), TESTER("jm0007", "Joni", "Mitchell"), ADMIN4("km2000", "Kot", "May"),
+// ADMIN("jh0003", "Jimmy", "Hendrix"), DESIGNER("cs0008", "Carlos", "Santana"), DESIGNER2("me0009", "Melissa","Etheridge"), TESTER("jm0007", "Joni", "Mitchell"), ADMIN4("km2000", "Kot", "May"),
// GOVERNOR("gv0001","David", "Shadmi"), OPS("op0001", "Steve", "Regev"), PRODUCT_STRATEGIST1("ps0001", "Eden","Rozin"), PRODUCT_STRATEGIST2("ps0002", "Ella", "Kvetny"), PRODUCT_STRATEGIST3("ps0003", "Geva", "Alon"),
// PRODUCT_MANAGER1("pm0001", "Teddy", "Isashar"), PRODUCT_MANAGER2("pm0002", "Sarah", "Bettens");
- ADMIN("jh0003", "Jimmy", "Hendrix"), DESIGNER("m08740", "Zero", "ASDCMech"), DESIGNER2("me0009", "Melissa","Etheridge"), DESIGNER3("cs0008", "Carlos", "Santana"),TESTER("jm0007", "Johnny", "Depp"), ADMIN4("km2000", "Kot", "May"),
- GOVERNOR("gv0001","David", "Shadmi"), OPS("af0006", "Aretha", "Franklin"), PRODUCT_STRATEGIST1("ps0001", "Eden","Rozin"), PRODUCT_STRATEGIST2("ps0002", "Ella", "Kvetny"), PRODUCT_STRATEGIST3("ps0003", "Geva", "Alon"),
- PRODUCT_MANAGER1("pm0001", "Teddy", "Isashar"), PRODUCT_MANAGER2("pm0002", "Sarah", "Bettens");
+ ADMIN("admin"),
+ ADMIN2("admin"),
+ DESIGNER("designer"),
+ DESIGNER2("designer"),
+ TESTER("tester"),
+ GOVERNOR("governor"),
+ OPS("ops"),
+ PRODUCT_STRATEGIST1("ops"),
+ PRODUCT_STRATEGIST2("ops"),
+ PRODUCT_STRATEGIST3("ops"),
+ PRODUCT_MANAGER1("ops"),
+ PRODUCT_MANAGER2("ops");
+
+ private String password;
private String userId;
private String firstName;
- private String lastName;
- private String userName;
+ private String lastName;
- private UserRoleEnum(String userId, String userName) {
- this.userId = userId;
- this.userName = userName;
- }
- private UserRoleEnum(String userId, String firstName, String lastName) {
- this.userId = userId;
- this.firstName = firstName;
- this.lastName = lastName;
- this.userName = firstName + " " + lastName;
- }
+ private UserRoleEnum(String userRole) {
+ String name = name();
+ final UserCredentialsFromFile instance = UserCredentialsFromFile.getInstance();
+ this.credentials = instance.getUserCredentialsByRole(userRole);
+ this.userId = this.credentials.getUserId();
+ this.firstName = this.credentials.getFirstName();
+ this.lastName = this.credentials.getLastName();
+ this.password = this.credentials.getPassword();
+ this.userName = this.firstName + " " + this.lastName;
+ }
+
public String getUserId() {
return userId;
@@ -53,14 +67,6 @@ public enum UserRoleEnum {
this.userId = userId;
}
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
public String getFirstName() {
return firstName;
}
@@ -69,12 +75,23 @@ public enum UserRoleEnum {
this.firstName = firstName;
}
+ public UserCredentials getCredentials() {
+ return credentials;
+ }
+
public String getLastName() {
return lastName;
}
- public void setLastName(String lastName) {
- this.lastName = lastName;
+ public String getUserName() {
+ return userName;
}
+ private String userName;
+ private UserCredentials credentials;
+
+
+ public String getPassword() {
+ return password;
+ }
}
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
index 9ab4d0b0dc..304f61d280 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/service/UpdateServiceMetadataTest.java
@@ -89,7 +89,7 @@ public class UpdateServiceMetadataTest extends ComponentBaseTest {
sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
sdncDesignerDetails2 = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER2);
sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN);
- sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN4);
+ sdncAdminDetails = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN2);
sdncGovernorDeatails = ElementFactory.getDefaultUser(UserRoleEnum.GOVERNOR);
sdncTesterDetails = ElementFactory.getDefaultUser(UserRoleEnum.TESTER);
sdncOpsDetails = ElementFactory.getDefaultUser(UserRoleEnum.OPS);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java
index 24afcec40f..28cf1b787f 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/execute/user/ActivateDeActivateDeleteUser.java
@@ -591,7 +591,7 @@ public class ActivateDeActivateDeleteUser extends ComponentBaseTest {
// resource---------------------------------------------------------------------------------
// import new resource with CERTIFIED state
- User importer = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN4);
+ User importer = ElementFactory.getDefaultUser(UserRoleEnum.ADMIN2);
RestResponse importResponse = ImportRestUtils.importResourceByName(resourceDetails, importer);
assertNotNull("check response object is not null after create user", importResponse);
diff --git a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
index 8d62dae8bf..a64c3771c3 100644
--- a/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
+++ b/test-apis-ci/src/main/java/org/openecomp/sdc/ci/tests/sanity/Onboard.java
@@ -106,7 +106,7 @@ public class Onboard extends ComponentBaseTest {
public void runOnboardToDistributionFlow(String filePath, String vnfFile) throws Exception {
ExtentTestActions.log(Status.INFO, String.format("Going to onboard the VNF %s", vnfFile));
- User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER3);
+ User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
Pair<String, VendorSoftwareProductObject> createVendorSoftwareProduct = OnboardingUtillViaApis.createVspViaApis(resourceReqDetails, filePath, vnfFile, user);
VendorSoftwareProductObject vendorSoftwareProductObject = createVendorSoftwareProduct.right;
@@ -116,19 +116,19 @@ public class Onboard extends ComponentBaseTest {
// ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
ExtentTestActions.log(Status.INFO, String.format("Create VF %s From VSP", resourceReqDetails.getName()));
- Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, UserRoleEnum.DESIGNER3);
+ Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails, UserRoleEnum.DESIGNER);
ExtentTestActions.log(Status.INFO, String.format("Certify VF"));
- resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER3, LifeCycleStatesEnum.CERTIFY, true).getLeft();
+ resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//--------------------------SERVICE--------------------------------
ServiceReqDetails serviceReqDetails = OnboardingUtillViaApis.prepareServiceDetailsBeforeCreate(user);
ExtentTestActions.log(Status.INFO, String.format("Create Service %s", serviceReqDetails.getName()));
- Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER3, true).left().value();
+ Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
ExtentTestActions.log(Status.INFO, String.format("add VF to Service"));
- Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER3, true);
+ Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
addComponentInstanceToComponentContainer.left().value();
ExtentTestActions.log(Status.INFO, String.format("Certify Service"));
- service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER3, LifeCycleStatesEnum.CERTIFY, true).getLeft();
+ service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
if (makeDistributionValue.equals("true")) {
ExtentTestActions.log(Status.INFO, String.format("Distribute Service"));
diff --git a/test-apis-ci/src/main/resources/ci/conf/credentials.yaml b/test-apis-ci/src/main/resources/ci/conf/credentials.yaml
new file mode 100644
index 0000000000..19dc605a1f
--- /dev/null
+++ b/test-apis-ci/src/main/resources/ci/conf/credentials.yaml
@@ -0,0 +1,48 @@
+ designer: {
+ username: cs0008,
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ admin: {
+ username: jh0003,
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ ops: {
+ username: af0006,
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ tester: {
+ username: kb0004,
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ governor: {
+ username: ah0002,
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ product_strategist: {
+ username: m99126,
+ password: 1910-FruitGum,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ product_manager: {
+ username: m99127,
+ password: 747-Airplane,
+ firstname: SDC,
+ lastname: SDC2
+ }
+ product_local: {
+ username: pm0001,
+ password: 123123a,
+ firstname: SDC,
+ lastname: SDC2
+ } \ No newline at end of file