Skip to content

Commit

Permalink
Merge pull request #1673 from mohanachandran-s/release-1.3.0
Browse files Browse the repository at this point in the history
MOSIP-37533 - Synced the release-1.3.0 branch with develop branch
  • Loading branch information
mohanachandran-s authored Nov 25, 2024
2 parents cf0c5ac + d4070ad commit 1a2e099
Show file tree
Hide file tree
Showing 15 changed files with 518 additions and 718 deletions.
5 changes: 5 additions & 0 deletions apitest-commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.tyrus.bundles</groupId>
<artifactId>tyrus-standalone-client</artifactId>
<version>1.13.1</version>
</dependency>
<dependency>
<groupId>io.mosip.authentication</groupId>
<artifactId>authentication-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.apache.log4j.PropertyConfigurator;
import org.json.JSONArray;
import org.json.simple.JSONObject;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.ITestContext;
import org.testng.annotations.AfterSuite;

Expand All @@ -44,7 +43,7 @@
* All suite level before and after tests will be completed here.
*
*/
public class BaseTestCase extends AbstractTestNGSpringContextTests {
public class BaseTestCase {

protected static Logger logger = Logger.getLogger(BaseTestCase.class);
public static OTPListener otpListener = null;
Expand Down Expand Up @@ -75,6 +74,7 @@ public class BaseTestCase extends AbstractTestNGSpringContextTests {
public String partnerCookie = null;
public String partnerrevampCookie = null;
public String partnerrevampdeviceCookie = null;
public String partnerrevampftmCookie = null;
public String partnerNewCookie = null;
public String withoutpartnerCookie = null;
public String withoutpolicyCookie = null;
Expand Down Expand Up @@ -133,6 +133,8 @@ public class BaseTestCase extends AbstractTestNGSpringContextTests {
public static String hierarchyName = "";
public static int hierarchyLevel = 0;
public static String parentLocCode = "";
public static String locationName = "";
public static int hierarchyLevelWithLocationCode = 0;

public static String locationCode = "";
public static String ZonelocationCode = "";
Expand Down Expand Up @@ -208,7 +210,7 @@ public static String getGlobalResourcePath() {
if (runTypeS.equalsIgnoreCase("JAR")) {
path = new File(jarURLS).getParentFile().getAbsolutePath() + "/MosipTestResource/MosipTemporaryTestResource";
} else if (runTypeS.equalsIgnoreCase("IDE")) {
path = new File(MosipTestRunner.class.getClassLoader().getResource("").getPath()).getAbsolutePath()
path = new File(BaseTestCase.class.getClassLoader().getResource("").getPath()).getAbsolutePath()
+ "/MosipTestResource/MosipTemporaryTestResource";
if (path.contains(GlobalConstants.TESTCLASSES))
path = path.replace(GlobalConstants.TESTCLASSES, "classes");
Expand Down Expand Up @@ -571,10 +573,12 @@ public static List<String> getLanguageList() {
}

private static String targetEnvVersion = "";

public static boolean isTargetEnvLatest = false;

public static boolean isTargetEnvLTS() {

if (targetEnvVersion.isEmpty()) {
if (targetEnvVersion.isEmpty() && isTargetEnvLatest == false) {

Response response = null;
org.json.JSONObject responseJson = null;
Expand All @@ -585,14 +589,16 @@ public static boolean isTargetEnvLTS() {
responseJson = new org.json.JSONObject(response.getBody().asString());

targetEnvVersion = responseJson.getJSONObject("build").getString("version");
isTargetEnvLatest = isVersionGreaterOrEqual(targetEnvVersion, "1.2");

} catch (Exception e) {
logger.error(GlobalConstants.EXCEPTION_STRING_2 + e);
}
}

// Compare the version numbers, ignoring any suffix like "-SNAPSHOT"
return isVersionGreaterOrEqual(targetEnvVersion, "1.2");

return isTargetEnvLatest;
}

private static boolean isVersionGreaterOrEqual(String version1, String version2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void copyCommonResources(String moduleName) {
public static void getListOfFilesFromJarAndCopyToExternalResource(String key) {
ZipInputStream zipInputStream = null;
try {
CodeSource src = MosipTestRunner.class.getProtectionDomain().getCodeSource();
CodeSource src = BaseTestCase.class.getProtectionDomain().getCodeSource();
if (src != null) {
URL jar = src.getLocation();
zipInputStream = new ZipInputStream(jar.openStream());
Expand Down Expand Up @@ -106,7 +106,7 @@ private static boolean copyFilesFromJarToOutsideResource(String resourceFilePare
String resourceFileAbsolutePath = resourceFileParentPath + "MosipTemporaryTestResource/" + resourceFileName;
File destinationFile = new File(resourceFileAbsolutePath);
LOGGER.info("resourceFile : " + BaseTestCase.jarURLS + "destinationFile : " + resourceFileAbsolutePath);
org.apache.commons.io.FileUtils.copyInputStreamToFile(MosipTestRunner.class.getResourceAsStream("/" + resourceFileName), destinationFile);
org.apache.commons.io.FileUtils.copyInputStreamToFile(BaseTestCase.class.getResourceAsStream("/" + resourceFileName), destinationFile);
return true;
} catch (Exception e) {
LOGGER.error(
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,16 @@ public void onError(WebSocket webSocket, Throwable error) {
}

public static String getOtp(String emailId) {
if (ConfigManager.getUsePreConfiguredOtp().equalsIgnoreCase(GlobalConstants.TRUE_STRING)) {
return ConfigManager.getPreConfiguredOtp();
}
int otpExpTime = AdminTestUtil.getOtpExpTimeFromActuator();
int otpCheckLoopCount = (otpExpTime * 1000) / AdminTestUtil.OTP_CHECK_INTERVAL;

int counter = 0;

String otp = "";


if (ConfigManager.getUsePreConfiguredOtp().equalsIgnoreCase(GlobalConstants.TRUE_STRING)) {
return ConfigManager.getPreConfiguredOtp();
}

while (counter < otpCheckLoopCount) {
if (emailNotificationMapS.get(emailId) != null) {
String html = (String) emailNotificationMapS.get(emailId);
Expand Down
Loading

0 comments on commit 1a2e099

Please sign in to comment.