How to use getListOfSecrets method of org.cerberus.service.datalib.impl.DataLibService class

Best Cerberus-source code snippet using org.cerberus.service.datalib.impl.DataLibService.getListOfSecrets

Source:DataLibService.java Github

copy

Full Screen

...520 }521 /**522 * Get list of subdata that are secrets.523 */524 private List<String> getListOfSecrets(Integer dataLibId) {525 AnswerList<TestDataLibData> answerData = new AnswerList<>();526 List<TestDataLibData> objectDataList = new ArrayList<>();527 List<String> result = new ArrayList<>();528 answerData = testDataLibDataService.readByVarious(dataLibId, null, null, null);529 if ((answerData.getResultMessage().getCode() == MessageEventEnum.DATA_OPERATION_OK.getCode()) && !answerData.getDataList().isEmpty()) {530 objectDataList = answerData.getDataList();531 for (TestDataLibData tdld : objectDataList) {532 if (ParameterParserUtil.parseBooleanParam(tdld.getEncrypt(), false)) {533 result.add(tdld.getSubData());534 }535 }536 }537 LOG.debug("List of Subdata that needs to be hidden : " + result);538 return result;539 }540 /**541 * Get the dataObject List depending on the type542 *543 * @param lib544 * @param columnList545 * @return546 */547 private AnswerList<HashMap<String, String>> getDataObjectList(TestDataLib lib, HashMap<String, String> columnList, int rowLimit, TestCaseExecution execution, TestCaseExecutionData testCaseExecutionData) {548 AnswerList<HashMap<String, String>> result = new AnswerList<>();549 MessageEvent msg = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS);550 CountryEnvironmentDatabase countryEnvironmentDatabase;551 AnswerList<HashMap<String, String>> responseList;552 String system = execution.getApplicationObj().getSystem();553 String country = execution.getCountry();554 String environment = execution.getEnvironment();555 Pattern pattern;556 Matcher matcher;557 Parameter p;558 List<HashMap<String, String>> list;559 List<String> columnsToHide = new ArrayList<>();560 switch (lib.getType()) {561 case TestDataLib.TYPE_CSV:562 /**563 * Before making the call we check if the Service Path is564 * already a proper URL. If it is not, we prefix with the CsvUrl565 * defined from corresponding database. This is used to get the566 * data from the correct environment.567 */568 String servicePathCsv = lib.getCsvUrl();569 LOG.debug("Service Path (Csv) : " + lib.getCsvUrl());570 // Trying making an URL with database context path.571 if (!StringUtil.isURL(servicePathCsv)) {572 // Url is not valid, we try to get the corresponding DatabaseURL CsvURL to prefix.573 if (!(StringUtil.isNullOrEmpty(lib.getDatabaseCsv()))) {574 try {575 countryEnvironmentDatabase = countryEnvironmentDatabaseService.convert(this.countryEnvironmentDatabaseService.readByKey(system,576 country, environment, lib.getDatabaseCsv()));577 if (countryEnvironmentDatabase == null) {578 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_CSV_URLKOANDDATABASECSVURLNOTEXIST);579 msg.setDescription(msg.getDescription()580 .replace("%SERVICEURL%", lib.getCsvUrl())581 .replace("%SYSTEM%", system)582 .replace("%COUNTRY%", country)583 .replace("%ENV%", environment)584 .replace("%DATABASE%", lib.getDatabaseCsv()));585 result.setResultMessage(msg);586 return result;587 } else {588 String csvURL = countryEnvironmentDatabase.getCsvUrl();589 if (StringUtil.isNullOrEmpty(csvURL)) {590 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_CSV_URLKOANDDATABASECSVURLEMPTY);591 msg.setDescription(msg.getDescription()592 .replace("%SERVICEURL%", lib.getCsvUrl())593 .replace("%SYSTEM%", system)594 .replace("%COUNTRY%", country)595 .replace("%ENV%", environment)596 .replace("%DATABASE%", lib.getDatabaseCsv()));597 result.setResultMessage(msg);598 return result;599 }600 // soapURL from database is not empty so we prefix the Service URL with it.601 servicePathCsv = csvURL + lib.getCsvUrl();602 if (!StringUtil.isURL(servicePathCsv)) {603 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_CSV_URLKO);604 msg.setDescription(msg.getDescription()605 .replace("%SERVICEURL%", servicePathCsv)606 .replace("%SOAPURL%", csvURL)607 .replace("%SERVICEPATH%", lib.getCsvUrl())608 .replace("%ENTRY%", lib.getName())609 .replace("%ENTRYID%", lib.getTestDataLibID().toString()));610 result.setResultMessage(msg);611 return result;612 }613 }614 } catch (CerberusException ex) {615 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_CSV_URLKOANDDATABASECSVURLNOTEXIST);616 msg.setDescription(msg.getDescription()617 .replace("%SERVICEURL%", lib.getCsvUrl())618 .replace("%SYSTEM%", system)619 .replace("%COUNTRY%", country)620 .replace("%ENV%", environment)621 .replace("%DATABASE%", lib.getDatabaseCsv()));622 result.setResultMessage(msg);623 return result;624 }625 }626 }627 // Trying make a valid path with csv parameter path.628 if (!StringUtil.isURL(servicePathCsv)) {629 // Url is still not valid. We try to add the path from csv parameter.630 String csv_path = parameterService.getParameterStringByKey("cerberus_testdatalibcsv_path", "", "");631 csv_path = StringUtil.addSuffixIfNotAlready(csv_path, File.separator);632 servicePathCsv = csv_path + servicePathCsv;633 }634 // Get list of columns to hide.635 columnsToHide = getListOfSecrets(lib.getTestDataLibID());636 // CSV Call is made here.637 responseList = fileService.parseCSVFile(servicePathCsv, lib.getSeparator(), columnList, columnsToHide, execution);638 list = responseList.getDataList();639 //if the query returns sucess then we can get the data640 if (responseList.getResultMessage().getCode() == MessageEventEnum.PROPERTY_SUCCESS_CSV.getCode()) {641 if (list != null && !list.isEmpty()) {642 result.setDataList(list);643 msg = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB_CSV);644 msg.setDescription(msg.getDescription().replace("%NBROW%", String.valueOf(result.getDataList().size())).replace("%CSVURL%", servicePathCsv));645 } else {646 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_CSVDATABASENODATA);647 msg.setDescription(msg.getDescription().replace("%CSVURL%", servicePathCsv));648 }649 } else {650 msg = responseList.getResultMessage();651 }652 result.setResultMessage(msg);653 break;654 case TestDataLib.TYPE_SQL:655 String connectionName;656 String db = lib.getDatabase();657 try {658 if (StringUtil.isNullOrEmpty(db)) {659 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SQLDATABASEEMPTY);660 } else {661 countryEnvironmentDatabase = countryEnvironmentDatabaseService.convert(countryEnvironmentDatabaseService.readByKey(system,662 country, environment, db));663 if (countryEnvironmentDatabase == null) {664 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SQLDATABASENOTCONFIGURED);665 msg.setDescription(msg.getDescription().replace("%SYSTEM%", system)666 .replace("%COUNTRY%", country).replace("%ENV%", environment)667 .replace("%DATABASE%", db));668 } else {669 connectionName = countryEnvironmentDatabase.getConnectionPoolName();670 if (!(StringUtil.isNullOrEmpty(connectionName))) {671 // Get list of columns to hide.672 columnsToHide = getListOfSecrets(lib.getTestDataLibID());673 LOG.debug("To hide : " + columnsToHide);674 Integer sqlTimeout = parameterService.getParameterIntegerByKey("cerberus_propertyexternalsql_timeout", system, 60);675 //performs a query that returns several rows containing n columns676 responseList = sqlService.queryDatabaseNColumns(connectionName, lib.getScript(), rowLimit, sqlTimeout, system, columnList, columnsToHide, execution);677 //if the query returns sucess then, we can get the data678 if (responseList.getResultMessage().getCode() == MessageEventEnum.PROPERTY_SUCCESS_SQL.getCode()) {679 list = responseList.getDataList();680 if (list != null && !list.isEmpty()) {681 result.setDataList(list);682 msg = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETFROMDATALIB_SQL);683 msg.setDescription(msg.getDescription().replace("%NBROW%", String.valueOf(result.getDataList().size())));684 } else {685 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SQLDATABASENODATA);686 }687 } else {688 msg = responseList.getResultMessage();689 }690 msg.setDescription(msg.getDescription().replace("%DATABASE%", db));691 msg.setDescription(msg.getDescription().replace("%SQL%", lib.getScript()));692 msg.setDescription(msg.getDescription().replace("%JDBCPOOLNAME%", connectionName));693 } else {694 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SQLDATABASEJDBCRESSOURCEMPTY);695 msg.setDescription(msg.getDescription().replace("%SYSTEM%", system).replace("%COUNTRY%", country).replace("%ENV%", environment).replace("%DATABASE%", db));696 }697 }698 }699 } catch (CerberusException ex) {700 msg = new MessageEvent(MessageEventEnum.PROPERTY_FAILED_GETFROMDATALIB_SQLDATABASENOTCONFIGURED);701 msg.setDescription(msg.getDescription().replace("%SYSTEM%", system).replace("%COUNTRY%", country).replace("%ENV%", environment).replace("%DATABASE%", db));702 }703 result.setResultMessage(msg);704 break;705 case TestDataLib.TYPE_SERVICE:706 AppService appService = new AppService();707 HashMap<String, String> resultHash = new HashMap<>();708 List<HashMap<String, String>> listResult = new ArrayList<>();709 // Temporary list of string.710 List<String> listTemp1 = null;711 // String containing the XML712 String responseString = "";713 /**714 * Before making the call we check if the Service Path is715 * already a propper URL. If it is not, we prefix with the716 * SoapUrl defined from corresponding database. This is used to717 * get the data from the correct environment.718 */719 String servicePath = lib.getServicePath();720 LOG.debug("Service Path : " + lib.getServicePath());721 // Get list of columns to hide.722 columnsToHide = getListOfSecrets(lib.getTestDataLibID());723 // Service Call is made here.724 AnswerItem ai = serviceService.callService(lib.getService(), null, null, lib.getDatabaseUrl(), lib.getEnvelope(), lib.getServicePath(), lib.getMethod(), execution);725 msg = ai.getResultMessage();726 //if the call returns success then we can process the soap ressponse727 if (msg.getCode() == MessageEventEnum.ACTION_SUCCESS_CALLSERVICE.getCode()) {728 appService = (AppService) ai.getItem();729 // Call successful so we can start to parse the result and build RawData per columns from subdata entries.730 /**731 * This Step will calculate hashTemp1 : Hash of List from732 * the Service response.733 */734 // Will contain the nb of row of the target list of Hash.735 int finalnbRow = 0;736 // Will contain the result of the XML parsing....

Full Screen

Full Screen

getListOfSecrets

Using AI Code Generation

copy

Full Screen

1import org.cerberus.service.datalib.impl.DataLibService;2import org.cerberus.service.datalib.impl.DataLibType;3import org.cerberus.service.datalib.impl.DataLibTypeFactory;4import org.cerberus.service.datalib.impl.DataLibTypeEnum;5import org.cerberus.service.datalib.impl.DataLibTypeFactory;6import org.cerberus.service.datalib.impl.DataLibTypeEnum;7import org.cerberus.service.datalib.impl.DataLibTypeFactory;8import org.cerberus.service.datalib.impl.DataLibTypeEnum;9import org.cerberus.service.datalib.impl.DataLibTypeFactory;10import org.cerberus.service.datalib.impl.DataLibTypeEnum;11public class DataLibService_GetListOfSecrets {12 public static void main(String[] args) {13 DataLibService dls = new DataLibService();14 DataLibTypeFactory dltf = new DataLibTypeFactory();15 DataLibType dlt = dltf.create(DataLibTypeEnum.SECRET);16 dlt.setSecret("CerberusLogin");17 dlt.setSecretKey("CerberusPassword");18 dlt.setSecretValue("CerberusPassword");19 dlt.setSecretType("MYSQL");20 dlt.setSecretPath("CerberusLogin");21 dlt.setSecretHost("localhost");22 dlt.setSecretPort("3306");23 dlt.setSecretDatabase("cerberus");24 dlt.setSecretTable("user");25 dlt.setSecretColumn("Login");26 dlt.setSecretColumn("Password");

Full Screen

Full Screen

getListOfSecrets

Using AI Code Generation

copy

Full Screen

1var listOfSecrets = new org.json.JSONArray();2listOfSecrets = org.cerberus.service.datalib.impl.DataLibService.getListOfSecrets();3testDataLib.setData("listOfSecrets", listOfSecrets);4LOG.info(listOfSecrets.toString());5LOG.info(testDataLib.getData("listOfSecrets"));6LOG.info(testDataLib.getData("listOfSecrets"));7LOG.info(testDataLib.getData("listOfSecrets"));8LOG.info(testDataLib.getData("listOfSecrets"));9LOG.info(testDataLib.getData("listOfSecrets"));10LOG.info(testDataLib.getData("listOfSecrets"));

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful