Skip to content

Commit

Permalink
Merge pull request #470 from pg-techno123/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
neeharikatech authored Oct 20, 2023
2 parents 9423d8d + 6d53cb0 commit adcdb4b
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ public void run() throws RigInternalError {
Object[] casesListUIN = null;
List<String> idType = BaseTestCase.getSupportedIdTypesValueFromActuator();
Object[] casesListVID = null;

String phone = AdminTestUtil.getValueFromAuthActuator("json-property", "phone_number");
String result = phone.replaceAll("\\[\"|\"\\]", "");

String email = AdminTestUtil.getValueFromAuthActuator("json-property", "emailId");
String emailResult = email.replaceAll("\\[\"|\"\\]", "");

// AuthPartnerProcessor.startProcess();
// step.getScenario().getUinPersonaProp().put("2759239619",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class SetContext extends BaseTestCaseUtil implements StepInterface {
static Logger logger = Logger.getLogger(SetContext.class);

static {
if (ConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
Expand All @@ -27,23 +27,26 @@ public class SetContext extends BaseTestCaseUtil implements StepInterface {
public void run() throws RigInternalError {
constantIntializer();
String contextKeyValue = "dev_context";

String userAndMachineDetailParam = null;
String mosipVersion = null;
boolean generatePrivateKey = Boolean.FALSE;
String status = null;
String negative="valid";
String negative = "valid";
boolean invalidCertFlag = Boolean.FALSE;
String consent="";
boolean changeSupervisorNameToDiffCase=Boolean.FALSE;
//neeha scenario = step.getScenario().getId() + ":" + step.getScenario().getDescription();
String consent = "";
boolean changeSupervisorNameToDiffCase = Boolean.FALSE;
String invalidEncryptedHashFlag = "";
String invalidCheckSum = "";
// neeha scenario = step.getScenario().getId() + ":" +
// step.getScenario().getDescription();
HashMap<String, String> map = new HashMap<String, String>();
HashMap<String, String> dummyholder = new HashMap<String, String>();
if (step.getParameters() == null || step.getParameters().isEmpty() || step.getParameters().size() < 1) {
logger.warn("SetContext Arugemnt is Missing : Please pass the argument from DSL sheet");
} else {
contextKeyValue = step.getParameters().get(0);
contextKeyValue=System.getProperty("env.user")+"_context";
contextKeyValue = step.getParameters().get(0);
contextKeyValue = System.getProperty("env.user") + "_context";
// step.getScenario().getContextInuse()put("contextKey",contextKeyValue );
step.getScenario().getCurrentStep().put(contextKeyValue, "true");
step.getScenario().getCurrentStep().clear();
Expand All @@ -53,7 +56,7 @@ public void run() throws RigInternalError {
if (!(value.equalsIgnoreCase("-1")) && value.contains("@@"))
userAndMachineDetailParam = value;
else if (value.startsWith("$$")) {

map = step.getScenario().getVariables();
}
}
Expand All @@ -67,27 +70,36 @@ else if (value.startsWith("$$")) {

if (step.getParameters().size() > 4) // deactivate
status = step.getParameters().get(4);
if (step.getParameters().size() > 5) // for negative operator and supervisor
if (step.getParameters().size() > 5) // for negative operator and supervisor
negative = step.getParameters().get(5);
if(step.getParameters().size() == 5 && step.getParameters().get(4).contains("true"))

if (step.getParameters().size() == 5 && step.getParameters().get(4).contains("true"))
invalidCertFlag = Boolean.parseBoolean(step.getParameters().get(4));

// consent value either "Y" or "N"
if(step.getParameters().size() == 6 && (step.getParameters().get(5).contains("yes") || step.getParameters().get(5).contains("no")))

// consent value either "yes" or "no"
if (step.getParameters().size() == 6
&& (step.getParameters().get(5).contains("yes") || step.getParameters().get(5).contains("no")))
consent = step.getParameters().get(5);



// supervisorIDFlag
if(step.getParameters().size() > 6 && step.getParameters().get(6).contains("true"))
if (step.getParameters().size() > 6 && step.getParameters().get(6).contains("true"))
changeSupervisorNameToDiffCase = Boolean.parseBoolean(step.getParameters().get(6));

// encryptedHashFlag
if (step.getParameters().size() > 6 && step.getParameters().get(7).contains("invalidEncryptedHash"))
invalidEncryptedHashFlag = step.getParameters().get(7);
// checksumFlag
if (step.getParameters().size() == 9 && step.getParameters().get(8).contains("invalidCheckSum"))
invalidCheckSum = step.getParameters().get(8);

}

if (userAndMachineDetailParam != null)
packetUtility.createContexts(contextKeyValue, userAndMachineDetailParam, mosipVersion, generatePrivateKey,
status, BaseTestCase.ApplnURI + "/",step);
else if(map != null)
packetUtility.createContexts(negative,contextKeyValue, map, mosipVersion, generatePrivateKey, status,
BaseTestCase.ApplnURI + "/",step,invalidCertFlag,consent,changeSupervisorNameToDiffCase);
status, BaseTestCase.ApplnURI + "/", step);
else if (map != null)
packetUtility.createContexts(negative, contextKeyValue, map, mosipVersion, generatePrivateKey, status,
BaseTestCase.ApplnURI + "/", step, invalidCertFlag, consent, changeSupervisorNameToDiffCase,
invalidEncryptedHashFlag, invalidCheckSum);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public void run() throws RigInternalError {
HashMap<String, String> map = new HashMap<String, String>();
String consent="";
boolean supervisorFlag=Boolean.FALSE;
String invalidEncryptedHashFlag = "";
String invalidCheckSum = "";
if (step.getParameters() == null || step.getParameters().isEmpty() || step.getParameters().size() < 1) {
logger.warn("SwitchContext Arugemnt is Missing : Please pass the argument from DSL sheet");
} else {
Expand All @@ -49,7 +51,7 @@ public void run() throws RigInternalError {
if (step.getParameters().size() > 3) // true/false (want to generate privatekey)
generatePrivateKey = Boolean.parseBoolean(step.getParameters().get(3));
if (map != null)
packetUtility.createContexts("",contextKeyValue, map, mosipVersion,generatePrivateKey,null,BaseTestCase.ApplnURI + "/",step,invalidCertFlag,consent,supervisorFlag);
packetUtility.createContexts("",contextKeyValue, map, mosipVersion,generatePrivateKey,null,BaseTestCase.ApplnURI + "/",step,invalidCertFlag,consent,supervisorFlag,invalidEncryptedHashFlag,invalidCheckSum);

else if (userAndMachineDetailParam != null)
packetUtility.createContexts(contextKeyValue, userAndMachineDetailParam, mosipVersion,generatePrivateKey,null,BaseTestCase.ApplnURI + "/",step);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ public String createContexts(String key, String userAndMachineDetailParam, Strin

public String createContexts(String negative, String key, HashMap<String, String> map, String mosipVersion,

Boolean generatePrivateKey, String status, String envbaseUrl, Scenario.Step step, boolean invalidCertFlag,String consent,boolean changeSupervisorNameToDiffCase)
Boolean generatePrivateKey, String status, String envbaseUrl, Scenario.Step step, boolean invalidCertFlag,String consent,boolean changeSupervisorNameToDiffCase,String invalidEncryptedHashFlag, String invalidCheckSum)
throws RigInternalError {
String url = this.baseUrl + "/context/server"; // this.baseUrl + "/context/server/" + key?contextKey=Ckey
logger.info("packet utility base url : " + url);
Expand Down Expand Up @@ -770,7 +770,8 @@ public String createContexts(String negative, String key, HashMap<String, String
jsonReq.put("introducerUIN", getValueFromIdJson("introducerUIN"));
jsonReq.put("introducerRID", getValueFromIdJson("introducerRID"));
jsonReq.put("introducerName", getValueFromIdJson("introducerName"));

jsonReq.put("invalidCheckSum", invalidCheckSum);
jsonReq.put("invalidEncryptedHashFlag", invalidEncryptedHashFlag);
jsonReq.put("changeSupervisorNameToDiffCase", changeSupervisorNameToDiffCase);
jsonReq.put("consent", consent);
jsonReq.put("invalidCertFlag", invalidCertFlag);
Expand Down Expand Up @@ -884,7 +885,7 @@ else if (supervOpertoDetails[3].equalsIgnoreCase(INVALID))
// get value specific to key from actuator
private String getValueFromIdJson(String key) {
String value = AdminTestUtil.getValueFromAuthActuator("json-property", key);
String result = value.replaceAll("\\[\"|\"\\]", "");
String result = value.replaceAll("\\[|\\]", "").replaceAll("\"", "");
return result;
}

Expand Down Expand Up @@ -1030,7 +1031,11 @@ public String packetSync(String personaPath, HashMap<String, String> map, Scenar
if (expectedToPass == false) {
if (response.getBody().asString().contains("RPR-PKR-016")) {
return response.getBody().asString();
} else {
}
else if (response.getBody().asString().contains("RPR-PKR-009")) {
return response.getBody().asString();
}
else {
this.hasError = true;
throw new RigInternalError("Unable to do sync packet from packet utility");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@
"tags": "Postive_Test",
"persona_class": "ResidentMaleAdult",
"persona": "ResidentMaleAdult",
"group_name": "Resident walk-ins to registration center with his child and completes the process",
"description": " gets UIN cards for both",
"group_name": "NA",
"description": "Resident walk-ins to registration center with his child and completes the process gets UIN cards for both",
"step0": "e2e_getPingHealth(packetcreator)",
"step1": "$$details1=e2e_ReadPreReq(1)",
"step2": "e2e_setContext(env_context,$$details1,1@@2,false)",
Expand Down Expand Up @@ -3096,7 +3096,7 @@
"persona_class": "ResidentMaleAdult",
"persona": "ResidentMaleAdult",
"group_name": "NA",
"description": "Resident Infant walk-ins to registration center gets the UIN but during packet generation CBEFF is invalid",
"description": "Resident walk-ins to registration center gets the UIN but during packet generation CBEFF is invalid",
"step0": "e2e_getPingHealth(packetcreator)",
"step1": "$$details1=e2e_ReadPreReq(1)",
"step2": "e2e_setContext(env_context,$$details1,1@@2,false)",
Expand Down Expand Up @@ -3892,6 +3892,69 @@
"step8": "e2e_checkStatus(REREGISTER,$$rid)",
"step9": "e2e_CheckRIDStage($$rid,VALIDATE_PACKET,FAILED)"
},
{
"tc_no": "150",
"tags": "Postive_Test",
"persona_class": "ResidentMaleAdult",
"persona": "ResidentMaleAdult",
"group_name": "New_Infant",
"description": "Resident Infant walk-ins to registration center gets UIN with parent RID details . Another infant tries to get UIN with the same demographics and parent details",
"step0": "e2e_getPingHealth(packetcreator)",
"step1": "$$details1=e2e_ReadPreReq(1)",
"step2": "e2e_setContext(env_context,$$details1,1@@2,false)",
"step3": "e2e_getPingHealth()",
"step4": "$$parentPersona=e2e_getResidentData(1,adult,false,Male)",
"step5": "$$parentTemplate=e2e_getPacketTemplate(NEW,$$parentPersona)",
"step6": "$$parentRid=e2e_generateAndUploadPacketSkippingPrereg($$parentPersona,$$parentTemplate)",
"step7": "e2e_checkStatus(processed,$$parentRid)",
"step8": "$$parentUin=e2e_getUINByRid($$parentRid)",
"step9": "e2e_updateResidentWithUIN($$parentPersona,$$parentUin)",
"step10": "$$childPersona=e2e_getResidentData(1,infant,true,Male@@false@@false@@true)",
"step11": "e2e_updateResidentWithGuardianSkippingPreReg($$parentPersona,$$childPersona)",
"step12": "$$childTemplate=e2e_getPacketTemplate(NEW,$$childPersona)",
"step13": "$$childRid1=e2e_generateAndUploadPacketSkippingPrereg($$childPersona,$$childTemplate)",
"step14": "e2e_checkStatus(processed,$$childRid1)",
"step15": "$$childUin1=e2e_getUINByRid($$childRid1)",
"step16": "e2e_CheckRIDStage($$childRid1,INTRODUCER_VALIDATION,SUCCESS)",
"step17": "e2e_CheckRIDStage($$childRid1,VERIFICATION,SUCCESS)",
"step18": "$$childRid2=e2e_generateAndUploadPacketSkippingPrereg($$childPersona,$$childTemplate)",
"step19": "$$childUin2=e2e_getUINByRid($$childRid2)",
"step20": "e2e_CheckRIDStage($$childRid2,INTRODUCER_VALIDATION,SUCCESS)",
"step21": "e2e_CheckRIDStage($$childRid2,VERIFICATION,SUCCESS)"
},
{
"tc_no": "151",
"tags": "Negative_Test",
"persona_class": "ResidentFemaleAdult",
"persona": "ResidentFemaleAdult",
"group_name": "Adult_New",
"description": "Resident walk-ins to registration center completes the process but while the packet getting created packet has invalid encrypted hash",
"step0": "e2e_getPingHealth(packetcreator)",
"step1": "$$details1=e2e_ReadPreReq(1)",
"step2": "e2e_setContext(env_context,$$details1,1@@2,false,null,null,null,invalidEncryptedHash)",
"step3": "e2e_getPingHealth()",
"step4": "$$personaFilePath=e2e_getResidentData(1,adult,false,Female)",
"step5": "$$templatePath=e2e_getPacketTemplate(NEW,$$personaFilePath)",
"step6": "$$rid=e2e_generateAndUploadPacketSkippingPrereg($$personaFilePath,$$templatePath)",
"step7": "e2e_CheckRIDStage($$rid,VALIDATE_PACKET,REPROCESS,RPR-PKV-FAILED-014)"
},
{
"tc_no": "152",
"tags": "Postive_Test",
"persona_class": "ResidentFemaleAdult",
"persona": "ResidentFemaleAdult",
"group_name": "Adult_New",
"description": "Resident walk-ins to registration center and tries to complete the process . But during packet sync the checksum is invalid",
"step0": "e2e_getPingHealth(packetcreator)",
"step1": "$$details1=e2e_ReadPreReq(1)",
"step2": "e2e_setContext(env_context,$$details1,1@@2,false,null,null,null,null,invalidCheckSum)",
"step3": "e2e_getPingHealth()",
"step4": "$$personaFilePath=e2e_getResidentData(1,adult,false,Female)",
"step5": "$$templatePath=e2e_getPacketTemplate(NEW,$$personaFilePath)",
"step6": "$$zipPacketPath=e2e_packetcreator(NEW,$$templatePath)",
"step7": "$$rid=e2e_ridsync(NEW,$$zipPacketPath)",
"step8": "e2e_packetsync($$zipPacketPath,false)"
},
{
"tc_no": "AFTER_SUITE",
"tags": "Postive_Test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,16 @@ boolean packPacket(String containerRootFolder, String regId, String type, String
}

MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
String encryptedHash = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(
messageDigest.digest(Files.readAllBytes(Path.of(Path.of(containerRootFolder) + ".zip"))));

String encryptedHashFlag =VariableManager.getVariableValue(contextKey, "invalidEncryptedHashFlag").toString();
String encryptedHash =null;

// Make encrypted hash as invalid if "invalidEncryptedHashFlag --yes"
if(encryptedHashFlag.equalsIgnoreCase("invalidEncryptedHash") && type.equals("id"))
encryptedHash = "INVALID_ENCRYPTED_HASH";
else
encryptedHash = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(
messageDigest.digest(Files.readAllBytes(Path.of(Path.of(containerRootFolder) + ".zip"))));

String signature = Base64.getEncoder().encodeToString(
cryptoUtil.sign(Files.readAllBytes(Path.of(Path.of(containerRootFolder) + UNENCZIP)), contextKey));
Expand Down
Loading

0 comments on commit adcdb4b

Please sign in to comment.