Skip to content

Commit

Permalink
MOSIP-30510
Browse files Browse the repository at this point in the history
Signed-off-by: Jayesh Kharode <[email protected]>
  • Loading branch information
Jayesh Kharode committed Dec 1, 2023
1 parent 01a1d94 commit 32fb050
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ else if (key.contains("EXCEPTION") && finalMap.get(key).contains("Exception"))
}

} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ else if (key.contains("EXCEPTION") && !finalMap.get(key).contains("Exception"))
}

} catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static String comparePacketTags(String jsonFromServer, String jsonFromPac
}
}
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
}
return tagMismatched;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package io.mosip.testrig.dslrig.ivv.e2e.methods;

import static org.testng.Assert.assertTrue;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;

import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.apirig.service.BaseTestCase;
import io.mosip.testrig.dslrig.ivv.core.base.StepInterface;
import io.mosip.testrig.dslrig.ivv.core.exceptions.FeatureNotSupportedError;
import io.mosip.testrig.dslrig.ivv.core.exceptions.RigInternalError;
import io.mosip.testrig.dslrig.ivv.orchestrator.BaseTestCaseUtil;

public class ValidateKycData extends BaseTestCaseUtil implements StepInterface {
boolean isDataPresent = false;
String data = "";
String responce = "";
static Logger logger = Logger.getLogger(ValidateKycData.class);
protected static final String AUTH_POLICY_REQUEST1 = "config/AuthPolicy5.json";
String newResponse= "";
org.json.JSONObject responseJson;
@Override
public void run() throws RigInternalError, FeatureNotSupportedError {

if (step.getParameters() == null || step.getParameters().isEmpty()) {
logger.error("Parameter is missing from DSL step");
assertTrue(false, " paramter is missing in step: " + step.getName());
} else if (step.getParameters().size() == 2) {
data = step.getParameters().get(0);
responce = step.getParameters().get(1);
}
newResponse= step.getScenario().getVariables() .get(responce);
responseJson = new org.json.JSONObject(newResponse);
//validateKycData();
//
// org.json.simple.JSONObject AUTH_POLICY_REQUEST2 = BaseTestCase.getRequestJson(AUTH_POLICY_REQUEST1);
// org.json.simple.JSONArray allowedKycAttributes = (JSONArray) AUTH_POLICY_REQUEST2.get("allowedKycAttributes");
//
// for (Object attribute : allowedKycAttributes) {
// org.json.simple.JSONObject attributeObject = (JSONObject) attribute;
// if (data.equals(attributeObject.get("attributeName"))) {
// isDataPresent = true;
// break;
// }
// }
if(responseJson.has(data)) {
System.out.println("data is there");
logger.info(data +" data is there");
logger.info(responseJson);
}else {
logger.info(data +" data is not present");
}
}
// public void validateKycData() {
// org.json.simple.JSONObject AUTH_POLICY_REQUEST2 = BaseTestCase.getRequestJson(AUTH_POLICY_REQUEST1);
// org.json.simple.JSONArray allowedKycAttributes = (JSONArray) AUTH_POLICY_REQUEST2.get("allowedKycAttributes");
//
// for (Object attribute : allowedKycAttributes) {
// org.json.simple.JSONObject attributeObject = (JSONObject) attribute;
// if (data.equals(attributeObject.get("attributeName"))) {
// isDataPresent = true;
// break;
// }
// }
// if(responseJson.has(data)) {
// System.out.println("data is there");
// }
//
// }


}






Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static void writeJSONArrayToFile(JSONArray jsonArray, String filePath) {
fileWriter.write(jsonString);
System.out.println("JSONArray has been written to the file.");
} catch (IOException e) {
e.printStackTrace();
logger.error(e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private String getCommitId() {
+ properties.getProperty("git.branch");

} catch (IOException io) {
io.printStackTrace();
logger.error(io.getMessage());
return "";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class PacketMakerService {
// String constants
private static final String MOSIPTEST_REGCLIENT_SUPERVISORID = "mosip.test.regclient.supervisorid";
private static final String MOSIP_TEST_REGCLIENT_USERID = "mosip.test.regclient.userid";
private static final String MOSIP_TEST_REGCLIENT_SUPERVISORPWD = "mosip.test.regclient.supervisorpwd";
private static final String MOSIP_TEST_REGCLIENT_supervisorP = "mosip.test.regclient.supervisorP";
private static final String MOSIP_TEST_REGCLIENT_PASSWORD = "mosip.test.regclient.password";
private static final String EVIDENCE = "evidence";
private static final String OPTIONAL = "optional";
Expand Down Expand Up @@ -115,13 +115,11 @@ public class PacketMakerService {
@Value("${mosip.test.regclient.supervisorid}")
private String supervisorId;

//@Value("${mosip.test.regclient.supervisorpwd}")
@SuppressWarnings("${mosip.test.regclient.supervisorpwd}")
private String supervisorPwd;
@Value("${mosip.test.regclient.supervisorP}")
private String supervisorP;

//@Value("${mosip.test.regclient.password}")
@SuppressWarnings("${mosip.test.regclient.password}") // This is not an hard coded password.
private String officerPwd;
@Value("${mosip.test.regclient.password}")
private String officerP;

@Value("${mosip.test.regclient.supervisorBiometricFileName}")
private String supervisorBiometricFileName;
Expand Down Expand Up @@ -217,10 +215,10 @@ else if (k.toString().equals("mosip.test.regclient.centerid")) {
supervisorId = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_USERID)) {
officerId = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_SUPERVISORPWD)) {
supervisorPwd = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_supervisorP)) {
supervisorP = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_PASSWORD)) {
officerPwd = v.toString();
officerP = v.toString();
}
});
}
Expand Down Expand Up @@ -327,10 +325,10 @@ else if (k.toString().equals("mosip.test.regclient.centerid")) {
officerId = v.toString();
} else if (k.toString().equals("mosip.version")) {
mosipVersion = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_SUPERVISORPWD)) {
supervisorPwd = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_supervisorP)) {
supervisorP = v.toString();
} else if (k.toString().equals(MOSIP_TEST_REGCLIENT_PASSWORD)) {
officerPwd = v.toString();
officerP = v.toString();
}
});
}
Expand Down Expand Up @@ -604,25 +602,25 @@ boolean createPacket(String containerRootFolder, String regId, String dataFilePa

updatePacketMetaInfo(packetRootFolder, OPERATIONSDATA, "supervisorId", supervisorId, false);

// officerPwd
officerPwd = p.getProperty(MOSIP_TEST_REGCLIENT_PASSWORD);
if (officerPwd != null && officerPwd.equals("invalid"))
officerPwd = FALSE; // invalid
else if (officerPwd != null && !officerPwd.equals(""))
officerPwd = "true"; // valid
// officerP
officerP = p.getProperty(MOSIP_TEST_REGCLIENT_PASSWORD);
if (officerP != null && officerP.equals("invalid"))
officerP = FALSE; // invalid
else if (officerP != null && !officerP.equals(""))
officerP = "true"; // valid
else
officerPwd = FALSE; // null
updatePacketMetaInfo(packetRootFolder, OPERATIONSDATA, "officerPassword", officerPwd, false);

// supervisorPwd
supervisorPwd = p.getProperty(MOSIP_TEST_REGCLIENT_SUPERVISORPWD);
if (supervisorPwd != null && supervisorPwd.equals("invalid"))
supervisorPwd = FALSE; // invalid
else if (supervisorPwd != null && !supervisorPwd.equals(""))
supervisorPwd = "true"; // valid
officerP = FALSE; // null
updatePacketMetaInfo(packetRootFolder, OPERATIONSDATA, "officerPassword", officerP, false);

// supervisorP
supervisorP = p.getProperty(MOSIP_TEST_REGCLIENT_supervisorP);
if (supervisorP != null && supervisorP.equals("invalid"))
supervisorP = FALSE; // invalid
else if (supervisorP != null && !supervisorP.equals(""))
supervisorP = "true"; // valid
else
supervisorPwd = FALSE; // null
updatePacketMetaInfo(packetRootFolder, OPERATIONSDATA, "supervisorPassword", supervisorPwd, false);
supervisorP = FALSE; // null
updatePacketMetaInfo(packetRootFolder, OPERATIONSDATA, "supervisorPassword", supervisorP, false);

// officerBiometricFileName
officerBiometricFileName = p.getProperty("mosip.test.regclient.officerBiometricFileName");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.testrig.dslrig.dataprovider;

import java.io.IOException;
import java.security.SecureRandom;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Base64;
Expand Down Expand Up @@ -51,7 +52,7 @@
*/
public class ResidentDataProvider {
private static final Logger logger = LoggerFactory.getLogger(ResidentDataProvider.class);
private static Random rand = new Random();
private static SecureRandom rand = new SecureRandom ();
Properties attributeList;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.testrig.dslrig.dataprovider.mds;

import java.io.IOException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
Expand All @@ -23,7 +24,7 @@
import io.mosip.testrig.dslrig.dataprovider.variables.VariableManager;

public class MDSClientNoMDS implements MDSClientInterface {
private static Random rand = new Random();
private static SecureRandom rand = new SecureRandom ();
private static final Logger logger = LoggerFactory.getLogger(MDSClientNoMDS.class);

Hashtable<String,MDSDataModel> profileData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
Expand All @@ -33,7 +34,7 @@

public class CommonUtil {
private static final Logger logger = LoggerFactory.getLogger(CommonUtil.class);
private static Random rand = new Random();
private static SecureRandom rand = new SecureRandom();

private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();

Expand Down

0 comments on commit 32fb050

Please sign in to comment.