Skip to content

Commit 56b5f46

Browse files
MOSIP-43588 - Updated the release-1.3.x branch with latest code
Signed-off-by: Mohanachandran S <mohanachandran.s@technoforte.co.in>
1 parent 53c2951 commit 56b5f46

13 files changed

Lines changed: 138 additions & 30 deletions

File tree

apitest-commons/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,16 +510,6 @@
510510
</plugins>
511511
</pluginManagement>
512512
<plugins>
513-
<plugin>
514-
<groupId>org.sonatype.central</groupId>
515-
<artifactId>central-publishing-maven-plugin</artifactId>
516-
<version>${central.publishing.maven.plugin.version}</version>
517-
<extensions>true</extensions>
518-
<configuration>
519-
<publishingServerId>ossrh</publishingServerId>
520-
<autoPublish>false</autoPublish>
521-
</configuration>
522-
</plugin>
523513
<plugin>
524514
<groupId>org.sonatype.central</groupId>
525515
<artifactId>central-publishing-maven-plugin</artifactId>

apitest-commons/src/main/java/io/mosip/testrig/apirig/dbaccess/DBManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.HashMap;
1313
import java.util.Map;
1414

15+
import io.mosip.testrig.apirig.testrunner.BaseTestCase;
1516
import org.apache.log4j.Level;
1617
import org.apache.log4j.Logger;
1718
import org.hibernate.HibernateException;
@@ -244,6 +245,7 @@ public void execute(Connection connection) throws SQLException {
244245
while ((line = bufferedReader.readLine()) != null) {
245246
if (line.trim().equals("") || line.trim().startsWith("#"))
246247
continue;
248+
line = line.replace("${currentModule}", BaseTestCase.currentModule);
247249
statement.addBatch(line);
248250
}
249251
} catch (IOException e) {

apitest-commons/src/main/java/io/mosip/testrig/apirig/report/EmailableReport.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ public void generateOutputFile(boolean skipPassed) {
161161
}
162162

163163
String oldString = System.getProperty(GlobalConstants.EMAILABLEREPORT2NAME);
164+
// Remove unwanted random suffix (e.g., -5e9, -2b9, -abc123) before the module name
165+
oldString = oldString.replaceAll("-[a-z0-9]{3,}(?=_)", "");
164166
String temp = "";
165167
String reportContext = skipPassed == true ? "error-" : "full-";
166168

apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/BaseTestCase.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.apache.log4j.PropertyConfigurator;
2121
import org.json.JSONArray;
2222
import org.json.simple.JSONObject;
23-
import org.testng.ITestContext;
2423
import org.testng.annotations.AfterSuite;
2524

2625
import com.aventstack.extentreports.ExtentReports;
@@ -162,8 +161,10 @@ public class BaseTestCase {
162161
public String genPolicyNameNonAuth = "policyNameForEsignet" + generateRandomNumberString(4);
163162
public String genMispPolicyName = "policyNameForMispEsi" + generateRandomNumberString(6)
164163
+ generateRandomNumberString(3);
165-
public static String genPartnerName = "partnernameforautomationesi-" + generateRandomNumberString(6);
166-
public static String genPartnerNameNonAuth = "partnernameforesignet-" + generateRandomNumberString(6);
164+
//public static String genPartnerName = "partnernameforautomationesi-" + generateRandomNumberString(6);
165+
public static String genPartnerName = null;
166+
//public static String genPartnerNameNonAuth = "partnernameforesignet-" + generateRandomNumberString(6);
167+
public static String genPartnerNameNonAuth = BaseTestCase.currentModule + "-partnernameforesignet";
167168
public String genPartnerNameForDsl = "partnernameforautomationdsl-" + generateRandomNumberString(6);
168169
public static String genMispPartnerName = "esignet_" + generateRandomNumberString(6)
169170
+ generateRandomNumberString(3);
@@ -187,6 +188,8 @@ public class BaseTestCase {
187188

188189
private static String runTypeS = "";
189190
protected static String jarURLS = "";
191+
192+
public static String runContext = GlobalMethods.getRunContext();
190193

191194
public static void setLogLevel() {
192195
if (ConfigManager.IsDebugEnabled())
@@ -213,6 +216,10 @@ public static void init() {
213216
* "@gmail.com"; static String role = PartnerRegistration.partnerType;
214217
*/
215218

219+
public static void initializePMSDetails() {
220+
genPartnerName = BaseTestCase.currentModule + "-partnernameforautomationesi";
221+
}
222+
216223
public static String getGlobalResourcePath() {
217224
if (cachedPath != null) {
218225
return cachedPath;

apitest-commons/src/main/java/io/mosip/testrig/apirig/testrunner/OTPListener.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ public static String getOtp(String emailId) {
143143
logger.info("*******emailNotificationMapS value = " + emailNotificationMapS + " and emailId = " + emailId);
144144
if (emailNotificationMapS.get(emailId) != null) {
145145
String html = (String) emailNotificationMapS.get(emailId);
146-
emailNotificationMapS.remove(emailId);
146+
if(BaseTestCase.currentModule.equals(GlobalConstants.DSL)) {
147+
emailNotificationMapS.remove(emailId);
148+
} else {
149+
emailNotificationMapS.clear();
150+
}
147151
otp = parseOtp(html);
148152
if (otp != null && otp.length() > 0) {
149153
logger.info("Found the OTP = " + otp);

apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/AdminTestUtil.java

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,15 @@ public class AdminTestUtil extends BaseTestCase {
172172
protected static String preregHbsForCreate = null;
173173
protected static String preregHbsForUpdate = null;
174174
protected static String timeStamp = String.valueOf(Calendar.getInstance().getTimeInMillis());
175-
protected static String policyGroup = "mosip auth policy group " + timeStamp;
175+
protected static String policyGroup = "mosip auth policy group " + BaseTestCase.runContext + timeStamp;
176176
protected static String mispPolicyGroup = "mosip misp policy group " + timeStamp;
177177
protected static String policyGroupForUpdate = "mosip auth policy group update " + timeStamp;
178178
protected static String policyGroup2 = "mosip auth policy group2 " + timeStamp;
179179
protected static String policyName = "mosip auth policy " + timeStamp;
180180
protected static String mispPolicyName = "mosip misp policy " + timeStamp;
181181
protected static String policyName2 = "mosip auth policy2 " + timeStamp;
182182
protected static String policyNameForUpdate = "mosip auth policy for update " + timeStamp;
183+
protected static final String preRegUser = "Prereg_" + BaseTestCase.runContext +"@mosip.net";
183184
protected static final String UPDATE_UIN_REQUEST = "config/Authorization/requestIdentity.json";
184185
protected static final String AUTH_INTERNAL_REQUEST = "config/Authorization/internalAuthRequest.json";
185186
protected static final String AUTH_POLICY_BODY = "config/AuthPolicy.json";
@@ -1440,7 +1441,6 @@ protected Response getWithPathParamAndCookieForAutoGeneratedId(String url, Strin
14401441
throws SecurityXSSException {
14411442
Response response = null;
14421443
jsonInput = inputJsonKeyWordHandeler(jsonInput, testCaseName);
1443-
14441444
if (bothAccessAndIdToken) {
14451445
token = kernelAuthLib.getTokenByRole(role, ACCESSTOKENCOOKIENAME);
14461446
idToken = kernelAuthLib.getTokenByRole(role, IDTOKENCOOKIENAME);
@@ -1521,7 +1521,7 @@ protected Response getWithPathParamAndCookieForAutoGeneratedId(String url, Strin
15211521
}
15221522
return response;
15231523
}
1524-
1524+
15251525
public static String encodeBase64(String value) {
15261526
String encodedStr;
15271527
try {
@@ -3783,6 +3783,23 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
37833783
String.valueOf(hierarchyLevelWithLocationCode));
37843784
}
37853785

3786+
if (jsonString.contains("$PREREGUSER$")) {
3787+
jsonString = replaceKeywordWithValue(jsonString, "$PREREGUSER$", preRegUser);
3788+
}
3789+
3790+
if (jsonString.contains("$PHONENUMBER$")) {
3791+
try {
3792+
jsonString = replaceKeywordWithValue(jsonString, "$PHONENUMBER$", genStringAsperRegex(phoneSchemaRegex));
3793+
} catch (Exception e) {
3794+
throw new RuntimeException(e);
3795+
}
3796+
}
3797+
3798+
if (jsonString.contains("$EMAILVALUE$")) {
3799+
jsonString = replaceKeywordWithValue(jsonString, "$EMAILVALUE$",
3800+
BaseTestCase.currentModule + "_" + generateRandomAlphaNumericString(5) + "@mosip.com");
3801+
}
3802+
37863803
if (jsonString.contains("$CACERT$")) {
37873804
JSONObject request = new JSONObject(jsonString);
37883805
String partnerId = null;
@@ -4200,9 +4217,9 @@ protected static String replaceIdWithAutogeneratedId(String jsonString, String i
42004217
&& ConfigManager.getMockNotificationChannel().equalsIgnoreCase("phone")) {
42014218
String temp = idKey + keyForIdProperty + "$"; // $ID:AddIdentity_withValidParameters_smoke_Pos_EMAIL$
42024219
keyForIdProperty = keyForIdProperty.replace("_EMAIL", "_PHONE"); // AddIdentity_withValidParameters_smoke_Pos_PHONE
4203-
keyToReplace = temp; // $ID:AddIdentity_withValidParameters_smoke_Pos_PHONE$@phone
4220+
keyToReplace = temp;
42044221

4205-
jsonString = jsonString.replace(temp, temp + "@phone");
4222+
jsonString = jsonString.replace(temp, temp + "@phone");// $ID:AddIdentity_withValidParameters_smoke_Pos_PHONE$@phone
42064223

42074224
} else if (keyForIdProperty.endsWith("_PHONE")
42084225
&& ConfigManager.getMockNotificationChannel().equalsIgnoreCase("email")) {
@@ -5604,6 +5621,11 @@ public static String generateHbsForPrereg(boolean isItUpdate) {
56045621
phoneFieldAdditionallyAdded = true;
56055622
}
56065623

5624+
if (identityPropsJson.has(result)) {
5625+
phoneSchemaRegex = identityPropsJson.getJSONObject(result).getJSONArray("validators").getJSONObject(0)
5626+
.getString("validator");
5627+
}
5628+
56075629
// System.out.println("result is:" + result);
56085630
String email = getValueFromAuthActuator("json-property", "emailId");
56095631
String emailResult = email.replaceAll("\\[\"|\"\\]", "");
@@ -5672,7 +5694,11 @@ public static String generateHbsForPrereg(boolean isItUpdate) {
56725694

56735695
if (eachRequiredProp.equals("IDSchemaVersion")) {
56745696
identityJson.put(eachRequiredProp, schemaVersion);
5675-
} else {
5697+
} else if (eachRequiredProp.equals(emailResult)) {
5698+
identityJson.put(eachRequiredProp, "$EMAILVALUE$");
5699+
} else if (eachRequiredProp.equals(result)) {
5700+
identityJson.put(eachRequiredProp, "$PHONENUMBERFORIDENTITY$");
5701+
} else {
56765702
identityJson.put(eachRequiredProp, "{{" + eachRequiredProp + "}}");
56775703
}
56785704
}

apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/DependencyResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ public static void main(String[] args) throws Exception {
5454
System.out.println(getDependencies("TC_IDRepo_AuthInternalock_01"));
5555
System.out.println(getDependencies("TC_IDRepo_AddIdentity_32"));
5656
}
57-
}
57+
}

apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/GlobalMethods.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.List;
1010
import java.util.Map;
1111
import java.util.Set;
12+
import java.util.UUID;
1213
import java.util.regex.Matcher;
1314
import java.util.regex.Pattern;
1415

@@ -34,8 +35,10 @@ public class GlobalMethods {
3435
// Compile the regex pattern
3536
private static Pattern pattern_1 = Pattern.compile(regex_1);
3637
private static Pattern pattern_2 = Pattern.compile(regex_2);
37-
38-
public static boolean isXSSProtectionCheckEnabled() {
38+
39+
public static String runContext = null;
40+
41+
public static boolean isXSSProtectionCheckEnabled() {
3942
return ConfigManager.getproperty("xssProtectionCheck").equalsIgnoreCase("yes") ? true : false;
4043
}
4144

@@ -69,6 +72,13 @@ public static void setModuleNameAndReCompilePattern(String value) {
6972
pattern_1 = Pattern.compile(regex_1);
7073
pattern_2 = Pattern.compile(regex_2);
7174
}
75+
76+
public static String getRunContext() {
77+
// Generate a UUID, remove dashes,convert to lowercase, and take first 3 characters
78+
runContext = UUID.randomUUID().toString().replaceAll("-", "").toLowerCase().substring(0, 3) + "_";
79+
logger.info("RUN_CONTEXT set to: " + runContext);
80+
return runContext;
81+
}
7282

7383
public static void main(String[] arg) {
7484

apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KernelAuthentication.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,9 @@ public String getPreRegToken() {
609609
actualRequest_generation.put(GlobalConstants.REQUESTTIME, AdminTestUtil.getCurrentUTCTime());
610610
((JSONObject) actualRequest_generation.get(GlobalConstants.REQUEST)).put("langCode",
611611
BaseTestCase.getLanguageList().get(0));
612-
((JSONObject) actualRequest_generation.get(GlobalConstants.REQUEST)).get("userId").toString();
613-
String userId = ((JSONObject) actualRequest_generation.get(GlobalConstants.REQUEST)).get("userId").toString();
612+
String userId = AdminTestUtil.preRegUser;
613+
((JSONObject) actualRequest_generation.get(GlobalConstants.REQUEST)).put("userId",
614+
userId);
614615
JSONObject actualRequest_validation = getRequestJson("config/prereg_ValidateOtp.json");
615616
AdminTestUtil.postWithJson(preregSendOtp, actualRequest_generation);
616617
String otp = null;
@@ -622,6 +623,8 @@ public String getPreRegToken() {
622623
}
623624
((JSONObject) actualRequest_validation.get(GlobalConstants.REQUEST)).put("otp", otp);
624625
actualRequest_validation.put(GlobalConstants.REQUESTTIME, AdminTestUtil.getCurrentUTCTime());
626+
((JSONObject) actualRequest_validation.get(GlobalConstants.REQUEST)).put("userId",
627+
userId);
625628
Response otpValidate = AdminTestUtil.postWithJson(preregValidateOtp, actualRequest_validation);
626629
cookie = otpValidate.getCookie(GlobalConstants.AUTHORIZATION);
627630
return cookie;

apitest-commons/src/main/java/io/mosip/testrig/apirig/utils/KeyMgrUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,10 @@ private static X500Name getCertificateAttributes(String cn, String organization)
393393
public PrivateKeyEntry getKeyEntry(String dirPath, String parterId) throws NoSuchAlgorithmException, UnrecoverableEntryException,
394394
KeyStoreException, CertificateException, IOException, OperatorCreationException {
395395
String filePrepend = parterId;
396+
396397
String partnerFilePath = dirPath + '/' +PartnerRegistration.appendEkycOrRp.get()+ filePrepend + PARTNER_P12_FILE_NAME;;
397-
logger.info("partnerFilePath : "+partnerFilePath);
398-
return getPrivateKeyEntry(partnerFilePath);
398+
logger.info("partnerFilePath : "+partnerFilePath);
399+
return getPrivateKeyEntry(partnerFilePath);
399400
}
400401

401402
/**

0 commit comments

Comments
 (0)