Skip to content

Commit

Permalink
MOSIP-30541
Browse files Browse the repository at this point in the history
Signed-off-by: Pankaj Godiyal <[email protected]>
  • Loading branch information
pg-techno123 committed Dec 5, 2023
1 parent dec35c7 commit 62f9e4d
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 137 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.mosip.testrig.dslrig.ivv.e2e.methods;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.json.JSONObject;

import io.mosip.testrig.apirig.kernel.util.ConfigManager;
import io.mosip.testrig.dslrig.ivv.core.base.StepInterface;
import io.mosip.testrig.dslrig.ivv.core.exceptions.RigInternalError;
import io.mosip.testrig.dslrig.ivv.orchestrator.BaseTestCaseUtil;
import io.restassured.response.Response;

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

static {
if (ConfigManager.IsDebugEnabled())
logger.setLevel(Level.ALL);
else
logger.setLevel(Level.ERROR);
}

@Override
public void run() throws RigInternalError {
Response response = null;

String clearBaseUrlNamespaceData = baseUrl + props.getProperty("resetContextData");
response = getRequest(clearBaseUrlNamespaceData, "Clear baseUrl namespace data", step);
if (response != null && response.getStatusCode() == 200) {
String responseString = response.getBody().asString();
if (!responseString.contains("true")) {
logger.info(responseString);
this.hasError = true;
throw new RigInternalError("Clearing baseUrl namespace data from variable manager failed");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,12 @@
"Input Parameters": "NA",
"Return Value": "NA",
"Action": "e2e_GenerateAuthCertifcates()"
},
"Step-43": {
"Description": "Resets the context data",
"Input Parameters": "NA",
"Return Value": "NA",
"Action": "e2e_ResetContextData()"
}
},
{
Expand Down Expand Up @@ -2396,7 +2402,7 @@
"Tag": "Postive_Test",
"Persona": "ResidentMaleAdult",
"Group": "NA",
"Description": "A blind Resident walk-ins to registration center completes the process and gets UIN card. Later performs biometric authentication using left little finger",
"Description": "A differently abled resident walk-ins to registration center completes the process and gets UIN card. Later performs biometric authentication using left little finger",
"Step-0": {
"Description": "Performs health check of given component",
"Input Parameters": "Keyword to check, only packetcreator is supported",
Expand Down Expand Up @@ -16301,7 +16307,7 @@
"Tag": "Postive_Test",
"Persona": "ResidentMaleAdult",
"Group": "Adult_New_Exception",
"Description": "A blind Resident walk-ins to registration center completes the process and gets UIN card .Later updates all biometrics and using uin check for the absence of exception marked modality",
"Description": "A differently abled resident walk-ins to registration center completes the process and gets UIN card .Later updates all biometrics and using uin check for the absence of exception marked modality",
"Step-0": {
"Description": "Performs health check of given component",
"Input Parameters": "Keyword to check, only packetcreator is supported",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ updatePersonabioexceptions=/persona/bioexceptions
blocklistedWord=/v1/masterdata/blocklistedwords/
holidayCreation=/v1/masterdata/holidays
getPacketTagsInfo=/commons/v1/packetmanager/info
clearDeviceCertCache=/clearDeviceCertCache
clearDeviceCertCache=/clearDeviceCertCache
resetContextData=/resetContextData
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.mosip.testrig.dslrig.packetcreator.controller;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

import org.slf4j.Logger;
Expand All @@ -13,6 +16,9 @@
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import io.mosip.mock.sbi.devicehelper.SBIDeviceHelper;
import io.mosip.testrig.dslrig.dataprovider.BiometricDataProvider;
import io.mosip.testrig.dslrig.dataprovider.preparation.MosipMasterData;
import io.mosip.testrig.dslrig.dataprovider.util.DataProviderConstants;
import io.mosip.testrig.dslrig.dataprovider.variables.VariableManager;
import io.mosip.testrig.dslrig.packetcreator.service.ContextUtils;
Expand Down Expand Up @@ -61,4 +67,15 @@ public class ContextController {
}
return bRet;
}

@GetMapping(value = "/resetContextData/{contextKey}")
public @ResponseBody String resetContextData(@PathVariable("contextKey") String contextKey) {
try {
return VariableManager.deleteNameSpace(
VariableManager.getVariableValue(contextKey, "urlBase").toString() + "run_context");
} catch (Exception ex) {
logger.error("resetNameSpaceData", ex);
return "{\"" + ex.getMessage() + "\"}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

public class MosipDataSetup {
private static final Logger logger = LoggerFactory.getLogger(MosipDataSetup.class);
private static String RUN_CONTEXT = "run_context";

public static Properties getConfig(String contextKey) {
Properties props = new Properties();
Expand Down Expand Up @@ -96,8 +97,8 @@ public static List<MosipMachineModel> getMachineDetail(String machineId, String
+ "v1/masterdata/machines/";

url = url + machineId + "/ ";

Object o =getCache(url,contextKey);
String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT;
Object o =getCache(url,run_context);
if(o != null)
return( (List<MosipMachineModel>) o);

Expand All @@ -109,7 +110,7 @@ public static List<MosipMachineModel> getMachineDetail(String machineId, String
machines = objectMapper.readValue(typeArray.toString(),
objectMapper.getTypeFactory().constructCollectionType(List.class, MosipMachineModel.class));

setCache(url, machines,contextKey);
setCache(url, machines,run_context);

}

Expand All @@ -126,9 +127,9 @@ public static List<MosipMachineModel> searchMachineDetail(String machineId, Stri
String url = VariableManager.getVariableValue(contextKey,"urlBase").toString()
+ "v1/masterdata/machines/search";

String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT;


Object o =getCache(url,contextKey);
Object o =getCache(url,run_context);
if(o != null)
return( (List<MosipMachineModel>) o);

Expand Down Expand Up @@ -170,7 +171,7 @@ public static List<MosipMachineModel> searchMachineDetail(String machineId, Stri
machines = objectMapper.readValue(typeArray.toString(),
objectMapper.getTypeFactory().constructCollectionType(List.class, MosipMachineModel.class));

setCache(url, machines,contextKey);
setCache(url, machines,run_context);

}

Expand Down Expand Up @@ -249,8 +250,8 @@ public static List<MosipMachineTypeModel> getMachineTypes(String contextKey) {
String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() +
VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"machinetype").toString();
url = url + "all";

Object o =getCache(url,contextKey);
String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT;
Object o =getCache(url,run_context);
if(o != null)
return( (List<MosipMachineTypeModel>) o);

Expand All @@ -263,7 +264,7 @@ public static List<MosipMachineTypeModel> getMachineTypes(String contextKey) {
machineTypes = objectMapper.readValue(typeArray.toString(),
objectMapper.getTypeFactory().constructCollectionType(List.class, MosipMachineTypeModel.class));

setCache(url, machineTypes,contextKey);
setCache(url, machineTypes,run_context);
}
} catch (Exception e) {
logger.error(e.getMessage());
Expand All @@ -276,8 +277,8 @@ public static List<MosipRegistrationCenterTypeModel> getRegCenterTypes(String co
String url = VariableManager.getVariableValue(contextKey,"urlBase").toString() +
VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"regcentertype").toString();
url = url + "all";

Object o =getCache(url,contextKey);
String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT;
Object o =getCache(url,run_context);
if(o != null)
return( (List<MosipRegistrationCenterTypeModel>) o);

Expand All @@ -290,7 +291,7 @@ public static List<MosipRegistrationCenterTypeModel> getRegCenterTypes(String co
machineTypes = objectMapper.readValue(typeArray.toString(),
objectMapper.getTypeFactory().constructCollectionType(List.class, MosipRegistrationCenterTypeModel.class));

setCache(url, machineTypes,contextKey);
setCache(url, machineTypes,run_context);
}
} catch (Exception e) {
logger.error(e.getMessage());
Expand Down Expand Up @@ -453,8 +454,8 @@ public static List<MosipDeviceModel> getDevices(String centerId,String contextKe
VariableManager.getVariableValue(VariableManager.NS_DEFAULT,"mappeddevices").toString();

url = url +centerId;

Object o =getCache(url,contextKey);
String run_context = VariableManager.getVariableValue(contextKey,"urlBase").toString() + RUN_CONTEXT;
Object o =getCache(url,run_context);
if(o != null)
return( (List<MosipDeviceModel>) o);

Expand All @@ -467,7 +468,7 @@ public static List<MosipDeviceModel> getDevices(String centerId,String contextKe
devices = objectMapper.readValue(typeArray.toString(),
objectMapper.getTypeFactory().constructCollectionType(List.class, MosipDeviceModel.class));

setCache(url, devices,contextKey);
setCache(url, devices,run_context);
}
} catch (Exception e) {
logger.error(e.getMessage());
Expand Down
Loading

0 comments on commit 62f9e4d

Please sign in to comment.