Skip to content

Commit

Permalink
Merge pull request #1594 from nandhu-kumar/develop
Browse files Browse the repository at this point in the history
MOSIP-35700 | Changing few methods in commons to modifying the mimoto testrig to adopt context URL through config
  • Loading branch information
lsivanand committed Sep 11, 2024
2 parents e7dee11 + 3c1b35c commit 154d68d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package io.mosip.testrig.apirig.utils;

import static io.restassured.RestAssured.given;
import de.mkammerer.argon2.Argon2;
import de.mkammerer.argon2.Argon2Factory;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
Expand Down Expand Up @@ -34,8 +33,6 @@
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
Expand All @@ -57,6 +54,8 @@
import java.util.Set;
import java.util.TimeZone;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.ws.rs.core.MediaType;
Expand All @@ -80,9 +79,7 @@
import org.testng.SkipException;
import org.yaml.snakeyaml.Yaml;

import java.lang.Double;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.jknack.handlebars.Context;
import com.github.jknack.handlebars.Handlebars;
Expand Down Expand Up @@ -120,8 +117,6 @@
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* @author Ravi Kant
Expand Down Expand Up @@ -2738,9 +2733,8 @@ public String getAutogenIdKeyName(String testCaseName, String fieldName) {
return null;
int indexof = testCaseName.indexOf("_");
String autogenIdKeyName = testCaseName.substring(indexof + 1);
if ((!BaseTestCase.isTargetEnvLTS() || isOTPEnabled().equals("false")) && fieldName.equals("VID")
&& (BaseTestCase.currentModule.equals("auth") || BaseTestCase.currentModule.equals("esignet")
|| BaseTestCase.currentModule.equals(GlobalConstants.MIMOTO)))
if ((!BaseTestCase.isTargetEnvLTS()) && fieldName.equals("VID")
&& (BaseTestCase.currentModule.equals("auth") || BaseTestCase.currentModule.equals("esignet")))
autogenIdKeyName = autogenIdKeyName + "_" + fieldName.toLowerCase();
else
autogenIdKeyName = autogenIdKeyName + "_" + fieldName;
Expand Down Expand Up @@ -3398,10 +3392,6 @@ public String inputJsonKeyWordHandeler(String jsonString, String testCaseName) {
jsonString = replaceKeywordWithValue(jsonString, "$DOB$",
getValueFromActuator(GlobalConstants.RESIDENT_DEFAULT_PROPERTIES, "mosip.date-of-birth.pattern"));
}
if (jsonString.contains("$GETCLIENTIDFROMMIMOTOACTUATOR$")) {
jsonString = replaceKeywordWithValue(jsonString, "$GETCLIENTIDFROMMIMOTOACTUATOR$",
getValueFromMimotoActuator("overrides", "mimoto.oidc.partner.clientid"));
}
if (jsonString.contains("$IDPREDIRECTURI$")) {
jsonString = replaceKeywordWithValue(jsonString, "$IDPREDIRECTURI$",
ApplnURI.replace(GlobalConstants.API_INTERNAL, "healthservices") + "/userprofile");
Expand Down Expand Up @@ -5166,7 +5156,7 @@ else if (eachRequiredProp.equals("password")) {
}
}
}
if (selectedHandles != null) {
if (selectedHandles != null && selectedHandles.size()>=1) {
setfoundHandlesInIdSchema(true);
identityJson.put("selectedHandles", selectedHandles);
}
Expand Down Expand Up @@ -6539,17 +6529,16 @@ public static String getValueFromActuator(String section, String key) {
}

public static JSONArray mimotoActuatorResponseArray = null;
private static String otpEnabled = "true";

public static String isOTPEnabled() {
String value = getValueFromMimotoActuator("/mimoto-default.properties", "mosip.otp.download.enable");
if (value != null && !(value.isBlank()))
otpEnabled = value;
return otpEnabled;
}

public static String getValueFromMimotoActuator(String section, String key) {
String url = ApplnURI + propsKernel.getProperty("actuatorMimotoEndpoint");
if (!(System.getenv("useOldContextURL") == null)
&& !(System.getenv("useOldContextURL").isBlank())
&& System.getenv("useOldContextURL").equalsIgnoreCase("true")) {
if (url.contains("/v1/mimoto/")) {
url = url.replace("/v1/mimoto/", "/residentmobileapp/");
}
}
String actuatorCacheKey = url + section + key;
String value = actuatorValueCache.get(actuatorCacheKey);
if (value != null && !value.isEmpty())
Expand Down Expand Up @@ -6847,16 +6836,6 @@ else if (testCaseName.startsWith("IdRepository_") && testCaseName.contains("Inva
&& (!isElementPresent(new JSONArray(schemaRequiredField), individualBiometrics))) {
throw new SkipException(GlobalConstants.FEATURE_NOT_SUPPORTED_MESSAGE);
}
} else if (BaseTestCase.currentModule.equalsIgnoreCase(GlobalConstants.MIMOTO)) {
if (isOTPEnabled().equals("false") && (testCaseDTO.getEndPoint().contains(GlobalConstants.SEND_OTP_ENDPOINT)
|| testCaseDTO.getInput().contains(GlobalConstants.SEND_OTP_ENDPOINT)
|| testCaseName.startsWith(GlobalConstants.MIMOTO_CREDENTIAL_STATUS))) {
throw new SkipException(GlobalConstants.OTP_FEATURE_NOT_SUPPORTED);
} else if (isOTPEnabled().equals("true")
&& testCaseDTO.getEndPoint().contains(GlobalConstants.CREATE_VID_ENDPOINT)) {
throw new SkipException(
GlobalConstants.VID_GENERATED_USING_RESIDENT_API_SO_FEATURE_NOT_SUPPORTED_OR_NEEDED_MESSAGE);
}
}

if ((ConfigManager.isInServiceNotDeployedList(GlobalConstants.ESIGNET))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,8 @@ public static boolean doesResponseHasErrorCode(String responseString, String all

public static void reportServerIssues(String responseString, TestCaseDTO testCaseDTO) throws AdminTestException {
if (responseString.startsWith("<!DOCTYPE html>") || responseString.startsWith("<html")
|| responseString.startsWith("no healthy upstream") || responseString == null)
|| responseString.startsWith("no healthy upstream") || responseString == null
|| responseString.isBlank())
throw new AdminTestException("Not a JSON response. Hence marking the test case as failed");

try {
Expand Down

0 comments on commit 154d68d

Please sign in to comment.